**RESOLVED** TY boardb My ammo counter on hud 4.5.9

TheRetroBro

Active member
Currently I have enemies set to drop ammo that increases my "super ammo" I got this to display on hud but i want my ammo to stack it seems to max out and if i pikcup another it doesnt add it just stays here is my code

gunPickup:
PlaySound #sfx_index_sfx_powerup
CMP #5
LDA #2
STA myAmmo
INC myAmmo
JMP endPickups1


;;Also i would prefer this max out at 5
 
Last edited:

baardbi

Well-known member
Currently I have enemies set to drop ammo that increases my "super ammo" I got this to display on hud but i want my ammo to stack it seems to max out and if i pikcup another it doesnt add it just stays here is my code

gunPickup:
PlaySound #sfx_index_sfx_powerup
CMP #5
LDA #2
STA myAmmo
INC myAmmo
JMP endPickups1


;;Also i would prefer this max out at 5

Try this:

gunPickup:
PlaySound #sfx_index_sfx_powerup

LDA myAmmo
CMP #5
BCS maxAmmo
INC myAmmo
JMP endPickups1
maxAmmo:
 

TheRetroBro

Active member
Try this:
You are the man with a plan! Works great i added LDA 2 so pickups give me a value of (2 shots)

here is my finished code :)

gunPickup:
PlaySound #sfx_index_sfx_powerup

LDA myAmmo
CMP #5
LDA #2
INC myAmmo
BCS maxAmmo
INC myAmmo
JMP endPickups1
maxAmmo:
 

TheRetroBro

Active member
I do have one additional question. How would.i go about making the ammo selectable. So instead of using the super ammo automatically maybe I can press select and switch over to standard shot to save suoer ammo for bosses? I am assuming I would need to change this in my shoot projectile script and maybe make a new variable "standard ammo" and create a input script for select.
 

baardbi

Well-known member
I do have one additional question. How would.i go about making the ammo selectable. So instead of using the super ammo automatically maybe I can press select and switch over to standard shot to save suoer ammo for bosses? I am assuming I would need to change this in my shoot projectile script and maybe make a new variable "standard ammo" and create a input script for select.
Hmm. There are several ways to do that sort of thing. You could do like in Castlevania and have a special weapon fire when you push up and B for example. Or you could do like you said and have some sort of select weapon thing. Thinking about it now, that might be the easiest.

You could create a new input script called changeWeapon.asm like this:

;;; Change weapon

LDA activeWeapon
CMP #2 ;; Super weapon object
BEQ loadFirstWeapon
LDA #2
STA activeWeapon
JMP doneWithWeaponChange

loadFirstWeapon:
LDA #1
STA activeWeapon

doneWithWeaponChange:

RTS
Assign it to the Select button.

Then you would need to have a shoot projectile input script like this:
;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.

LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
CMP #2 ;;; Super weapon
BEQ +shootSuper
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
;;; PlaySound #sfx_noAmmo ;;; Maybe play a sound if there's no ammo
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo

+shootNormal:


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

If you run out of super ammo then nothing happens if you press the shoot button. So maybe there could be a sound effect to indicate that there's no more ammo. If you press Select to go back to the normal weapon you can shoot normal projectiles.
 

TheRetroBro

Active member
Hmm. There are several ways to do that sort of thing. You could do like in Castlevania and have a special weapon fire when you push up and B for example. Or you could do like you said and have some sort of select weapon thing. Thinking about it now, that might be the easiest.

You could create a new input script called changeWeapon.asm like this:


Assign it to the Select button.

Then you would need to have a shoot projectile input script like this:


If you run out of super ammo then nothing happens if you press the shoot button. So maybe there could be a sound effect to indicate that there's no more ammo. If you press Select to go back to the normal weapon you can shoot normal projectiles.
I'll give this try I'm also going to "create object on screen" when select is pressed in my hud.
 

TheRetroBro

Active member
actually come to think of it, I dont want to cresate an object as it will take up too much memory and limit my monsters...hmm wondering if i can use the draw sprite macro?
 

TheRetroBro

Active member
Hmm. There are several ways to do that sort of thing. You could do like in Castlevania and have a special weapon fire when you push up and B for example. Or you could do like you said and have some sort of select weapon thing. Thinking about it now, that might be the easiest.

You could create a new input script called changeWeapon.asm like this:


Assign it to the Select button.

Then you would need to have a shoot projectile input script like this:


If you run out of super ammo then nothing happens if you press the shoot button. So maybe there could be a sound effect to indicate that there's no more ammo. If you press Select to go back to the normal weapon you can shoot normal projectiles.
HMMM So ive entered this code I do have a variable called "myAmmo" this is where super ammo is counted.

