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