Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Racing Games

Author
Message
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 4th Jul 2004 23:08
How do you actually do a driving racing game? I would like to do one while working on my other games, main thing is How will I get the A.I to follow the racing circuit, yet if they skid or spin around, they can spin around right back and follow the track?
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 24th Aug 2004 22:22
Blimey no help here either then?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 24th Aug 2004 22:43
you use waypoints, make a list of points (like the positions of cats eyes on the road) in an array, and when you pass one then mark it as passed, point the car at the next waypoint, if it spins round then turn it as it moves untill it points at the next waypoint, keep on doing so untill you reach the finish.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 24th Aug 2004 22:54
I see I would some example code of that Mentor but thanks though
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 25th Aug 2004 00:45
simple waypoint follower, just add extra code and level editor to make a full game



Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 25th Aug 2004 01:02
Thanks Mentor, fantastic I will try this out
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 25th Aug 2004 01:24 Edited at: 25th Aug 2004 01:25
hmm! that post was a bit tongue in cheek, don`t get your hopes up too much, in the example I pointed the "car" at a sequence of boxes, in a game you would use a sequence of co-ordinates stored in an array or memblock, then you would wait for the car to reach one position, and then swap to the other co-ordinate, then the next, then the next etc, you realy need to make a simple map editor for the game, then you can lay down the waypoints by just clicking and it will store them for you in an array and you can then save the array for the map, I might make a more fanciful version since I am off work this week, (depends on my other projects) that allows you to chase the computer car around a track, cheers.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 25th Aug 2004 01:56
Great, thanks Mentor looking forward to it
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Aug 2004 04:52
Quote: "I pointed the "car" at a sequence of boxes, in a game you would use a sequence of co-ordinates stored in an array or memblock"


I use hidden boxes for waypoints. It's a bigger target, you can use collision functions, and you can use programs like Magic World to lay down your track.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 25th Aug 2004 05:55
what BatVink said is also true, remember that there is always more than one way to code something, I don`t use waypoints at all in my own code, but using rotators and triggers or magnetic tunnels (my own names for methods) is far more complicated and not easy to explain, after a while if you get the feel for codeing you find half the fun is in making unbeleivably weird ways to do things that nobody else has thought of, and for any way to do something there are a dozen others you can think of and thousands that you didn`t.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 25th Aug 2004 07:18 Edited at: 25th Aug 2004 22:12
OK Mentor I will take your word for it , my game will be futurist hovercraft racing each other I think, just a simple racing game , with scaletric loops, things like that I wthink nothing too complcated as I am still really relearning BASIC
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Aug 2004 07:37
Quote: "but using rotators and triggers or magnetic tunnels "


Sounds weird, whacky and fun!

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 05:21
Nearly forgot this post since it wasnt in my bookmarks, my error sorry!, I have run up a simple track editor and a simple game to go with it, I had better explain some things first or you might not realise what is wrong if it doesnt work, you need to create a bitmap 512x512, you can go bigger later but for now stick with this, please bear in mind that this code is not optimised and has no "shine" on it, its just an example written without gosubs or functions in the hope that it makes it easier to understand.
Fill your bitmap with green and then draw a 15 pixel wide loop on it to represent the track, preferably in a dark colour, you can make the track as convoluted as you like, just don`t let the track cross (keeps things simpler), place this wonderful work of art in the same project folder as the waypoint code under this post (in the source button), run the program and it will load and display the bitmap of your track )please note that your bitmap must be called "track.bmp".
Once it is loaded you will see a small red spher in the center of the map, this is your cursor (I said it lacked shine), position the cursor on the track where you would like the race to start and click, you will see a white dot with a light ring around it, the dot is the waypoint, the next waypoint should be inside the lighter area, if you place the waypoints too far apart then the players car will be at a serious disadvantage in the actual game, since it checks for a waypoint being close by to make sure it isn`t off the track, if it can`t find a nearby waypoint then it will slow the car down to force the player to go back onto the road if he wants to win.
so if you place the waypoints too far apart the players car will keep slowing down since it will think the player is off the road and penalise him.
continue to click a "join the dots" type path around the track (always placeing the next dot inside the lighter "zone") until you get back to the start, leave a small gap between the last dot you placed and the one you started out with, then press the spacekey, at this point the program will create a .dat file with all your waypoints in it.
now read the next post on how to get this example race program working

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 05:30
ok! so you have run the editor, made your waypoints file and saved it by pressing space, now create a new project, place the code below into your editor window and save it, place the .dat file into the projects folder, and place your bitmap into the folder too, now run the code, you get a short five second countdown and then the race will start, chase the NPC car, if you run off the road you slow down, so get back on the road ;p, catch the car (you are a third faster than him so you should manage it, theres no endgame or extras, this is justan example, I spent ages fully commenting every line, so you can read the source and see how each bit works, add to it, improve it (not hard ), pass it off as your own work for all I care, any forum users who want to use the code or any ideas feel free, totaly freeware (with usual disclaimers of liability), cheers

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 05:56
code above works in pro but not in classic, heres the revised code (should work now)

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 27th Aug 2004 08:28
Thanks Mentor I shall study this in great detail
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 27th Aug 2004 18:52
Er... Mentor I keep getting a nestling error in the code aound the Next I command I don't why that is? Can I get a little help with that please?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 20:54
did you get the revised code?, I had written it in pro and just left out any pro commands, but I forgot that classic doesn`t allow some actions, remember this is simplified for understanding, lots of tricks like only having waypoints near the NPC and player, or using less waypoints and curving the NPC car round to the new heading etc are not used, this just points the NPC car at the next waypoint and moves it to there, so you need a lot of waypoints to stop the turning looking jerky with the code being so simple, I have reposted the code in the codebox (sometimes things get clipped by the forum)

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 27th Aug 2004 21:31
No I got the revised version for DBC, oK I will try thi code out
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 27th Aug 2004 21:36
No I am still getting a syntax error nestling error at line 74
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 22:07
weird, it works in classic here, just a mo.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 22:31 Edited at: 27th Aug 2004 22:34
ok, the forum "post code" thingy is eating a chunk of the code, so you don`t have the bit with the end/start of the loop and its messing up, oddly enough it has the start and the end of the code, I will try putting it into the code snippet thingy, it might fit there.



Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2004 22:33
YES! that looks like it`s all there, try that.

FAO Mike or whoever, post code box thingy eats middle? section of code, most weird.

Mentor.

PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 28th Aug 2004 01:26
Yes Mentor I think it works I wiill have to get some media to make it work properly but thatproblem is no longer there

Login to post a reply

Server time is: 2025-05-25 02:16:14
Your offset time is: 2025-05-25 02:16:14