-->
0 Members and 1 Guest are viewing this topic.
; store the sprites in a table in memory, because you have various spritessprites_position:; X Y .db 30,30 .db 10,30 .db 10,10 .db 30,10 .db 0,0; 5 sprites for now; routine to get X and Y; input: A is sprite number (0 to 5); output: b is X and c is Yget_x_y_sprite: ld h,0 ld l,a add hl,hl ld de,sprites_position add hl,de ;hl has spriteX ld b,(hl) ; b is X inc hl ; skip to SpriteY ld c,(hl) ; c is Y rettestSprite3: ld a,3 call get_x_y_sprite ld a,30 cp b jr z,spriteXis30 ld a,10 cp c jr z,spriteYis10
ld ix,sprites_position; get XposSprite2 into A ld a,(ix+2) cp 30 jr z,Sprite2XisTrue retSprite2XisTrue:; to get YposSprite2 into a ld A,(ix+3) cp 30 jr z,Sprite2isinX30Y30 retSprite2isinX30Y30:; do something when Sprite2 is in X=30 and Y=30