Skip to content

Commit

Permalink
Add a death animation and some basic drops
Browse files Browse the repository at this point in the history
  • Loading branch information
D0ntPanic committed Oct 14, 2015
1 parent 79d793e commit 393fb17
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 4 deletions.
Binary file added ERASE_PRG.bin
Binary file not shown.
8 changes: 6 additions & 2 deletions defines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ LOAD_TILES addr, var, .ident(.concat(.string(var), "_count"))
.define SPRITE_TILE_FAT_ZOMBIE $60
.define SPRITE_TILE_SHARK $80

.define SPRITE_TILE_SPLAT $e0
.define SPRITE_TILE_ORB $ee
.define SPRITE_TILE_BULLET $f2
.define SPRITE_TILE_BULLET_HIT $f4
.define SPRITE_TILE_BULLET_DAMAGE $f6
Expand All @@ -308,8 +310,10 @@ LOAD_TILES addr, var, .ident(.concat(.string(var), "_count"))

; Effects
.define EFFECT_PLAYER_BULLET 0
.define EFFECT_PLAYER_BULLET_DAMAGE 1
.define EFFECT_PLAYER_BULLET_HIT 2
.define EFFECT_DROP 1
.define EFFECT_ENEMY_DEATH 2
.define EFFECT_PLAYER_BULLET_DAMAGE 3
.define EFFECT_PLAYER_BULLET_HIT 4
.define EFFECT_NONE $ff

.define EFFECT_MAX_COUNT 16
Expand Down
18 changes: 18 additions & 0 deletions effect.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PROC init_effect_sprites
LOAD_ALL_TILES $100 + SPRITE_TILE_BULLET, bullet_tiles
LOAD_ALL_TILES $100 + SPRITE_TILE_SPLAT, splat_tiles
LOAD_ALL_TILES $100 + SPRITE_TILE_ORB, orb_tiles

ldx #0
lda #EFFECT_NONE
Expand Down Expand Up @@ -425,6 +427,10 @@ found:
sta effect_direction, x
lda #0
sta effect_time, x
lda arg4
sta effect_data_0, x
lda arg5
sta effect_data_1, x

lda arg2
asl
Expand Down Expand Up @@ -496,11 +502,23 @@ VAR effect_time
.byte 0
.endrepeat

VAR effect_data_0
.repeat EFFECT_MAX_COUNT
.byte 0
.endrepeat

VAR effect_data_1
.repeat EFFECT_MAX_COUNT
.byte 0
.endrepeat


.data

VAR effect_descriptors
.word player_bullet_descriptor
.word drop_descriptor
.word enemy_death_descriptor
.word player_bullet_damage_descriptor
.word player_bullet_hit_descriptor

Expand Down
191 changes: 191 additions & 0 deletions enemy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,173 @@ spawnloop:
.endproc


PROC enemy_die
lda #ITEM_NONE
ldx #0
jsr enemy_die_with_drop
rts
.endproc


PROC enemy_die_with_drop
sta arg4
stx arg5

ldx cur_enemy
lda enemy_x, x
sta arg0
lda enemy_y, x
sta arg1
lda #EFFECT_ENEMY_DEATH
sta arg2
lda #0
sta arg3

jsr create_effect
rts
.endproc


PROC enemy_die_with_drop_table
; Pick drop entry from table
ldy #0
lda (ptr), y
jsr rand_range
sta arg0

; Read drop type pointer
ldy #1
lda (ptr), y
sta temp
ldy #2
lda (ptr), y
sta temp + 1

; Look up drop type
ldy arg0
lda (temp), y
sta arg1

; Read count randomization field and pick a count
ldy #5
lda (ptr), y
sta temp
ldy #6
lda (ptr), y
sta temp + 1

ldy arg0
lda (temp), y
jsr rand_range
sta arg2

; Add in the minimum count
ldy #3
lda (ptr), y
sta temp
ldy #4
lda (ptr), y
sta temp + 1
ldy arg0
lda (temp), y
clc
adc arg2
tax

lda arg1
jsr enemy_die_with_drop
rts
.endproc


PROC enemy_death_tick
ldx cur_effect
inc effect_time, x
lda effect_time, x
cmp #8
beq secondframe
cmp #16
beq thirdframe
cmp #24
beq splatdone
rts

secondframe:
lda #SPRITE_TILE_SPLAT + 4
sta effect_tile, x
rts
thirdframe:
lda #SPRITE_TILE_SPLAT + 8
sta effect_tile, x
rts

splatdone:
; If there is no drop, remove effect now
ldx cur_effect
lda effect_data_0, x
cmp #ITEM_NONE
beq noitem
lda effect_data_1, x
bne hasitem

