A C64 Game - Step 52

posted in New Old Things
Published May 19, 2012
Advertisement

To make spawning enemies a bit more player friendly spawns are now shown before the enemy actually appears.



The way to implement this is quite simple. We've got a neat object system running already, so we make the spawn animation just another type.
Once the spawn life time is up the object is replaced in spot with the proper object type.

During a spawn point process we store the target type in SPRITE_ANNOYED (since spawns do not get annoyed):

          ;store spawn type in SPRITE_ANNOYED
          ldx PARAM7
          lda PARAM5
          sta SPRITE_ANNOYED,x

The spawns behaviour is straight forward, animate, count life time down and finally spawn the final object:


;------------------------------------------------------------
;Spawn
;------------------------------------------------------------
!zone BehaviourSpawn
BehaviourSpawn
          inc SPRITE_ANIM_DELAY,x
          lda SPRITE_ANIM_DELAY,x
          cmp #3beq .UpdateAnimation
          rts

.UpdateAnimation
          lda #0
          sta SPRITE_ANIM_DELAY,x

          lda SPRITE_POINTER_BASE,x
          eor #$01
          sta SPRITE_POINTER_BASE,x

          inc SPRITE_MOVE_POS,x
          lda SPRITE_MOVE_POS,x
          cmp #20beq .SpawnNow
          rts

.SpawnNow
          lda SPRITE_ANNOYED,x
          sta PARAM3
          lda SPRITE_CHAR_POS_X,x
          sta PARAM1
          lda SPRITE_CHAR_POS_Y,x
          sta PARAM2
          stx PARAM7
          lda #1
          jsr SpawnObject
          ldx PARAM7
          rts

The rest is too simple to show it here line by line, add new constants for the sprite, add the entry to the behaviour and hurt tables, add entries to the type start tables (color, sprite, etc.) and we're done.


And now the player is not killed by suddenly appearing enemies.

step52.zip

Previous Step Next Step

Previous Entry A C64 Game - Step 51
2 likes 3 comments

Comments

AlanSmithee
Looking good. I want to play this :)
May 19, 2012 11:17 AM
Endurion
Thanks :)

Well, you can play it. Just grab any C64 emulator (Vice, CCS64, Hox, Frodo) and drop the .prg file onto it (or open it via the emulators attach media feature).
May 19, 2012 05:57 PM
cgpIce
I like the idea of showing a spawn beforehand, I think this is one of those features that although small greatly improves "play-ability."
May 19, 2012 06:34 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement