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 Professional Discussion / help with acceleration

Author
Message
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 27th Nov 2003 02:47
I have 2 ?'s

1. i've been having problems getting a vehicle to accelerate. I,ve tried steps and i've also have tried useing floats with speed ,acceleration, friction ect. Promblem I've been having is that no matter what i use i don't get any gradual increase in speed it starts out and stays the same no what i set things at. If I start it out slow it adds up the math and moves but it wont increase any higher. I'm missing something here , probably cause im still new to all this. More than likely cause my math skills are limited to basic algerbra and its been 15yrs since ive graduated high school.

I'm not trying to make a racing game , auto combat so i just want to create the impression of speed variation but for gaming purposes realism isn't to important due frantic gameplay(drive, shoot, run, go,go,go)

any suggestion?

2. how much of a difference is their between the new patch and the disc version of DBP? I have not downloaded yet because I've read that the debugger doesn't function with the upgrade . Becuase im new to this I use the debugger all the time, and rely on it to show me my errors, and without it im affaid i would be completely lost. If the debugger works please let me know, also if their is still a way to get around this patch flaw please inform me.

thanks
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 27th Nov 2003 03:21
I don't know about the debugger I never use it, I personally preffer to text suspect information to the screen during the program loop.

The download patch is an order of magnitude more stable than the disk version, infact the disk version is so buggy that I put it over the hob and melted it into a nice ash tray and could even explain why your acceleration routine is not working.

How I tackle acceleration, and i'll simply this a little because i'm very sad and program in complicated ways because i'm a nerd, is like this.

I have three values, acceleration, current speed, and top speed.



Tinker with the values to suite your game, but that's pretty much the principle.


God created the world in 7 days, but we're still waiting for the patch.
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 27th Nov 2003 07:20
Tried your snippet but i'm still having the same problem.
When i press the upkey because speed =0 and acc= 0.01 the car crawls across the screen never going any faster than 0.01.
even though top is set for 5 the car never exceeds 0.01 . Am I not doing something right here? It won't keep adding into itself. If I use repeat it runs into conflict with the repeat command being run with program itself. If i try to loop it , it locks into itself with speed loop locking out everything else.
las6
23
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 27th Nov 2003 08:44
eh? problems looping it?



doesn't something like that work?

Keyboard not detected. Press F1 to continue.
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 27th Nov 2003 15:30
las 6
tried snippet on its own had to play with up and downkeys()=1 just to get the object to move then had to lower everything down to thousands of a unit to slow it down enough so i could see what the he** was going on. When play with it i was getting some progress with it thou
but no when i put the do-loop in my program it conflicts with the repeat command i have set up for the camera and collisions the screen will show the backdrop and the frame per sec sring on screen but will not show matix or any objects.

Would a while endwhile loop work or do i need to restucture the coding re-placing thinks in a diferent order. Could this be part of the loop confliction that i've been getting?
Thanks for the advice at least i kind of have an idea of what its not.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 29th Nov 2003 06:48
See these:

acc=0.01
spd=0
top=5

There are setting the variables at the start of your program.

If you put spd=0 into your mainloop then every time your mainloop see's spd=0 your spd will be set to 0!

As spd is your speed in this example, that meens your speed is being set to 0.

So whenever you accelerate your speed will equal (spd=spd+acc) 0.01.

It's nothing to do with what loop you use, if the program see's the line spd=0, then your spd will equal 0.

For a further explanation see the 'variables' section of the help file found in 'Principles' menu, then 'data types & variables'. I believe it will explain the basics of what a variable is and the fundamental basics of algebra and why when you give the command spd=0 then spd will be set to 0.


God created the world in 7 days, but we're still waiting for the patch.
Shadow Lord
22
Years of Service
User Offline
Joined: 26th Sep 2003
Location:
Posted: 29th Nov 2003 17:05
Also, post the code you are using so we can see what you're doing wrong.

