Re: A86: Tilemaps and Collision Detection


[Prev][Next][Index][Thread]

Re: A86: Tilemaps and Collision Detection




In a message dated 4/22/00 5:59:52 PM Eastern Daylight Time, 
zoneti@tinews.net writes:

> On Sat, 22 Apr 2000 ComAsYuAre@aol.com wrote:
>  
>  > 
>  > In a message dated 4/22/00 5:29:54 PM Eastern Daylight Time, 
>  > zoneti@tinews.net writes:
>  > 
>  > > Hrmm...I'll try this. But you use "or a" to check if the tile is clear.
>  > >  Does this only work for blank tiles?
>  > 
>  > The code assumes that the only tiles that can be passed through are 
those 
>  > with a value of 0.  
>  
>  What do you mean by that? Do you mean that only the first tile it the set
>  is passable? (It is 0 in the list).

Well, ideally you arrange your tiles so that all the transparent (passable) 
ones are within a range, and all the non-passables are in another range.

  call GetTile
  ld a,(hl)
  cp 20   ;first 20 tiles (0-19) are transparent
  jr nc,mainloop

>  
>  > You can change the code to check for whichever tiles are 
>  > passable and which ones are solid.
>  
>  Hrmm...how would I do that?
>  
>  > Also, before moving the coordinates be sure to erase the old sprite and 
to 
> 
>  > redraw it after updating the coords.
>  
>  Whats the best why to save a 8x8 area of the screen to a temporary space?
>  I'm guessing adding the offset of your xy to $Fc00 and grabbing a byte
>  then incrementing by $10 but I'm not sure =/

There are two efficient ways that I can think of offhand.  One, the way sqrxz 
does it, is to have the PutSprite routine automatically save the background 
to a buffer.  You can download Jimmy's PutSprite routine off of ticalc.org.  
The other way is to draw all the tiles to a buffer and then copy them onto 
the screen before drawing moving sprites.  The background is overwritten each 
time, but you can just recopy it from the buffer so that nothing is modified. 
 You can even do all this to a buffer, which is essentially triple-buffering, 
but would help prevent flicker.

  ld hl,tilebuffer
  ld de,buffer
  ld bc,1024
  ldir  ;copy background

  ld bc,(coords)
  ld hl,sprite
  call PutSprite   ;display moving character on buffer (PutSprite must be set 
up to draw to buffer)

  ld hl,buffer
  ld de,$fc00
  ld bc,1024
  ldir   ;copy buffer to screen



----
Jonah Cohen
<ComAsYuAre@aol.com>
http://jonah.ticalc.org