• entries
104
102
• views
259239

# A C64 Game - Step 52

1732 views

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 #3
beq .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 #20
beq .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.

Looking good. I want to play this

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).

I like the idea of showing a spawn beforehand, I think this is one of those features that although small greatly improves "play-ability."

## Create an account

Register a new account