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 / Can't Get the Ball to Move Properely

Author
Message
programming guru
17
Years of Service
User Offline
Joined: 11th Dec 2006
Location:
Posted: 28th Feb 2007 13:24
Hi, everyone
I've programmed C++ for a couple years now, so I'm not brand new to programming, but I'm having a little trouble adapting to DBPRO.

I don't know if i'm being really dumb or just can't seem to find the right snippet out there.

All I'm trying to do for my first trial game is to put a paddle on the bottom of the screen. Use SPACEBAR to launch the ball and after the ball is launched it will bounces around on the screen edges, and when it comes back down, and doesn't hit the paddles on bottom it will fall off the bottom of the screen. If it hits, it will bounces back up.

I've gotton the paddle to properly work, and some basic collision, but I really think there has got to be a better and more ethical way to doing it and also with the ball.

here is the code that I have so far. Fell free to make any changes and if you already know how I could accomplish this, It would be great as I could really use some coding for this type of game for study as I know that this is a basic style and can be applied to a lot of different games out there



chris
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 28th Feb 2007 20:05
I've chopped you code quite a bit:



Not very comprehensive, just basic reverse velocity bouncing to start you off.
You'll want to change velocities according to where ball hits paddle, take into account speed paddle is moving when hit ball etc.


The word "Gullible" cannot be found in any English Dictionary.
programming guru
17
Years of Service
User Offline
Joined: 11th Dec 2006
Location:
Posted: 28th Feb 2007 20:38
Thanks so much for the reply. The changes you made does exactly what I was trying to acheive. Now i can study it and and will now how to do it later on in the future. I thank you for your time to read my messy code and change it to a proper form.

chris

Login to post a reply

Server time is: 2024-09-25 19:24:14
Your offset time is: 2024-09-25 19:24:14