TheRetroBro
Active member
Looking to implement directional shooting in my next game. Preferably much like contra shooting up down and diagonal i cannot seem to find anything in the forums. Does anyone know of this being discussed?
I may point you into this one...Looking to implement directional shooting in my next game. Preferably much like contra shooting up down and diagonal i cannot seem to find anything in the forums. Does anyone know of this being discussed?
;;custom create projectile script - up/left/right/down
;;;Uses gameobject 02 as projectilesource, can be changed in the code below
;;; I set up different actionsteps for the projectile to be able to have different
;;; animations of the projectile for all the directions. If your projectile is a "ball"
;;; and looks the same in every direction. You only need one actionstep for the projectile.
;my proj setup
;actionstep0 - normal left/right projectile
;actionstep1 - proj going down
;actionstep2 - proj going up
;;;I wanted the player to have different animations shooting in different directions
;;;so the set up that worked on my player
;actionstep3 - normal left/right projectile
;actionstep5 - proj going down
;actionstep3 - proj going up
;;if you only want to use one shoting animation/actionstep for your player
;;you can set that up at line 39, early in the beguinning of the code and ;komma out; the
;;changing of the players actionsteps for the different directions at line 93, 150, 202
;;This limits projectiles on screen
CountObjects #%00000100 ;player weapons on screen
CMP #2 ; Max Number of player projectiles on screen
BNE yesCanShootProjectile
JMP +skipToENd
yesCanShootProjectile:
;;;Here you can change player into shooting actionstep, if it is one and the same for all directions
;;;Otherwise we set the different actionsteps for your player after the projectile been created later in the script
;;change player into shooting animation
;;ChangeActionStep #00, #$03
LDA gamepad
AND #%00100000 ; check down button
BNE +downPressed
JMP +skipButtonDown
+downPressed:
;down was pressed, do stuff here
;;create a projectile going down
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$01 ;#$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
;;i have GameObject2 beeing the projectile,
;;actionstep 01- projectile going down animation.
CreateObjectOnScreen tempA, tempB, #$02, #$01, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
;LDA DirectionTableOrdered,y
;STA temp1
TXA
STA temp
StartMoving temp, #DOWN ;temp1
PLA
TAY
PLA
TAX
;;Here i set up my player in a actionstep for animation shooting down
;;change player into shooting DOWN animation
ChangeActionStep #00, #$05
;;PlaySound #sfx_whip
JMP +skipToENd:
+skipButtonDown:
;;;;;;;;;;;;;;;;;;;shoot projectile up
LDA gamepad
AND #%00010000 ; check up button
BNE +upPressed
JMP +skipButtonUp
+upPressed:
;up was pressed, do stuff here
;;create a projectile going up
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$01 ;#$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
;;My Projectile is gameobject 2
;;its actonstep 2 has a projectile going up animation
CreateObjectOnScreen tempA, tempB, #$02, #$02, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
;LDA DirectionTableOrdered,y
;STA temp1
TXA
STA temp
StartMoving temp, #UP ;temp1
PLA
TAY
PLA
TAX
;;change player into shooting UP animation
ChangeActionStep #00, #$03
;;PlaySound #sfx_whip
JMP +skipToENd:
+skipButtonUp:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end of shoot proj up
;;No directional buttons where pressed lets just
;;create a "normal" projectile going Left/right
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$01 ;#$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
;;My Projectile is gameobject 2
;;its actonstep 0 has the normal projectile animation
CreateObjectOnScreen tempA, tempB, #$02, #$00, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
;;change player into shooting animation
ChangeActionStep #00, #$03
;;PlaySound #sfx_whip
+skipToENd:
RTS
Thaks for sharing I'll dig into this. My shoot projectile script has the option of shooting two different projectiles depending on what you select. When I get home Ill share my script as wellI recently created a shoot in 4 different directions inputscript depending on up/down beeing pressed
Sharing the code down below.
It does not have diagonal shooting. But perhaps you can modify it for more directions.
Its from my byteoff project, so i erased the doublejump function from it. So this should work just creating the projectile.
It might be better ways of doing this, but i had a lot of romspace and not so much time so this is how i solved the problem:
Code:;;custom create projectile script - up/left/right/down ;;;Uses gameobject 02 as projectilesource, can be changed in the code below ;;; I set up different actionsteps for the projectile to be able to have different ;;; animations of the projectile for all the directions. If your projectile is a "ball" ;;; and looks the same in every direction. You only need one actionstep for the projectile. ;my proj setup ;actionstep0 - normal left/right projectile ;actionstep1 - proj going down ;actionstep2 - proj going up ;;;I wanted the player to have different animations shooting in different directions ;;;so the set up that worked on my player ;actionstep3 - normal left/right projectile ;actionstep5 - proj going down ;actionstep3 - proj going up ;;if you only want to use one shoting animation/actionstep for your player ;;you can set that up at line 39, early in the beguinning of the code and ;komma out; the ;;changing of the players actionsteps for the different directions at line 93, 150, 202 ;;This limits projectiles on screen CountObjects #%00000100 ;player weapons on screen CMP #2 ; Max Number of player projectiles on screen BNE yesCanShootProjectile JMP +skipToENd yesCanShootProjectile: ;;;Here you can change player into shooting actionstep, if it is one and the same for all directions ;;;Otherwise we set the different actionsteps for your player after the projectile been created later in the script ;;change player into shooting animation ;;ChangeActionStep #00, #$03 LDA gamepad AND #%00100000 ; check down button BNE +downPressed JMP +skipButtonDown +downPressed: ;down was pressed, do stuff here ;;create a projectile going down TXA PHA TYA PHA LDX player1_object LDA Object_x_hi,x CLC ADC #$04 STA tempA LDA Object_screen,x ADC #$00 STA tempD LDA Object_y_hi,x CLC ADC #$01 ;#$04 STA tempB LDA Object_direction,x AND #%00000111 STA tempC ;;i have GameObject2 beeing the projectile, ;;actionstep 01- projectile going down animation. CreateObjectOnScreen tempA, tempB, #$02, #$01, tempD ;;; x, y, object, starting action. ;;; and now with that object, copy the player's ;;; direction and start it moving that way. LDA tempC STA Object_direction,x TAY ;LDA DirectionTableOrdered,y ;STA temp1 TXA STA temp StartMoving temp, #DOWN ;temp1 PLA TAY PLA TAX ;;Here i set up my player in a actionstep for animation shooting down ;;change player into shooting DOWN animation ChangeActionStep #00, #$05 ;;PlaySound #sfx_whip JMP +skipToENd: +skipButtonDown: ;;;;;;;;;;;;;;;;;;;shoot projectile up LDA gamepad AND #%00010000 ; check up button BNE +upPressed JMP +skipButtonUp +upPressed: ;up was pressed, do stuff here ;;create a projectile going up TXA PHA TYA PHA LDX player1_object LDA Object_x_hi,x CLC ADC #$04 STA tempA LDA Object_screen,x ADC #$00 STA tempD LDA Object_y_hi,x CLC ADC #$01 ;#$04 STA tempB LDA Object_direction,x AND #%00000111 STA tempC ;;My Projectile is gameobject 2 ;;its actonstep 2 has a projectile going up animation CreateObjectOnScreen tempA, tempB, #$02, #$02, tempD ;;; x, y, object, starting action. ;;; and now with that object, copy the player's ;;; direction and start it moving that way. LDA tempC STA Object_direction,x TAY ;LDA DirectionTableOrdered,y ;STA temp1 TXA STA temp StartMoving temp, #UP ;temp1 PLA TAY PLA TAX ;;change player into shooting UP animation ChangeActionStep #00, #$03 ;;PlaySound #sfx_whip JMP +skipToENd: +skipButtonUp: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end of shoot proj up ;;No directional buttons where pressed lets just ;;create a "normal" projectile going Left/right TXA PHA TYA PHA LDX player1_object LDA Object_x_hi,x CLC ADC #$04 STA tempA LDA Object_screen,x ADC #$00 STA tempD LDA Object_y_hi,x CLC ADC #$01 ;#$04 STA tempB LDA Object_direction,x AND #%00000111 STA tempC ;;My Projectile is gameobject 2 ;;its actonstep 0 has the normal projectile animation CreateObjectOnScreen tempA, tempB, #$02, #$00, tempD ;;; x, y, object, starting action. ;;; and now with that object, copy the player's ;;; direction and start it moving that way. LDA tempC STA Object_direction,x TAY LDA DirectionTableOrdered,y STA temp1 TXA STA temp StartMoving temp, temp1 PLA TAY PLA TAX ;;change player into shooting animation ChangeActionStep #00, #$03 ;;PlaySound #sfx_whip +skipToENd: RTS
;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.
PlaySound #sfx_index_sfx_shoot
LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
CMP #3 ;;; Super weapon
BEQ +shootSuper
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
PlaySound #sfx_index_sfx_noammo;;; Maybe play a sound if there's no ammo
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo
+shootNormal:
;;;;;;;;;;;;;;;;;;;shoot projectile up
LDA gamepad
AND #%00010000 ; check up button
BNE +upPressed
JMP +skipButtonUp
+upPressed:
;up was pressed, do stuff here
;;create a projectile going up
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$01 ;#$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
;;My Projectile is gameobject 2
;;its actonstep 2 has a projectile going up animation
CreateObjectOnScreen tempA, tempB, activeWeapon, #$02, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
;LDA DirectionTableOrdered,y
;STA temp1
TXA
STA temp
StartMoving temp, #UP ;temp1
PLA
TAY
PLA
TAX
;;change player into shooting UP animation
;ChangeActionStep #00, #$03
;;PlaySound #sfx_whip
JMP +skipToENd:
+skipButtonUp:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end of shoot proj up
;;No directional buttons where pressed lets just
;;create a "normal" projectile going Left/right
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
CreateObjectOnScreen tempA, tempB, activeWeapon, #$00, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
+canNotShoot:
RTS
+skipToENd:
+canNotShoot:
RTS
Have you checked this thread?I can not get projectiles to go up either.. Not sure why. ANy help would be appreciated. I just want a simple press b projectile goes up. no other directions needed. cant get it to work tho.
;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.
PlaySound #sfx_index_sfx_shoot
LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
CMP #3 ;;; Super weapon
BEQ +shootSuper
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
PlaySound #sfx_index_sfx_noammo;;; Maybe play a sound if there's no ammo
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo
+shootNormal:
;;;;;below code checks for down button
LDA gamepad
AND #%00100000 ; check down button
BNE +downPressed
JMP +skipButtonDown
+downPressed:
;down was pressed, do stuff here
;;create a projectile going down
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #16
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #16
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
CreateObjectOnScreen tempA, tempB, activeWeapon, #$00, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
ChangeActionStep #00, #$03
+canNotShoot:
RTS
;;Here i set up my player in a actionstep for animation shooting down
;;change player into shooting DOWN animation
;;ChangeActionStep #00, #$05
;;PlaySound #sfx_whip
JMP +skipToENd:
+skipButtonDown:
;;;;;;;;;;;;;;;;;;;shoot projectile up
LDA gamepad
AND #%00010000 ; check up button
BNE +upPressed
JMP +skipButtonUp
+upPressed:
;up was pressed, do stuff here
;;create a projectile going up
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$01 ;#$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
;;My Projectile is gameobject 2
;;its actonstep 2 has a projectile going up animation
CreateObjectOnScreen tempA, tempB, activeWeapon, #$02, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
;LDA DirectionTableOrdered,y
;STA temp1
TXA
STA temp
StartMoving temp, #UP ;temp1
PLA
TAY
PLA
TAX
;;change player into shooting UP animation
ChangeActionStep #00, #$06
;;PlaySound #sfx_whip
JMP +skipToENd:
+skipButtonUp:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end of shoot proj up
;;No directional buttons where pressed lets just
;;create a "normal" projectile going Left/right
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #$09
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x
CLC
ADC #$09
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
CreateObjectOnScreen tempA, tempB, activeWeapon, #$00, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
+canNotShoot:
RTS
+skipToENd:
+canNotShoot:
RTS