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 / Basic collision and acceleration

Author
Message
Pikey
16
Years of Service
User Offline
Joined: 19th Apr 2008
Location: England
Posted: 20th Apr 2008 06:33
Hi guys, I really hope i can get some help on this cause i've been searching for a while in vein for a solution.

Basically im trying to make a very simple maze game where you get the marble from one end to the next. the code is as follows;



The level is meant to be icey and i want the ball to gradually accelerate and then slow it self down once you stop pressing the up key. oh and for the ball to not go through the walls as well.

Any help would be greatly appreciated. Thanks

PS "rem'd" out the lines of code that ask for media so it should work as soon as its copied into Darkbasic
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 20th Apr 2008 22:29 Edited at: 20th Apr 2008 22:31
Welcome to the forums, Pikey! For the acceleration part of your question, you might want to try something like this:



When the upkey is pressed, your speed increases by acceleration# (after all, acceleration is defined as a change in speed over time). Your marble will then move at an increased speed. If Upkey is not pressed, however, then the speed# will be reduced by acceleration# each time the program cycles through the code. You'll notice I've added a little If statement that checks to make sure that the speed never falls below zero - otherwise, your marble would start rolling backwards!!

For collision, I think your best bet would be to have a look at TDK's collision tutorial:
http://forum.thegamecreators.com/?m=forum_view&t=96045&b=10
It's pretty detailed, and I think it explains collision a lot better than I could.

You could try something like this, though:



I'm not sure how good the last bit of code will be, but I hope all this is of some use.

It is said there are 10 types of people in this world - those who understand binary, and those who have friends!

Login to post a reply

Server time is: 2024-09-27 14:24:16
Your offset time is: 2024-09-27 14:24:16