noitem:
jsr remove_effect
rts

hasitem:
lda #SPRITE_TILE_ORB
sta effect_tile, x
lda #0
sta effect_time, x
lda #EFFECT_DROP
sta effect_type, x
lda effect_x, x
clc
adc #4
sta effect_x, x
lda effect_y, x
clc
adc #4
sta effect_y, x
rts
.endproc


PROC drop_tick
ldx cur_effect
inc effect_time, x
lda effect_time, x
cmp #16
beq secondframe
cmp #32
bne done

lda #SPRITE_TILE_ORB
sta effect_tile, x
lda #0
sta effect_time, x
rts

secondframe:
lda #SPRITE_TILE_ORB + 2
sta effect_tile, x

done:
rts
.endproc


PROC drop_collide
ldy cur_effect
lda effect_data_1, y
tax
lda effect_data_0, y
jsr give_item_with_count
jsr remove_effect
rts
.endproc


.zeropage

VAR cur_enemy
Expand Down Expand Up @@ -1588,3 +1755,27 @@ VAR enemy_descriptors
.word normal_female_zombie_descriptor
.word shark_descriptor
.word fat_zombie_descriptor


VAR enemy_death_descriptor
.word enemy_death_tick
.word nothing
.word nothing
.word nothing
.byte SPRITE_TILE_SPLAT, 1
.byte 3
.byte 16, 16


VAR drop_descriptor
.word drop_tick
.word drop_collide
.word nothing
.word nothing
.byte SPRITE_TILE_ORB, 0
.byte 2
.byte 8, 8


TILES splat_tiles, 2, "tiles/effects/splat.chr", 12
TILES orb_tiles, 2, "tiles/items/orb.chr", 4
Binary file added tiles/effects/splat.chr
Binary file not shown.
Binary file modified tiles/items/orb.chr
Binary file not shown.
36 changes: 34 additions & 2 deletions zombie.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ PROC init_zombie_sprites
.endproc


PROC normal_zombie_die
LOAD_PTR normal_zombie_drop_table
jsr enemy_die_with_drop_table

jsr remove_enemy
rts
.endproc


PROC normal_zombie_collide
lda #8
jsr take_damage
Expand All @@ -32,7 +41,7 @@ PROC fat_zombie_explode

VAR normal_male_zombie_descriptor
.word walking_ai_tick
.word remove_enemy
.word normal_zombie_die
.word normal_zombie_collide
.word walking_sprites_for_state
.byte SPRITE_TILE_NORMAL_MALE_ZOMBIE
Expand All @@ -42,7 +51,7 @@ VAR normal_male_zombie_descriptor

VAR normal_female_zombie_descriptor
.word walking_ai_tick
.word remove_enemy
.word normal_zombie_die
.word normal_zombie_collide
.word walking_sprites_for_state
.byte SPRITE_TILE_NORMAL_FEMALE_ZOMBIE
Expand All @@ -63,6 +72,29 @@ VAR fat_zombie_descriptor
VAR zombie_palette
.byte $0f, $18, $28, $08

VAR normal_zombie_drop_table
.byte 4
.word normal_zombie_drop_type
.word normal_zombie_drop_base_count
.word normal_zombie_drop_rand_count
VAR normal_zombie_drop_type
.byte ITEM_NONE, ITEM_PISTOL, ITEM_PISTOL, ITEM_BANDAGE
VAR normal_zombie_drop_base_count
.byte 0, 2, 2, 1
VAR normal_zombie_drop_rand_count
.byte 1, 4, 4, 1
;VAR normal_zombie_drop_table
; .byte 6
; .word normal_zombie_drop_type
; .word normal_zombie_drop_base_count
; .word normal_zombie_drop_rand_count
;VAR normal_zombie_drop_type
; .byte ITEM_CLOTH, ITEM_SHIRT, ITEM_PANTS, ITEM_STICKS, ITEM_GUNPOWDER, ITEM_METAL
;VAR normal_zombie_drop_base_count
; .byte 2, 1, 1, 1, 1, 1, 1, 2, 2
;VAR normal_zombie_drop_rand_count
; .byte 3, 1, 1, 1, 2, 1, 1, 3, 3

TILES normal_male_zombie_tiles, 2, "tiles/enemies/zombie/zombie-male.chr", 32
TILES normal_female_zombie_tiles, 2, "tiles/enemies/zombie/zombie-female.chr", 32
TILES fat_zombie_tiles, 2, "tiles/enemies/zombie/zombie-fat.chr", 32

0 comments on commit 393fb17

Please sign in to comment.