Nothing is happening. I cannot shoot normal or super. I can collect super ammo buti can neither select ammo or fire my standard.
 

TheRetroBro

Active member
OK so I got regular ammo to shoot but for some reason it wont switch to super: here are my codes

Weapon select:
;;; Change weapon
PlaySound #sfx_index_sfx_cursor
LDA activeWeapon
CMP #3 ;; Super weapon object
BEQ loadFirstWeapon
LDA #1
STA activeWeapon
JMP doneWithWeaponChange

loadFirstWeapon:
LDA #1
STA activeWeapon

doneWithWeaponChange:

RTS



Shoot projectile script:

HTML clipboard ;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.

LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
PlaySound #sfx_index_sfx_laser
CMP #3 ;;; Super weapon
BEQ +shootSuper
PlaySound #sfx_index_sfx_laser
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
PlaySound #sfx_index_sfx_damage
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo

+shootNormal:


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
 

baardbi

Well-known member
actually come to think of it, I dont want to cresate an object as it will take up too much memory and limit my monsters...hmm wondering if i can use the draw sprite macro?
You need to create an object either way, or else you wont be able to do object collisions. The sprite by itself does nothing like that. It needs to be an object.
 

baardbi

Well-known member
HMMM So ive entered this code I do have a variable called "myAmmo" this is where super ammo is counted.

Nothing is happening. I cannot shoot normal or super. I can collect super ammo buti can neither select ammo or fire my standard.
Sorry! I forgot to say that you need to create a user variable called activeWeapon. But I guess you figured that out.
 

baardbi

Well-known member
OK so I got regular ammo to shoot but for some reason it wont switch to super: here are my codes

Weapon select:
;;; Change weapon
PlaySound #sfx_index_sfx_cursor
LDA activeWeapon
CMP #3 ;; Super weapon object
BEQ loadFirstWeapon
LDA #1
STA activeWeapon
JMP doneWithWeaponChange

loadFirstWeapon:
LDA #1
STA activeWeapon

doneWithWeaponChange:

RTS



Shoot projectile script:

HTML clipboard ;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.

LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
PlaySound #sfx_index_sfx_laser
CMP #3 ;;; Super weapon
BEQ +shootSuper
PlaySound #sfx_index_sfx_laser
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
PlaySound #sfx_index_sfx_damage
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo

+shootNormal:


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

You need to change this (marked in yellow):

Weapon select:
;;; Change weapon
PlaySound #sfx_index_sfx_cursor
LDA activeWeapon
CMP #3 ;; Super weapon object
BEQ loadFirstWeapon
LDA #3
STA activeWeapon
JMP doneWithWeaponChange

loadFirstWeapon:
LDA #1
STA activeWeapon

doneWithWeaponChange:

RTS
 

baardbi

Well-known member
HMMM So ive entered this code I do have a variable called "myAmmo" this is where super ammo is counted.

Nothing is happening. I cannot shoot normal or super. I can collect super ammo buti can neither select ammo or fire my standard.
The myAmmo variable is subtracted right below +canShootSuperWeapon .
 

TheRetroBro

Active member
The myAmmo variable is subtracted right below +canShootSuperWeapon .
Ok so i got it working BUT. It seems that when I pickup my ammo for object 3 it is associating it with object 1

here is my code:

HTML clipboard ;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.

LDA activeWeapon
CMP #1 ;;; Normal weapon
BEQ +shootNormal
CMP #3 ;;; Super weapon
BEQ +shootSuper
JMP +canNotShoot
+shootSuper:
LDA myAmmo
BNE +canShootSuperWeapon
;;; PlaySound #sfx_noAmmo ;;; Maybe play a sound if there's no ammo
JMP +canNotShoot
+canShootSuperWeapon:
DEC myAmmo

+shootNormal:


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, #$01, #$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
 

TheRetroBro

Active member
also not sure if this helps but this is my pickup script:

gunPickup:
PlaySound #sfx_index_sfx_powerup

LDA myAmmo
CMP #3
LDA #3
INC myAmmo
BNE Not8Yet
LDA #3
BCS maxAmmo
INC myAmmo
JMP endPickups1
maxAmmo:
Not8Yet
JMP endPickups1
 

TheRetroBro

Active member
The myAmmo variable is subtracted right below +canShootSuperWeapon .
I GO IT!!!!! I was changing the this macro in the shoot projectile script and didnt need to!

CreateObjectOnScreen tempA, tempB, activeWeapon, #$00, tempD (thought i needed to change the "activeWeapon" to object 1 but thenr ealized this was calling on the "active weapon Object"

Dude THANK YOU!!!
 
Top Bottom