junglejourney
changeset 36:4dfd1a194717
Added a delay bit to the enemy objects to make them slower than
the player.
Alternate between horizontal and vertical movement to allow them
to attack diagonally.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Aug 21 04:13:36 2011 +0200 |
| parents | dfc945305302 |
| children | df35796af7ff |
| files | build.py mapcode.oph |
| diffstat | 2 files changed, 77 insertions(+), 34 deletions(-) [+] |
line diff
1.1 --- a/build.py Sun Aug 21 03:09:04 2011 +0200 1.2 +++ b/build.py Sun Aug 21 04:13:36 2011 +0200 1.3 @@ -52,10 +52,12 @@ 1.4 # 3300 character table (0x24/6 = 6 entries) 1.5 # n type (0 missing, 1 player, 2 projectile, 3 explosion, 1.6 # 4 and higher enemy - bits 3,4,5 are enemy type) 1.7 - # n+1 counter/direction (player/enemy: bits 1,2 are direction, 1.8 - # bit 0 is animation) 1.9 + # n+1 counter/direction (player: bits 1,2 are direction, 1.10 + # bit 0 is animation 1.11 + # enemy: bits 2,3 are direction, 1.12 + # bits 0,1 are animation with bit 0 a delay bit) 1.13 # (emerging, explosion: bits 4,5,6 are enemy type for emerging, 1.14 - # bit 3 is type 0=emerge,1=explode, 1.15 + # bit 3 is type 0=emerge,1=explode, 1.16 # bits 0,1,2 are animation with bit 0 a delay bit) 1.17 # n+2 y room offset (0-10) 1.18 # n+3 dy (0-5)
2.1 --- a/mapcode.oph Sun Aug 21 03:09:04 2011 +0200 2.2 +++ b/mapcode.oph Sun Aug 21 04:13:36 2011 +0200 2.3 @@ -1184,6 +1184,7 @@ 2.4 lda $80 ; remove the least significant bit, used to delay 2.5 lsr ; the animation 2.6 and #7 ; only keep the bits required to find the correct sprite 2.7 + clc 2.8 tax 2.9 lda emerge_explode_chars_low,x 2.10 sta $70 2.11 @@ -1206,7 +1207,10 @@ 2.12 clc 2.13 sta $71 ; 0x00, 0x02, 0x04, 0x06, 0x08 2.14 2.15 - ldx $80 2.16 + lda $80 ; remove the least significant bit, used to delay 2.17 + lsr ; the animation 2.18 + clc 2.19 + tax 2.20 lda enemy_direction_chars_low,x 2.21 sta $70 2.22 lda enemy_direction_chars_high,x 2.23 @@ -1883,8 +1887,8 @@ 2.24 2.25 ldy #1 2.26 lda ($74),y 2.27 - and #1 2.28 - eor #1 ; toggle animation flag 2.29 + and #2 2.30 + eor #2 ; toggle animation flag 2.31 sta ($74),y ; left (directional bits are 0) 2.32 2.33 jsr plot_character 2.34 @@ -1958,7 +1962,7 @@ 2.35 jmp animate_enemy_left ; optimise away the rts 2.36 2.37 move_enemy_left_exit: 2.38 - clc 2.39 + sec 2.40 rts 2.41 2.42 animate_enemy_right: ; $74,$75=character address 2.43 @@ -1967,9 +1971,9 @@ 2.44 2.45 ldy #1 2.46 lda ($74),y 2.47 - and #1 ; remove direction information (result is 0) 2.48 - eor #1 ; toggle animation flag 2.49 - ora #2 ; right 2.50 + and #2 ; remove direction information (result is 0) 2.51 + eor #2 ; toggle animation flag 2.52 + ora #4 ; right 2.53 sta ($74),y 2.54 2.55 jsr plot_character 2.56 @@ -2055,7 +2059,7 @@ 2.57 jmp animate_enemy_right ; optimise away the rts 2.58 2.59 move_enemy_right_exit: 2.60 - clc 2.61 + sec 2.62 rts 2.63 2.64 animate_enemy_up: ; $74,$75=character address 2.65 @@ -2064,9 +2068,9 @@ 2.66 2.67 ldy #1 2.68 lda ($74),y 2.69 - and #1 ; remove direction information (result is 0) 2.70 - eor #1 ; toggle animation flag 2.71 - ora #4 ; up 2.72 + and #2 ; remove direction information (result is 0) 2.73 + eor #2 ; toggle animation flag 2.74 + ora #8 ; up 2.75 sta ($74),y 2.76 2.77 jsr plot_character 2.78 @@ -2139,7 +2143,7 @@ 2.79 jmp animate_enemy_up ; optimise away the rts 2.80 2.81 move_enemy_up_exit: 2.82 - clc 2.83 + sec 2.84 rts 2.85 2.86 animate_enemy_down: ; $74,$75=character address 2.87 @@ -2148,9 +2152,9 @@ 2.88 2.89 ldy #1 2.90 lda ($74),y 2.91 - and #1 ; remove direction information (result is 0) 2.92 - eor #1 ; toggle animation flag 2.93 - ora #6 ; down 2.94 + and #2 ; remove direction information (result is 0) 2.95 + eor #2 ; toggle animation flag 2.96 + ora #12 ; down 2.97 sta ($74),y 2.98 2.99 jsr plot_character 2.100 @@ -2236,11 +2240,30 @@ 2.101 jmp animate_enemy_down ; optimise away the rts 2.102 2.103 move_enemy_down_exit: 2.104 - clc 2.105 + sec 2.106 rts 2.107 2.108 +move_enemy_animate: ; $74,$75=character address 2.109 + 2.110 + jsr unplot_character 2.111 + ldy #1 2.112 + lda ($74),y ; direction/animation 2.113 + and #$fe ; mask off the delay bit 2.114 + eor #2 2.115 + sta ($74),y 2.116 + jmp plot_character ; optimise away the rts 2.117 + 2.118 move_enemy: ; $74,$75=character address 2.119 2.120 + ldy #1 2.121 + lda ($74),y ; direction/animation 2.122 + and #1 2.123 + beq move_enemy_delay 2.124 + 2.125 + lda ($74),y ; direction/animation 2.126 + and #2 2.127 + bne move_enemy_horizontally 2.128 + 2.129 ;and #16 ; A contains the object type 2.130 ;beq move_enemy_with_inbuilt_direction 2.131 2.132 @@ -2251,54 +2274,72 @@ 2.133 bpl move_enemy_upwards 2.134 2.135 ; Move the enemy downwards. 2.136 - lda #4 2.137 + lda #12 2.138 jmp move_enemy_with_direction 2.139 2.140 move_enemy_upwards: 2.141 - lda #3 2.142 + lda #8 2.143 jmp move_enemy_with_direction 2.144 2.145 move_enemy_horizontally: 2.146 ldy #4 2.147 lda ($74),y ; x 2.148 cmp $3304 ; player x 2.149 - beq move_enemy_exit 2.150 + beq move_enemy_toggle 2.151 bpl move_enemy_leftwards 2.152 2.153 ; Move the enemy to the right. 2.154 - lda #2 2.155 + lda #4 2.156 jmp move_enemy_with_direction 2.157 2.158 move_enemy_leftwards: 2.159 - lda #1 2.160 + lda #0 2.161 jmp move_enemy_with_direction 2.162 2.163 move_enemy_with_inbuilt_direction: 2.164 2.165 ldy #1 ; direction/animation 2.166 lda ($74),y 2.167 - and #6 2.168 + and #$0c 2.169 2.170 move_enemy_with_direction: 2.171 2.172 - cmp #1 2.173 + cmp #0 2.174 bne move_enemy_not_left 2.175 - jmp move_enemy_left ; optimise away the rts 2.176 + jsr move_enemy_left 2.177 + bcs move_enemy_toggle 2.178 + bcc move_enemy_exit 2.179 2.180 move_enemy_not_left: 2.181 - cmp #2 2.182 + cmp #4 2.183 bne move_enemy_not_right 2.184 - jmp move_enemy_right ; optimise away the rts 2.185 + jsr move_enemy_right 2.186 + bcs move_enemy_toggle 2.187 + bcc move_enemy_exit 2.188 2.189 move_enemy_not_right: 2.190 - cmp #3 2.191 + cmp #8 2.192 bne move_enemy_not_up 2.193 - jmp move_enemy_up ; optimise away the rts 2.194 + jsr move_enemy_up 2.195 + bcs move_enemy_toggle 2.196 + bcc move_enemy_exit 2.197 2.198 move_enemy_not_up: 2.199 - cmp #4 2.200 - bne move_enemy_exit 2.201 - jmp move_enemy_down ; optimise away the rts 2.202 + cmp #12 2.203 + bne move_enemy_toggle 2.204 + jsr move_enemy_down 2.205 + bcs move_enemy_toggle 2.206 + bcc move_enemy_exit 2.207 + 2.208 + move_enemy_toggle: 2.209 + clc 2.210 + jmp move_enemy_animate 2.211 + 2.212 + move_enemy_delay: 2.213 + ldy #1 2.214 + lda ($74),y 2.215 + eor #1 2.216 + sta ($74),y 2.217 2.218 move_enemy_exit: 2.219 clc
