few things my platformer needs help

my first platformer uses the contra shooting like you can move the player in any direction to shoot their gun - which Dr. Alex has to do the same thing on his Phaser Rifle instead of the Megaman jump and shoot idea.

Also how I can do upgrades to the Phaser Rifle making it more powerful or select a special mode to stop Emerald's robots.

This Platformer requires firing of a gun like Troll Burner.

if anyone knows the code or script let me know so I can start working on Dr Emerald's Revenge.
 

WolfMerrik

New member
Well, you are probably going to want to shoot in 8 directions right?
Have you looked at modifying the "Move 8 Directions" Script, to changing this to the direction the player shoots in?
 
WolfMerrik said:
Well, you are probably going to want to shoot in 8 directions right?
Have you looked at modifying the "Move 8 Directions" Script, to changing this to the direction the player shoots in?

That's what I'm aiming for to make it contra like so it's easy on the player to shoot in different directions and I didn't mention a way to "Scroll the screen."

so I'm not sure which one to mod and add it in my custom folder if it works like so.
 
Hey, if it helps you go in the right direction, here is my current platform shooting script:
Note: This is a work in progress. I don't like how firing straight up is handled. You will also need to tweak it to your own game and sprites.
This will let you fire left, right, up, and crouched left and right.

You will also need to add a user variable plrShotlim and update it in the collision scripts when a projectile hits a monster and when it hits a solid/edge.

Code:
createWeaponProjectile:
  LDA gameHandler
  AND #%00100000
    BEQ notNPCstate_proj
    JMP doneShooting   
    
notNPCstate_proj:
  ;LDA weaponsUnlocked
  ;AND #%00000010
    ;BNE canShoot
    ;JMP doneShooting
  JMP checkPlrShotsFired
  
checkPlrShotsFired:
  ;;  Check if the player is at their limits for projectile on the screen
  LDA plrShotlim
  CMP #$00
    BNE canShoot
    JMP doneShooting 
    
canShoot:
  LDX player1_object
  GetCurrentActionType player1_object
  CMP #$05
    BNE notAlreadyShooting
    JMP doneShooting  
    
notAlreadyShooting:  
  ; Get only first 4 bits of the player's 'Object_movement' value and save back to player object
  LDA Object_movement,x
  AND #%00001111
  STA Object_movement,x
  
  ; Get upper left corner of the player object
  LDA Object_x_hi,x
  STA temp
  LDA Object_y_hi,x
  STA temp1
  
  JMP chooseProjDir
  

;;Check if player is aiming up, if so set direction to up. Else check left or right
;  LDA Object_action_step,x
;  AND #%00000111
;  CMP #$04
;  BEQ setPlrAimup
;  JMP chooseProjDir

;setPlrAimup:
;  LDA #%00000100
;  STA temp2
;  JMP setUPOffsetProjectile
  
chooseProjDir:
  ; Get only first 3 bits of the player's 'Object_movement' value and save to temp2
  LDA Object_movement,x
  AND #%00000111
  STA temp2
    
  ;; Choose the offset to change based on facing direction
  ;; You can comment out any you do not need
  CMP #%00000110
    BEQ facingLeft
  CMP #%00000010
    BEQ facingRight
  ;CMP #%00000100
    ;BEQ setUPOffsetProjectile
  ;CMP #%00000000
    ;BEQ setDOWNOffsetProjectile
  JMP doneShooting

facingLeft:
  LDA Object_action_step,x
  AND #%00000111
  CMP #$04
  BEQ setLEFTUPOffsetProjectile
  JMP setLEFTOffsetProjectile
  
facingRight:
  LDA Object_action_step,x
  AND #%00000111
  CMP #$04
  BEQ setRIGHTUPOffsetProjectile
  JMP setRIGHTOffsetProjectile
  
setLEFTOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    SBC #$04    ;;<<-- horizontal offset of your weapon when your player facing left (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    ADC #$07    ;;<<-- vertical offset of your weapon  when your player facing left(change the value to adjust from #$00 to #$0F or more)
    STA temp1
    JMP checkIfPlayerDuck
    
setRIGHTOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$1B    ;;<<-- horizontal offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    ADC #$07    ;;<<-- vertical offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp1
    JMP checkIfPlayerDuck
    
setLEFTUPOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$07    ;;<<-- horizontal offset of your weapon when your player facing left (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    SBC #$01    ;;<<-- vertical offset of your weapon  when your player facing left(change the value to adjust from #$00 to #$0F or more)
    STA temp1
    LDA #%00000100
    STA temp2
    JMP checkIfPlayerDuck
    
setRIGHTUPOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$12    ;;<<-- horizontal offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    SBC #$01    ;;<<-- vertical offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp1
    LDA #%00000100
    STA temp2
    JMP checkIfPlayerDuck

;setUPOffsetProjectile:
;    ;; If player is pressing up, act like they are facing up and set direction of bullet to up
;    LDA #$100
;    STA temp2
;    LDA Object_x_hi,x
;    CLC
;    ADC #$14    ;;<<-- horizontal offset of your weapon when your player facing up (change the value to adjust from #$00 to #$0F or more)
;    STA temp
;    LDA Object_y_hi,x
;    CLC
;    SBC #$0D    ;;<<-- vertical offset of your weapon when your player facing up (change the value to adjust) from #$00 to #$0F or more
;    STA temp1
;    JMP checkIfPlayerDuck

;setDOWNOffsetProjectile:
;    LDA Object_x_hi,x
;    CLC
;    ADC #$04    ;;<<-- horizontal offset of your weapon when your player facing down (change the value to adjust from #$00 to #$0F or more)
;    STA temp
;    LDA Object_y_hi,x
;    CLC
;    ADC #$0D    ;;<<-- vertical offset of your weapon when your player facing down (change the value to adjust from #$00 to #$0F or more)
;    STA temp1
;    JMP checkIfPlayerDuck
    
checkIfPlayerDuck:
  LDA gamepad
  AND #%11110000
  CMP #%00100000 ;;check if down is pressed
    BEQ setDuckOffset
   JMP createProjectile
    
setDuckOffset:
  LDA Object_y_hi,x
  CLC
  ADC #$10    ;;<<-- vertical offset of your weapon when your player facing up (change the value to adjust) from #$00 to #$0F or more
  STA temp1
  JMP createProjectile

createProjectile:
    LDA Object_action_step,x
    AND #%00000111
    CMP #$04
    BEQ createProjWOAnim
    CMP #$03
    BEQ createProjWOAnim
    LDA gamepad
    AND #%10000000 ; If Left is pressed
    CMP #%10000000
    BEQ createProjWOAnim
    LDA gamepad
    AND #%01000000 ; If Right is pressed
    CMP #%01000000
    BEQ createProjWOAnim
    JMP createProjNormal
    
createProjNormal:
    ChangeObjectState #$05, #$02 ;Change to 'shooting' state if you have one
createProjWOAnim:
    LDA Object_action_step,x ;Grab the action step before we lose it
    AND #%00000111
    CMP #$04
    BEQ createVShotMethod2
    JMP createHShot
    
createVShotMethod1:
    ;;This is how it SHOULD work, but for some reason the projectile just freezes in place.
    CreateObject temp, temp1, #$03, #$00
    LDA #%00000100
    STA temp2
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x  
    JMP addShotEffects
    
createVShotMethod2:
    ;;THIS WORKS BUT IS NOT IDEAL. THIS IS SKIPPED FOR TESTING
    ;;VERTICAL SHOT IS ACTION STEP 1 WITH GRAVITY
    CreateObject temp, temp1, #$03, #$01
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x     
    ;;Additional step of adding a vertical velocity to projectile
    LDA #$00
    SBC #$09
    STA Object_v_speed_hi,x
    JMP addShotEffects

createHShot:
    CreateObject temp, temp1, #$03, #$00
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x  
    JMP addShotEffects

addShotEffects:
    ;PlaySound #sfx_shoot ;play sound effect for shooting

    ;Manage # of shots and Infinite-Wall-Fire exploit
    LDA plrShotlim
    CMP #$02
    BCS resetShots
    JMP decrShots
    
resetShots:
    LDA #$02
    STA plrShotlim
    JMP decrShots
    
decrShots:
    DEC plrShotlim ; Decrement the shots on screen count
 
doneShooting:
  RTS

;; Values for directions:
;000 down
;010 right
;100 up
;110 left

It will probably n
 
chronicleroflegends said:
Hey, if it helps you go in the right direction, here is my current platform shooting script:
Note: This is a work in progress. I don't like how firing straight up is handled. You will also need to tweak it to your own game and sprites.
This will let you fire left, right, up, and crouched left and right.

You will also need to add a user variable plrShotlim and update it in the collision scripts when a projectile hits a monster and when it hits a solid/edge.

Code:
createWeaponProjectile:
  LDA gameHandler
  AND #%00100000
    BEQ notNPCstate_proj
    JMP doneShooting   
    
notNPCstate_proj:
  ;LDA weaponsUnlocked
  ;AND #%00000010
    ;BNE canShoot
    ;JMP doneShooting
  JMP checkPlrShotsFired
  
checkPlrShotsFired:
  ;;  Check if the player is at their limits for projectile on the screen
  LDA plrShotlim
  CMP #$00
    BNE canShoot
    JMP doneShooting 
    
canShoot:
  LDX player1_object
  GetCurrentActionType player1_object
  CMP #$05
    BNE notAlreadyShooting
    JMP doneShooting  
    
notAlreadyShooting:  
  ; Get only first 4 bits of the player's 'Object_movement' value and save back to player object
  LDA Object_movement,x
  AND #%00001111
  STA Object_movement,x
  
  ; Get upper left corner of the player object
  LDA Object_x_hi,x
  STA temp
  LDA Object_y_hi,x
  STA temp1
  
  JMP chooseProjDir
  

;;Check if player is aiming up, if so set direction to up. Else check left or right
;  LDA Object_action_step,x
;  AND #%00000111
;  CMP #$04
;  BEQ setPlrAimup
;  JMP chooseProjDir

;setPlrAimup:
;  LDA #%00000100
;  STA temp2
;  JMP setUPOffsetProjectile
  
chooseProjDir:
  ; Get only first 3 bits of the player's 'Object_movement' value and save to temp2
  LDA Object_movement,x
  AND #%00000111
  STA temp2
    
  ;; Choose the offset to change based on facing direction
  ;; You can comment out any you do not need
  CMP #%00000110
    BEQ facingLeft
  CMP #%00000010
    BEQ facingRight
  ;CMP #%00000100
    ;BEQ setUPOffsetProjectile
  ;CMP #%00000000
    ;BEQ setDOWNOffsetProjectile
  JMP doneShooting

facingLeft:
  LDA Object_action_step,x
  AND #%00000111
  CMP #$04
  BEQ setLEFTUPOffsetProjectile
  JMP setLEFTOffsetProjectile
  
facingRight:
  LDA Object_action_step,x
  AND #%00000111
  CMP #$04
  BEQ setRIGHTUPOffsetProjectile
  JMP setRIGHTOffsetProjectile
  
setLEFTOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    SBC #$04    ;;<<-- horizontal offset of your weapon when your player facing left (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    ADC #$07    ;;<<-- vertical offset of your weapon  when your player facing left(change the value to adjust from #$00 to #$0F or more)
    STA temp1
    JMP checkIfPlayerDuck
    
setRIGHTOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$1B    ;;<<-- horizontal offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    ADC #$07    ;;<<-- vertical offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp1
    JMP checkIfPlayerDuck
    
setLEFTUPOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$07    ;;<<-- horizontal offset of your weapon when your player facing left (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    SBC #$01    ;;<<-- vertical offset of your weapon  when your player facing left(change the value to adjust from #$00 to #$0F or more)
    STA temp1
    LDA #%00000100
    STA temp2
    JMP checkIfPlayerDuck
    
setRIGHTUPOffsetProjectile:
    LDA Object_x_hi,x
    CLC
    ADC #$12    ;;<<-- horizontal offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp
    LDA Object_y_hi,x
    CLC
    SBC #$01    ;;<<-- vertical offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
    STA temp1
    LDA #%00000100
    STA temp2
    JMP checkIfPlayerDuck

;setUPOffsetProjectile:
;    ;; If player is pressing up, act like they are facing up and set direction of bullet to up
;    LDA #$100
;    STA temp2
;    LDA Object_x_hi,x
;    CLC
;    ADC #$14    ;;<<-- horizontal offset of your weapon when your player facing up (change the value to adjust from #$00 to #$0F or more)
;    STA temp
;    LDA Object_y_hi,x
;    CLC
;    SBC #$0D    ;;<<-- vertical offset of your weapon when your player facing up (change the value to adjust) from #$00 to #$0F or more
;    STA temp1
;    JMP checkIfPlayerDuck

;setDOWNOffsetProjectile:
;    LDA Object_x_hi,x
;    CLC
;    ADC #$04    ;;<<-- horizontal offset of your weapon when your player facing down (change the value to adjust from #$00 to #$0F or more)
;    STA temp
;    LDA Object_y_hi,x
;    CLC
;    ADC #$0D    ;;<<-- vertical offset of your weapon when your player facing down (change the value to adjust from #$00 to #$0F or more)
;    STA temp1
;    JMP checkIfPlayerDuck
    
checkIfPlayerDuck:
  LDA gamepad
  AND #%11110000
  CMP #%00100000 ;;check if down is pressed
    BEQ setDuckOffset
   JMP createProjectile
    
setDuckOffset:
  LDA Object_y_hi,x
  CLC
  ADC #$10    ;;<<-- vertical offset of your weapon when your player facing up (change the value to adjust) from #$00 to #$0F or more
  STA temp1
  JMP createProjectile

createProjectile:
    LDA Object_action_step,x
    AND #%00000111
    CMP #$04
    BEQ createProjWOAnim
    CMP #$03
    BEQ createProjWOAnim
    LDA gamepad
    AND #%10000000 ; If Left is pressed
    CMP #%10000000
    BEQ createProjWOAnim
    LDA gamepad
    AND #%01000000 ; If Right is pressed
    CMP #%01000000
    BEQ createProjWOAnim
    JMP createProjNormal
    
createProjNormal:
    ChangeObjectState #$05, #$02 ;Change to 'shooting' state if you have one
createProjWOAnim:
    LDA Object_action_step,x ;Grab the action step before we lose it
    AND #%00000111
    CMP #$04
    BEQ createVShotMethod2
    JMP createHShot
    
createVShotMethod1:
    ;;This is how it SHOULD work, but for some reason the projectile just freezes in place.
    CreateObject temp, temp1, #$03, #$00
    LDA #%00000100
    STA temp2
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x  
    JMP addShotEffects
    
createVShotMethod2:
    ;;THIS WORKS BUT IS NOT IDEAL. THIS IS SKIPPED FOR TESTING
    ;;VERTICAL SHOT IS ACTION STEP 1 WITH GRAVITY
    CreateObject temp, temp1, #$03, #$01
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x     
    ;;Additional step of adding a vertical velocity to projectile
    LDA #$00
    SBC #$09
    STA Object_v_speed_hi,x
    JMP addShotEffects

createHShot:
    CreateObject temp, temp1, #$03, #$00
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x  
    JMP addShotEffects

addShotEffects:
    ;PlaySound #sfx_shoot ;play sound effect for shooting

    ;Manage # of shots and Infinite-Wall-Fire exploit
    LDA plrShotlim
    CMP #$02
    BCS resetShots
    JMP decrShots
    
resetShots:
    LDA #$02
    STA plrShotlim
    JMP decrShots
    
decrShots:
    DEC plrShotlim ; Decrement the shots on screen count
 
doneShooting:
  RTS

;; Values for directions:
;000 down
;010 right
;100 up
;110 left

It will probably n
so where to put this line of code in? so I can make a copy of it and add it in my custom scripts folder for my projects
 
The code I provided here you would use the input editor and assign it to your fire button.

For the other scripts, to limit the number of player shots to 2 (which you want to do if you don't want the game to lag) check this thread:
http://nesmakers.com/viewtopic.php?f=3&t=598&hilit=limit+projecitle

Basically you need to make a user variable that tracks the # of shots in your project settings, then make sure it Increments when the bullet collides with anything.

Also:
Whatever your projectile object is, you will need to give it a horizontal action state 0 that ignores gravity and a vertical action state 1 that doesn't ignore gravity.
(I am hoping to fix that in the next version of NESMaker. There is an engine bug I had to work around.)

Other than that, you will have to tweak the code to your game:
Change the gameobject to point to your projectile game object if it is not the default one
Change the line that updates the players state to point to your players 'shooting' state. If you do not have one just delete the line.
Change the projectile offsets to fit your own sprite.
 
Top Bottom