[A83] Re: Mario Side-Scroller
[Prev][Next][Index][Thread]
[A83] Re: Mario Side-Scroller
Here's some code that checks what tile is at X,Y (you need to check 4
points to see if you can move an 8x8 sprite, 6 points for an 8x16 sprite)
GetXY:
;NOTE: This assumes you stored the map data vertically!
;Input e=y,hl=x
;Output a= tile at (x,y)
ld a,l
and %11111000
ld l,a
;add hl,hl ;only do this if your map is 16 high instead of 8
ld 0,d
add hl,de
ld de,map ;or whatever you named the map memory
add hl,de
ld a,(hl)
ret
When you're moving an 8x8 sprite, you need to check if an unwalkable terrain
is in that direction.
RIGHT:
####' <- check this (X+8,Y)
####
####
####. <- And this (X+8,Y+7)
LEFT:
Check this (x-1,y) -> '####
_ ####
_ ####
And this (x-1,y+7) -> .####
UP:
Check This: (x,y-1) -> . . <- And this (x+7,y-1)
_ ####
_ ####
_ ####
_ ####
DOWN:
_ ####
_ ####
_ ####
_ ####
Check This: (x,y+8) -> ' ' <- And this (x+7,y+8)
Those little diagrams tell you to check a couple points to determine if you
can go in that direction. If any of those points is a wall, then you can't
go in that direction. (to check which brick mario hit with his head, the
brick is at (x+4,y-1))
And now these same crappy diagrams for 8x16 sprites:
RIGHT:
####' <- check this (X+8,Y)
####
####
####
####' <- And this (X+8,Y+8)
####
####
####. <- And this (X+8,Y+15)
LEFT:
Check this (x-1,y) -> '####
_ ####
_ ####
_ ####
And this (x-1,y+8) -> '####
_ ####
_ ####
And this (x-1,y+15)-> .####
UP:
Check This: (x,y-1) -> . . <- And this (x+7,y-1)
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
DOWN:
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
_ ####
Check This: (x,y+16) -> ' ' <- And this (x+7,y+16)
Hope this stuff helped.
>From: Sk8a4good@aol.com
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: [A83] Re: Mario Side-Scroller
>Date: Sun, 27 May 2001 10:47:21 EDT
>
>
>OK, i used crashman's sprite routine and got that to work just fine. How
>do
>I check which tile the sprite is on if its coordinates are in ypos and
>xpos?
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com