forums

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

09-02-2003 10:33

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

thanks to everyone who helped me out on my last post, it was much appreciated.
right, i am making a single screen platform game where you must complete a mission and escape as fast as possible, but at present my little guy wont land on a platform, he just falls straight though
i used the maptutorial for collisions with sprites which worked great
and then i noticed someone had posted an algorythm for jumping,
so i put it in. now the guy doesnt land on the tile.
before i was letting the guy fly around the screen using the arrow keys, but as soon as i stopped that and put jumping in it ceased working. i can get him to land on the platform but he is still jumping,and just wobbles up and down.

any tips would be greatly appreciated as i have been stuck on ths for days, and i think the problem is with the jumping algorythm
i could post the source code or e-mail it if you think it is neccesary

thanks,
charlie

09-02-2003 10:50

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

I take it that you're using the code I posted?
Just turn jumping to false if they fall on a non-passable tile.

You might want to check the code for "bang on" in the TNT directory. The game is a platformer with jumping and shooting.

09-02-2003 10:59

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

thats what ive got at the moment
this only half works, the animation frame for jumping is swiched back to the frame for standing still when the little guy has stopped jumping, this happens as soon as it hits the tile, however, he keeps falling through the tile until he hits the designated ground level, in this case its y575

thanks

charlie

09-02-2003 14:50

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

also i looked at the bang on code, its a bit to much for me to take in

09-02-2003 18:24

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

After applying the yvelocity to the player, see if it causes him to enter a tile. If yvelocity is positive(The player went DOWN into the tile), set yvelocity to 0, jumping to false, and whatever else. However, if the player enters the tile going up, you can either do nothing and let the player jump through, or turn yvelocity to 0 and jumping to false

09-02-2003 19:59

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

still i have no luck
im going to post my code so you can pick out whats wrong with it,
it just seems that everything i try doesnt work, perhaps im missing something big?
anyway, heres the code

graphics mode 800,600
load images 128
load map 128
draw map section 0,0 to 800,600,0 to 0,0
' arrange the choords so it doesn't start on a wall
int x=100,y=575 ,upVelocity=0,jumping=false,gravity=1, spaceup
float image
while not mouse button
sprite 1,x,y,image
if left=false and right=false and jumping=false then image=0
if right=true
image=image+0.1
x=x+5
if image>6
image=3
end if

end if

if left=true
'set sprite x flip image,flip=true
'if flip=true
'flip=sprite x flip (image)
'end if
image=image+0.1
x=x-5
if image>6
image=3
end if

end if

upVelocity=upVelocity-gravity
if space=true and jumping=false
upVelocity=17
jumping=true
end if
y=y-upVelocity
if y>=575
y=575
jumping=false
end if
if jumping=true then image=6



if map tile ( x/48, y /48, 0 ) =8
if left then x=x+5
if right then x=x-5


end if
if map tile ( x/48, y /48, 0 ) =1
if left then x=x+5
if right then x=x-5

jumping=false
end if
if map tile ( x/48, y /48, 0 ) =1 and jumping=true

jumping=false
end if

if map tile ( x/48, y /48, 0 ) =9
if left then x=x+5
if right then x=x-5

end if


draw frame
wend

there are six sprites and nine tiles 48pixels square

thanks
charlie

09-03-2003 05:01

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

If you want me to look at it, go ahead and email me the source file at edoi@earthlink.net

09-03-2003 17:58

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

ok, ive emailed the source to you
thanks
charlie

09-04-2003 00:30

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Sorry, but the file didn't work. I think you have to stuff it or the resource fork doesn't get sent sometimes.

See this thread.

09-04-2003 17:15

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

ive resent the email wit hthe attachment in sit form
again, thanks for taking a look at it

thanks
charlie

09-10-2003 05:25

Posted by:
jamie

Click Here to Email jamie   Find more posts by jamie

I wrote a tutorial awhile ago that may help you, check it out.

http://www.clay-communications.com/jamie/files/sprite_tile_collision_tutorial.sit

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.