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.

Newcomers DBPro Corner / Shifting Gears

Author
Message
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 3rd Apr 2004 06:36
Lets say i'm making a racing game. And lets say I want to shift gears to increase the speed. The speed variable is "met".
The shift variable is "shift".
I need to make it so that when you hit space, you shift, but only if you are at the top speed for the previous gear.
("n" is the variable for moving X, that doesnt need changing)
If spacekey()=1 then shift=shift+1
if shift=0 then n=2
if shift=1 then n=4 : inc met
if shift=2 and met=40 then n=8 : inc met
if shift=3 and met=80 then n=16 : inc met
ect. ect.
This is a very simple thing... yet my mind doesnt seem to grasp it... mabey it's becuase it's late... but i always run into problems with that code... If i go 40, then shift, then go 80, and shift, the next thing is supposed to be 120, but it goes all the way to 240. (which is the 5th gear) Mabey it's becuase if "met" doesn't meet the requirements for the next gear to take place, shift stays in that gear, but the speed wont change.

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 3rd Apr 2004 06:43
i'd suggest writing your code in blocks

IF
...
ELSE
...
ENDIF

without any : anywhere.

plot out the logic on paper first, then write it in code. Move onto each next step only when the previous one is flawless in all situations.

rock on



Home of the VB.NET Class Builder Utility - Demo available now!
Clarks
20
Years of Service
User Offline
Joined: 30th Oct 2003
Location: BALTIMORE,MARYLAND
Posted: 3rd Apr 2004 11:02 Edited at: 3rd Apr 2004 11:04
This should help

Login to post a reply

Server time is: 2024-09-22 04:34:02
Your offset time is: 2024-09-22 04:34:02