I'm using DBPro to write "Suger Free Candyland", for diabetic children!
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 30th Nov 2003 02:03
okay here is a snippet of the code.
please explain what the h377 the problem is .
the controls are part of a subroutine in the main loop of the program. If i put a loop such as do-loop or while endwhile the program gets caught in the loop and will not perform any of the other commands.
if i keep the car at a set speed everythings fine, but i don't want the car to lunge forward at top speed.
I know the forward might seem strange but at this point im trying to get acceleration one direction only to work before i try reverse and gradual slow down in either direction with the gas off.
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 30th Nov 2003 02:05
[/code][code]
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 30th Nov 2003 02:05
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 30th Nov 2003 02:06
BHoltzman
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 30th Nov 2003 04:56
Stormbringer, you might get better results if you use a log function to calculate your speed. The way this will work is probably something like this.

Speed = SpeedMultiplier * Log(inc(acceleration),2)

Where I'm assuming the log function takes these arguments, Log(Number to log, Base of the log).

The reason that Log is a good function to use for acceleration is because it accelerates quickly and then accelerates at a slower rate later on.
Krash
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location:
Posted: 30th Nov 2003 08:09 Edited at: 30th Nov 2003 08:16
I see where your problem is, you've made the movement and accel into a sub-routine and you keep resetting the variables just like Andy said. Try declaring your variables at the start of your program and only set them once - Like this...

I left out the collision stuff for clarity...
Personally, I would make my sub a function so that I could colapse it in the GUI to make things neater(plus I just like using functions)
Hope this helps!

It's all fun and games 'till someone loses an arm...
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 1st Dec 2003 17:13
See, I can read your code before you even show it to us I read minds too, this is probably a bad thing .... especially for you Rich... mwhahaHAHA!


God created the world in 7 days, but we're still waiting for the patch.
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 2nd Dec 2003 02:02
thanks Krash & Andy.
Used your advice Krash the only thing I noticed was when the car hit top speed it paused moved to top speed paused again over and over.Does this have to do with it being a subroutine and would making this a function cure this?
Also when either the up or down key was pressed the car kept moving in wichever direction even after the keypress was released. I'm hoping that when you move forward or reverse that when you release the direction key it would gradually move to a stop.
would it be something like
if upkey()=0 and speed >0
speed= speed - accel
if speed = 0 then speed = 0

Would this cancel out all movement period, and if it did would i need to create more variables floats ect?

If i want the car to brake more quickly before stopping then going in reverse do i need to make another code for hitting down key while greater then zero , hitting downkey if = to zero or less?

Sorry if this sounds confussing, basically think of control schematics similar to Twisted Metal or Vegilanty 8.

Any ways thanks for the help, you've helped me with a 2 week migraine.
Krash
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location:
Posted: 2nd Dec 2003 03:25 Edited at: 2nd Dec 2003 04:14
I don't notice any pause on my machine at top speed. Don't know why you would, but using a function wouldn't help this, it just makes the code cleaner(I think so anyway).
As for your other questions, I believe I have what you're asking for...

Hope this helps. I know all too well how migraines feel...

It's all fun and games 'till someone loses an arm...
Stormbringer
22
Years of Service
User Offline
Joined: 1st Oct 2003
Location:
Posted: 5th Dec 2003 00:40
Don't know why it pauses either but it does well not really pausing but more of a slight hesitation. Car reaches top speed hesitates then goes back to top again repeating this over and over. Also still not getting any slow down when no key is pressed and the car is in motion. This is what is becoming the most annoying, i've tried everything I can come up with and still nothing. I even ran your snippet alone and I still get no decrease. When a direction is pussed the vehicle still keeps going at the same speed indefinetly until you change in manually. Thanks for trying thou.

Just incase you might think its my machine I'm useing an Anthlon XP 2600 516megs with Geforce 4 440 with 64megs . Though im not to impressed with my gforce my radeon 7000 can do all the effects for DBP the Gforce cant.
Krash
23
Years of Service
User Offline
Joined: 13th Oct 2002
Location:
Posted: 5th Dec 2003 01:53
Quote: " I even ran your snippet alone and I still get no decrease"

You may have gotten my first post (it was edited...sorry). Try the snippet again, it works for me...

It's all fun and games 'till someone loses an arm...

Login to post a reply

Server time is: 2026-07-26 20:16:56
Your offset time is: 2026-07-26 20:16:56