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 / Transmission coding gone awry

Author
Message
Phrozin
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Florida USA
Posted: 17th Feb 2004 13:36 Edited at: 17th Feb 2004 13:37
K, for 3 days now I have been working on this one section of a game. Actually just the neutral gear I'm having a hard time with.

Here's the full source code:


K, so what it's doing is when the game starts (IE trans in "N", it says can't divide by zero. K, but I can't figure out how to make a neutral gear without it being 0.)

Also the gears are "skipping" gears from shifting to fast. What I'm trying to do here (it's not actually a game) is make a simulator for the new trainees. Problem is 1) I need atleast 10 forward gears, 6 reverse gears in some trucks, 13 forward gears, and 2 reverse gears in others. problem 2) I can't figure out how to make a gear system, and accel system, weight system to work together.

Thx to anyone that can help I would really appreciate it,

Phrozin
GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 17th Feb 2004 16:29 Edited at: 17th Feb 2004 16:42
hmmm... think of a pizza... if you devide that pizza by eight you have eight slices of pizza... if you devide it by 2 you have 2 halves... devide it by one and you have a whole pizza...
now, what if you devide that pizza by 0... how many pieces and how big would each piece be. There is no known mathamatical way to devide any number by zero... so you should always avoid doing it in code... I think you want a number/0 to equal zero... try instead...

Temp1#=Rpm#/(GearA#+0.000001)

I think that will get you the wanted result and not get an error...
well...I hope that fixes your problem...

[edit...]
I did not fully read your post... sorry...
What happens is, when you push the key, even if you don't notice it, you are holding it down for a period of time... what you can do is add a variable that will tell you whether or not you have released the key...change this...

IF KEYSTATE(30)=1 THEN INC Gear#,1
IF KEYSTATE(44)=1 THEN DEC Gear#,1

into this...

IF KEYSTATE(30)=1 and Shifted#=0
inc Gear#,1
Shifted#=1
Endif

IF KEYSTATE(44)=1 and Shifted#=0
dec Gear#,1
Shifted#=1
Endif

IF Keystate(30)=0 and Keystate(44)=0 then Shifted#=0

well... once again... i hope that helps...

Do not thwart the way of the dragon. For thou tasteth like chicken.
Clarks
21
Years of Service
User Offline
Joined: 30th Oct 2003
Location: BALTIMORE,MARYLAND
Posted: 18th Feb 2004 05:40
IF GEARA#<>0
TEMP1#=RPM#/GEARA#
ELSE
TEMP1#=0.0
ENDIF
Phrozin
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Florida USA
Posted: 18th Feb 2004 07:25

Many Thx Game_Creator and Clarks, both suggestions worked like a charm!

Now I can go get some sleep finally.

Again Thank you very much,

Phrozin

Login to post a reply

Server time is: 2025-05-23 04:11:49
Your offset time is: 2025-05-23 04:11:49