forums

TNT Basic Forums > Programming Q&A
Difficulty on making a racing game...
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-13-2003 21:33

Posted by:
Leorik The Creator

Location:
Montréal,Québec(canada)

Find more posts by Leorik The Creator

Im starting to make a racing game with TNT

i have all my graphics ready and some of my map but can someone help me with the direction of the car...


i have input done but the car don't want to move if their a way to someone to write me exemple(s) of this ??

Thanks to all of you who reply my thread and continue making games on tnt basic!

Leorik

10-14-2003 00:27

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Well...

You could make it a bit easier by telling us a bit more about it, are you using a joystick or mouse to move the cars?

If you are just using the keyboard, inputs aren't really needed.

If you could post the bit of code that you have to move the car, I might be able to help you.

10-14-2003 23:39

Posted by:
Leorik The Creator

Location:
Montréal,Québec(canada)

Find more posts by Leorik The Creator

nothing

thats correct someone else help me

thanks anyway...

10-15-2003 06:57

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

How about this?

***

Graphics Mode 640,480
Load Images 128

float carx=100,cary=100,speed=0,accel=0.2,maxSpeed=4
float mx,my
int d 'direction between 0 and 39

while not mouse button
if left
if d=0
d=39
else
d=d-1
end if
end if
if right
if d=39
d=0
else
d=d+1
end if
end if
if up and speed<maxSpeed
speed=speed+accel
end if
if down and speed>maxSpeed*-0.5
speed=speed-(accel/2)
end if
if space
speed=0
end if
if d>-1 and d<11
mx=(d/10)
my=(d/10)-1
end if
if d>10 and d<21
mx=1-((d-10)/10)
my=((d-10)/10)
end if
if d>20 and d<31
mx=0-((d-20)/10)
my=1-((d-20)/10)
end if
if d>30 and d<40
mx=((d-30)/10)-1
my=0-((d-30)/10)
end if
cary=cary+speed*my
carx=carx+speed*mx
Sprite 0,carx,cary,0
Draw Frame
wend
***

Or something like it. You're going to have to fix the breaking though, as at the moment pressing space simply halts movement instantly. You can modify accelleration and max speed, though, which would abviously be quite important and a racing game.

And, if the car hit something, you could just say:

speed=speed*-0.75

and it would probably bouce backwards.

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.