diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-05-15 17:00:43 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-05-15 17:00:43 +0200 |
| commit | 33147295f3f4d469fa9ae28aa1d971b9bd58c930 (patch) | |
| tree | a570bc3a14c906af798e4dfa25900c798ec361a7 | |
| parent | 6be9892eeb55835e338096e482fd5e5926985413 (diff) | |
| download | jetpac.nes-33147295f3f4d469fa9ae28aa1d971b9bd58c930.tar.gz jetpac.nes-33147295f3f4d469fa9ae28aa1d971b9bd58c930.zip | |
bullet: Do not clash with the pool
One of the glitches as hinted by commit ae857d302cd6 ("Implement the
base for moving bullets") actually came from the fact that the temporary
screen coordinates were pointing at the first sprite from the pool of
bullets. This commit moves these variables into a memory region where
there won't be any clashes.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
| -rw-r--r-- | src/bullets.s | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/bullets.s b/src/bullets.s index 736a226..db8bfd7 100644 --- a/src/bullets.s +++ b/src/bullets.s @@ -6,6 +6,9 @@ ;; Maximum amount of bullets allowed on screen at the same time. BULLETS_POOL_CAPACITY = 10 + ;; The capacity of the bullets pool in bytes. + BULLETS_POOL_CAPACITY_BYTES = BULLETS_POOL_CAPACITY * 3 + ;; Base address for the pool of bullets used on this game. The pool has ;; #BULLETS_POOL_CAPACITY bullet objects where each one is 3 bytes long: ;; 1. State: which can have two formats: @@ -17,15 +20,6 @@ ;; 3. X coordinate. zp_bullets_pool_base = $A0 - ;; The screen coordinates of the bullet being inspected right now. Used when - ;; computing the move of bullets and checking possible collisions with - ;; background/enemies. - zp_current_bullet_y = $A1 - zp_current_bullet_x = $A2 - - ;; The capacity of the bullets pool in bytes. - BULLETS_POOL_CAPACITY_BYTES = BULLETS_POOL_CAPACITY * 3 - ;; The current amount of bullets on screen. zp_bullets_pool_size = $E0 @@ -34,6 +28,12 @@ ;; time, as consecutive allocation is a very common case. zp_last_allocated_index = $E1 + ;; The screen coordinates of the bullet being inspected right now. Used when + ;; computing the move of bullets and checking possible collisions with + ;; background/enemies. + zp_current_bullet_y = $E2 + zp_current_bullet_x = $E3 + ;; The amount of time we are not allowing B presses. This is a rather low ;; value so you can have quite some presses per frame. zp_bullet_timer = $35 |
