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 / To put it bluntly. My Balls wont bounce.

Author
Message
MarshalMallow
11
Years of Service
User Offline
Joined: 11th May 2012
Location:
Posted: 12th May 2012 02:41
I started working on a program that I wanted as a screensaver.
Call it an unoriginal idea, but I wanted different coloured balls bouncing off the sides of the screen.

After getting one ball to bounce off the screen edges (After racking both my brain and my friends for the maths involved) I created another ball. After finally getting the two to operate independently, I added two more.

This is when the code gets unpredictable. Sometimes the balls behave and bounce off. Sometimes one ignores the boundary and moves off the screen and sometimes all my balls fly off.

I have included a .zip including all the images and project files and I apologise for untidy coding.

Any help would be magical. Thank you

Attachments

Login to view attachments
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th May 2012 18:31
Hi MarshalMallow!


So let's get your balls bouncing again!

Your problem is simple. Your balls *snicker* move faster than just 1 pixel per loop, so when you check whether it's reached the edge of the screen with this:



Your ball just jumps right over 1000. I changed it to this:



(pseudo code, I know you have other numbers)

Update is attached.

TheComet

Attachments

Login to view attachments
MarshalMallow
11
Years of Service
User Offline
Joined: 11th May 2012
Location:
Posted: 16th May 2012 23:00
See, I've tried doing this, however, when the ball crosses that line

Then once it has rotated, it is still beyond that line.

See what I'm getting at?

I figured that if I did this simple snippet


However, I noticed I will need to create global variables to control the X/Y coordinates of the balls.

Thank you for your input, if it weren't for you then I wouldn't have thought this far into it
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th May 2012 12:39 Edited at: 17th May 2012 12:46
I noticed you're using DBP, is that correct?

If so, you could check out this here : http://forum.thegamecreators.com/?m=forum_view&t=190374&b=1

The "2D collision lines" would give you just what you want, and also allow you to have complex shapes for your balls to bounce off of.

TheComet

MarshalMallow
11
Years of Service
User Offline
Joined: 11th May 2012
Location:
Posted: 22nd Jun 2012 01:41
I apologise for the late reply, the last week of college can really suck up a lot of your time (especially if you spent most of the time before making balls bounce around a screen...)
But thank you so much for your input, I have bookmarked the thread you linked me as, while I have little use for them now, they could serve as a good place for inspiration and help.

I have managed to contain my balls now by juggling around some variables and what-not.

I apologise for the terrible pun and thank you once again for your help :brohoof:

Login to post a reply

Server time is: 2024-04-20 06:28:06
Your offset time is: 2024-04-20 06:28:06