PortableAnswers
New member
Hello, apologies if this question has been asked. I have not yet found what I am looking for. With the help of dale_coop, I was able to get my character to shoot the projectile in each direction from specified x and y coordinates. I am now hoping to have my player move while he is shooting. Below is my current code for the "a_create_projectile.asm" script.
Code:
createWeaponProjectile:
LDA gameHandler
AND #%00100000
BEQ notNPCstate_proj
JMP doneShooting
notNPCstate_proj
LDA weaponsUnlocked
AND #%00000010
BNE canShoot
JMP doneShooting
canShoot:
LDX player1_object
GetCurrentActionType player1_object
CMP #$02
BNE notAlreadyShooting
JMP doneShooting
notAlreadyShooting
;;; don't attack if already attacking.
;;; do we have to check for hurt here?
;;;;; Here, we WOULD create melee
ChangeObjectState #$02, #$02
LDA Object_movement,x
AND #%00001111
STA Object_movement,x
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
LDA Object_movement,x
AND #%00000111
STA temp2
CMP #%00000110
BEQ setLEFTOffsetProjectile
CMP #%00000010
BEQ setRIGHTOffsetProjectile
CMP #%00000100
BEQ setUPOffsetProjectile
CMP #%00000000
BEQ setDOWNOffsetProjectile
JMP doneShooting
setLEFTOffsetProjectile:
LDA Object_x_hi,x
CLC
SBC #$-13 ;;<<-- 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 #$11 ;;<<-- vertical offset of your weapon when your player facing left(change the value to adjust from #$00 to #$0F or more)
STA temp1
JMP continueCreatingProjectile
setRIGHTOffsetProjectile:
LDA Object_x_hi,x
CLC
ADC #$13 ;;<<-- L/R - 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 #$11 ;;<<-- U/D - vertical offset of your weapon when your player facing right (change the value to adjust from #$00 to #$0F or more)
STA temp1
JMP continueCreatingProjectile
setUPOffsetProjectile:
LDA Object_x_hi,x
CLC
ADC #$07 ;;<<-- 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 #$-00 ;;<<-- vertical offset of your weapon when your player facing up (change the value to adjust) from #$00 to #$0F or more
STA temp1
JMP continueCreatingProjectile
setDOWNOffsetProjectile:
LDA Object_x_hi,x
CLC
ADC #$07 ;;<<-- 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 #$16 ;;<<-- vertical offset of your weapon when your player facing down (change the value to adjust from #$00 to #$0F or more)
STA temp1
JMP continueCreatingProjectile
continueCreatingProjectile:
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
PlaySound #sfx_shoot
doneShooting:
RTS
;;000 down
;010 right
;100 up
;110 left