junglejourney
changeset 39:84da455d1eb9
Added support for more animation frames in the enemy characters.
Added subtile movement for enemies.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Aug 21 15:46:59 2011 +0200 |
| parents | da4544440ac5 |
| children | 3946b61beb36 |
| files | build.py makesprites.py mapcode.oph |
| diffstat | 3 files changed, 96 insertions(+), 55 deletions(-) [+] |
line diff
1.1 --- a/build.py Sun Aug 21 15:46:07 2011 +0200 1.2 +++ b/build.py Sun Aug 21 15:46:59 2011 +0200 1.3 @@ -54,8 +54,8 @@ 1.4 # 4 and higher enemy - bits 3,4,5 are enemy type) 1.5 # n+1 counter/direction (player: bits 1,2 are direction, 1.6 # bit 0 is animation 1.7 - # enemy: bits 2,3 are direction, 1.8 - # bits 0,1 are animation with bit 0 a delay bit) 1.9 + # enemy: bits 3,4 are direction, 1.10 + # bits 1,2 are animation, bit 0 is a delay bit) 1.11 # (emerging, explosion: bits 4,5,6 are enemy type for emerging, 1.12 # bit 3 is type 0=emerge,1=explode, 1.13 # bits 0,1,2 are animation with bit 0 a delay bit)
2.1 --- a/makesprites.py Sun Aug 21 15:46:07 2011 +0200 2.2 +++ b/makesprites.py Sun Aug 21 15:46:59 2011 +0200 2.3 @@ -82,53 +82,53 @@ 2.4 read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.5 read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.6 2.7 - read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.8 - read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.9 - read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.10 - read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.11 read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.12 read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.13 + read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.14 + read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.15 read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.16 read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.17 + read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.18 + read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.19 2.20 - read_xpm("images/wasplu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.21 - read_xpm("images/wasplu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.22 - read_xpm("images/waspru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.23 - read_xpm("images/waspru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.24 read_xpm("images/waspld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.25 read_xpm("images/waspld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.26 + read_xpm("images/waspld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.27 + read_xpm("images/waspld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.28 read_xpm("images/wasprd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.29 read_xpm("images/wasprd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.30 + read_xpm("images/wasprd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.31 + read_xpm("images/wasprd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.32 2.33 # placeholder enemy sprites 2.34 - read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.35 - read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.36 - read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.37 - read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.38 - read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.39 - read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.40 - read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.41 - read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "3"), ("@", "3")]), 2.42 + read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.43 + read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.44 + read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.45 + read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.46 + read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.47 + read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.48 + read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.49 + read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.50 2.51 # placeholder enemy sprites 2.52 - read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.53 - read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.54 - read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.55 - read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.56 read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.57 read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.58 + read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.59 + read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.60 read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.61 read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.62 + read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.63 + read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.64 2.65 # placeholder enemy sprites 2.66 - read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.67 - read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.68 - read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.69 - read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.70 read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.71 read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.72 + read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.73 + read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.74 read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.75 read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.76 + read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.77 + read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 2.78 2.79 # placeholder enemy appear 2.80 read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
3.1 --- a/mapcode.oph Sun Aug 21 15:46:07 2011 +0200 3.2 +++ b/mapcode.oph Sun Aug 21 15:46:59 2011 +0200 3.3 @@ -1209,6 +1209,7 @@ 3.4 3.5 lda $80 ; remove the least significant bit, used to delay 3.6 lsr ; the animation 3.7 + and #7 ; remove the top direction bit 3.8 clc 3.9 tax 3.10 lda enemy_direction_chars_low,x 3.11 @@ -1887,9 +1888,14 @@ 3.12 3.13 ldy #1 3.14 lda ($74),y 3.15 - and #2 3.16 - eor #2 ; toggle animation flag 3.17 - sta ($74),y ; left (directional bits are 0) 3.18 + sta $81 3.19 + adc #1 3.20 + and #$07 ; keep animation bits 3.21 + sta $8f 3.22 + lda $81 3.23 + and #$10 ; keep vertical direction bit 3.24 + ora $8f 3.25 + sta ($74),y ; left (horizontal directional bit is 0) 3.26 3.27 jsr plot_character 3.28 rts 3.29 @@ -1971,9 +1977,14 @@ 3.30 3.31 ldy #1 3.32 lda ($74),y 3.33 - and #2 ; remove direction information (result is 0) 3.34 - eor #2 ; toggle animation flag 3.35 - ora #4 ; right 3.36 + sta $81 3.37 + adc #1 3.38 + and #$07 ; keep animation bits 3.39 + sta $8f 3.40 + lda $81 3.41 + and #$10 ; keep vertical direction bit 3.42 + ora $8f 3.43 + ora #8 ; right 3.44 sta ($74),y 3.45 3.46 jsr plot_character 3.47 @@ -2068,9 +2079,13 @@ 3.48 3.49 ldy #1 3.50 lda ($74),y 3.51 - and #2 ; remove direction information (result is 0) 3.52 - eor #2 ; toggle animation flag 3.53 - ora #8 ; up 3.54 + sta $81 3.55 + adc #1 3.56 + and #$07 ; keep animation bits 3.57 + sta $8f 3.58 + lda $81 3.59 + and #$08 ; keep horizontal direction bit 3.60 + ora $8f 3.61 sta ($74),y 3.62 3.63 jsr plot_character 3.64 @@ -2152,9 +2167,14 @@ 3.65 3.66 ldy #1 3.67 lda ($74),y 3.68 - and #2 ; remove direction information (result is 0) 3.69 - eor #2 ; toggle animation flag 3.70 - ora #12 ; down 3.71 + sta $81 3.72 + adc #1 3.73 + and #$07 ; keep animation bits 3.74 + sta $8f 3.75 + lda $81 3.76 + and #$08 ; keep horizontal direction bit 3.77 + ora $8f 3.78 + ora #$10 ; down 3.79 sta ($74),y 3.80 3.81 jsr plot_character 3.82 @@ -2248,8 +2268,13 @@ 3.83 jsr unplot_character 3.84 ldy #1 3.85 lda ($74),y ; direction/animation 3.86 - and #$fe ; mask off the delay bit 3.87 - eor #2 3.88 + sta $81 3.89 + adc #1 3.90 + and #$07 ; keep animation bits 3.91 + sta $8f 3.92 + lda $81 3.93 + and #$18 ; mask off the animation bits 3.94 + ora $8f 3.95 sta ($74),y 3.96 jmp plot_character ; optimise away the rts 3.97 3.98 @@ -2270,40 +2295,54 @@ 3.99 ldy #2 3.100 lda ($74),y ; y 3.101 cmp $3302 ; player y 3.102 + bmi move_enemy_downwards 3.103 + bne move_enemy_upwards 3.104 + 3.105 + ldy #3 3.106 + lda ($74),y ; dy 3.107 + cmp #1 3.108 beq move_enemy_horizontally 3.109 bpl move_enemy_upwards 3.110 3.111 - ; Move the enemy downwards. 3.112 - lda #12 3.113 - jmp move_enemy_with_direction 3.114 + move_enemy_downwards: 3.115 + lda #$10 3.116 + jmp move_enemy_vertically_with_direction 3.117 3.118 move_enemy_upwards: 3.119 - lda #8 3.120 - jmp move_enemy_with_direction 3.121 + lda #$00 3.122 + jmp move_enemy_vertically_with_direction 3.123 3.124 move_enemy_horizontally: 3.125 ldy #4 3.126 lda ($74),y ; x 3.127 cmp $3304 ; player x 3.128 + bmi move_enemy_rightwards 3.129 + bne move_enemy_leftwards 3.130 + 3.131 + ldy #5 3.132 + lda ($74),y ; dx 3.133 + cmp #0 3.134 beq move_enemy_toggle 3.135 bpl move_enemy_leftwards 3.136 3.137 - ; Move the enemy to the right. 3.138 - lda #4 3.139 - jmp move_enemy_with_direction 3.140 + move_enemy_rightwards: 3.141 + lda #$08 3.142 + jmp move_enemy_horizontally_with_direction 3.143 3.144 move_enemy_leftwards: 3.145 - lda #0 3.146 - jmp move_enemy_with_direction 3.147 + lda #$00 3.148 + jmp move_enemy_horizontally_with_direction 3.149 3.150 move_enemy_with_inbuilt_direction: 3.151 3.152 ldy #1 ; direction/animation 3.153 lda ($74),y 3.154 - and #$0c 3.155 + and #$18 3.156 3.157 move_enemy_with_direction: 3.158 3.159 + move_enemy_horizontally_with_direction: 3.160 + 3.161 cmp #0 3.162 bne move_enemy_not_left 3.163 jsr move_enemy_left 3.164 @@ -2311,21 +2350,23 @@ 3.165 bcc move_enemy_exit 3.166 3.167 move_enemy_not_left: 3.168 - cmp #4 3.169 - bne move_enemy_not_right 3.170 + cmp #$08 3.171 + bne move_enemy_toggle 3.172 jsr move_enemy_right 3.173 bcs move_enemy_toggle 3.174 bcc move_enemy_exit 3.175 3.176 + move_enemy_vertically_with_direction: 3.177 + 3.178 move_enemy_not_right: 3.179 - cmp #8 3.180 + cmp #0 3.181 bne move_enemy_not_up 3.182 jsr move_enemy_up 3.183 bcs move_enemy_toggle 3.184 bcc move_enemy_exit 3.185 3.186 move_enemy_not_up: 3.187 - cmp #12 3.188 + cmp #$10 3.189 bne move_enemy_toggle 3.190 jsr move_enemy_down 3.191 bcs move_enemy_toggle
