forums

TNT Basic Forums > Programming Q&A
tiles
< Last Thread     Next Thread >
Author
Thread        Post A Reply

09-01-2003 12:04

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

im having trouble getting a sprite to stop when it hits a wall
i have used genesis to create a map and singled out some tiles in the code which should stop a sprite dead in its tracks, only it doesnt seem to work
ive been trying for days but to no avail
is there a simple way of doing this?
i can post my code if neccesary
thanks
charlie

09-01-2003 14:11

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I don't know how your moving your sprite. This example contains a character moved with arrows. This examples works if all floor tiles are first on the map image and all walls are last. You will have to write yourself what is between [ ].

[ draw the map and load everything ]
int execution=true,x=100,y=100 ' arrange the choords so it doesn't start on a wall

while execution

if left then x=x-5
if right then x=x+5
if up then y=y-5
if down then y=y+5

if map tile ( x/ tile width, y / tile height, [layer ( usually 0)] ) >= [ first wall tile ID]
if left then x=x+5
if right then x=x-5
if up then y=y+5
if down then y=y-5
end if

sprite 1,x,y,[sprite image]
draw frame
wend

' that sould do!

09-01-2003 15:17

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

thanks, that works well
but when i introduce scrolling it stops working
perhaps its me being useless
any more tips?

thanks
charlie

09-01-2003 20:40

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Oh, If you're using map viewports you should read my map tutorial at http://www.tntbasic.com/learn/maptutorial/maptutorial.php

09-01-2003 21:35

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

thanks
charlie

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.