Note: Yes, I realize this is really terrible code
I tried to get the enemies set up in Raven, but for some reason they just sit there. The data structure looks like:
Code:
And the code is:
Code:
![Sad](images/smiles/icon_sad.gif)
I tried to get the enemies set up in Raven, but for some reason they just sit there. The data structure looks like:
Code:
EnemyArray:
.fill (3*6)*3,0 ; | X acceleration{3 bits}, Y acceleration{3 bits}, health{2 bits} | Y pos | X pos | etc
Code:
UpdateDrawEnemies:
ld hl,EnemyArray
UDEnemiesLoop:
comparehl(EnemyArray+51)
ret z
ld a,(hl)
and %00000011
jr z,UDEnemiesSkip
ld b,3
call iRandom
dec a
ld b,a
ld a,(hl)
and %11100000
srl a \ srl a \ srl a \ srl a \ srl a ;%11100000 into %00000111
sub 3
add a,b
push af
push hl
inc hl \ inc hl ;Points to the X position
ld b,a
ld a,(hl)
add a,b
cp maxX
jr c,$+3 ;If the new X value is over the allowed amount (or less than 0) don't save X
ld (hl),a
pop hl
pop af
add a,3
sll a \ sll a \ sll a \ sll a \ sll a ;%00000111 into %11100000
ld b,a
push bc
ld b,3
call iRandom
dec a
ld b,a
ld a,(hl)
and %00011100
srl a \ srl a ;%00011100 into %00000111
sub 3
add a,b
push af
push hl
inc hl ;hl points to the Y position
ld b,a
ld a,(hl)
add a,b
cp maxY - 8
jr c,$+3 ;If the new Y value is over the allowed amount (or less than 0) don't save Y
ld (hl),a
pop hl
pop af
add a,3
sll a \ sll a ;%00000111 into %00011100
pop bc
or b
ld b,a
ld a,(hl)
and %00000011
or b
ld (hl),a
;call CheckColllision
inc hl
ld a,(hl)
ld e,a
inc hl
ld a,(hl)
inc hl
push hl
ld l,e
ld b,7
ld ix,EnemySprite
call iPutSprite
pop hl
jr UDEnemiesLoop
UDEnemiesSkip:
inc hl
inc hl
inc hl
jp UDEnemiesLoop