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 / how to make a drunk driving game

Author
Message
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 18:26
how would you simulate intoxication in DBC?

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 19:13 Edited at: 22nd Aug 2009 19:16
Use sine and cosine commands that increment in random numbers, then smooth it with curveangle. Here's the function:



-incr sets the maximum frequency of the sine and cosine wave.
-angr# sets the maximum rotation value returned (if I don't want the car to rotate faster than 12, I set that to 12).
-smooth# sets the smooth value to smooth out the jagged mechanics of the calculations. A higher value is smoother, a low value is more jagged. I don't recommend a value lower than 8.

The function returns a value between 0 and the maximum angle you set (angr#), at the given frequency smoothed. So you have to add it to the cars current angle:

new_car_angle#=wrapvalue(current_car_angle#+drunk_angle#)

When switching from drunk to not drunk, made sure to set "drunk_angle#" to 0, or the car will jam and always rotate until you are drunk again.

And here is an example using it:



And of course, have fun!


TheComet


Make the paths of your enemies easier with WaypointPro!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 19:27 Edited at: 22nd Aug 2009 19:28
cool comet!!!!!

i really like this line:

drunk=drunk+1-((drunk=2)*2)

its a cool way of saying

if drunk=1
drunk=0
else
drunk=1
endif

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 19:34 Edited at: 22nd Aug 2009 19:39
Glad I could help!

Actually, what is faster?

drunk=drunk+1-((drunk=2)*2)

or

inc drunk:if drunk=2 then drunk=0


?

TheComet


Make the paths of your enemies easier with WaypointPro!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 19:37
i duno, id prolly go with the second tho since its easier to read

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 19:39
Damn, the second way is faster...



TheComet


Make the paths of your enemies easier with WaypointPro!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 19:44
wow lol

also is that really what driving drunk feels like?

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 19:46
I don't think so, since I have never been a drunk driver, but it is hard to keep control of the car, so it is a pretty good simulation.

TheComet


Make the paths of your enemies easier with WaypointPro!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 19:48
ok, reason im doing this is for s SADD (Students Against Destructive Decisions) project

idea is, make a driving sim game with two levels, one sober and one drunk, to show high school kids how dangerous drunk driving can be

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 22nd Aug 2009 20:21 Edited at: 22nd Aug 2009 20:31
A good way I do is:
drunk=1-drunk

This also works with 1-100:
num=100-num
1=99
0=100
100=0
50=50
49=51


Edit:

It's not faster tho(by 10)



4-61 ,5-52 ,6-63 ,7-94 ,8-46 ,9-??
What's the next number?
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 20:57
@razerx

drunk=0

inc drunk

drunk=1

drunk=1-drunk

drunk=0

Drunk will always equal zero, won't it?

Anyway, the fastest version is still the second one:



TheComet


Make the paths of your enemies easier with WaypointPro!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 22nd Aug 2009 21:35
what about drunk=abs(drunk-1)

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Aug 2009 21:41
The abs() command is usually really slow. But that would work.

TheComet


Make the paths of your enemies easier with WaypointPro!
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 22nd Aug 2009 21:48
Quote: "how would you simulate intoxication in DBC?"


Get a beer bottle, and smash it up against the comp screen, then turn on Db...

jk.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Aug 2009 04:57 Edited at: 23rd Aug 2009 05:00
razer had the best method and then forgot how to use it
drunk = 1-drunk
will alternate between 1 and 0...

Start: drunk = 0
Pass 1: drunk = 1 = 1-0 = 1-drunk
Pass 2: drunk = 0 = 1-1 = 1-drunk

No increment required.

TGC Forum - converting error messages into sarcasm since 2002.
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 23rd Aug 2009 05:05 Edited at: 23rd Aug 2009 05:08
MINES THE FASTEST!!!



Sorry about that I copyed the second one and forgot to erase the inc drunk.

Thanks Obese.

4-61 ,5-52 ,6-63 ,7-94 ,8-46 ,9-??
What's the next number?
Dietrich
14
Years of Service
User Offline
Joined: 15th Aug 2009
Location:
Posted: 28th Aug 2009 02:23
I'm pretty noobish to DarkBASIC,but if you could do up a basic driving game you could use something like this to get the drunken effect :



Randoffset is for deciding if the car will swerve left or right,and steeringoffset is how bad the car will swerve,would make for a very realistic drunk driving effect.
If I had typed any more code I'd have ended up coding the entire thing I'd really have to see the code of the engine to give a more concise code.
Hope I helped,
Nik.

"Don't practice 'til you get it right,practice 'til you never get it wrong."

Login to post a reply

Server time is: 2024-05-01 14:59:50
Your offset time is: 2024-05-01 14:59:50