;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.
;;; assumes myAmmo is in hud element 8.
+checkShoot
LDA myAmmo ;; load the myAmmo variable into the accumulator. ;;
BNE canShoot ;; if there is ammo go to canShoot, if not go to next line. ;;
JMP canNotShoot ;; jump to subroutine canNotShoot, at the end of the script. ;;
canShoot: ;; this is what happens when you canShoot. ;;
;PlaySound #sfx_laser
;; the myAmmo stuff and updating it happens below here. ;;
DEC myAmmo ;; decrease/decrement the myAmmo variable. ;;
UpdateHudElement #$07 ;; change this to which element shows myAmmo. ;;
TXA
PHA
TYA
PHA
LDX player1_object ;; get player1_object load into x ;;
LDA Object_screen,x ;; load the data of player1_object ;;
STA tempD ;; store this location into tempD for later ;;
LDA Object_x_hi,x
CLC
ADC #$04
STA tempA
LDA Object_y_hi,x
CLC
ADC #$04
STA tempB
LDA Object_direction,x ;; Get the player's direction ;;
AND #%00000111
STA tempC ;; store it into tempC ;;
CreateObjectOnScreen tempA, tempB, #$02, #$00, tempD
;;; x, y, object, starting action. ;;;
;;; the x y from tempA and tempB are where the object will be made in correllation with the player. ;;;
;;; the next number here #$02 is the object number you're creating. ;;;
;;; the next number here #$00 is the object you're creating's action step. ;;;
;;; tempD is the screen. ;;;
;;; now with that object, retrieve the player's direction from previously and start it moving that way. ;;;
LDA tempC ;; the player's direction stored earlier ;;
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
canNotShoot: ;; this is what happens when you canNotShoot. ;;
RTS