Someone. Physics. Thank you


#1

Ok, I want to make a game, but I need a ball with Physics. Make it bounce off the edge of the screen. Also, if possible, make an ability for it bouncing off a moveable object. If not possible, take out two circles. Do not put any rules on the circles, but put rules on the ball to bounce off the circle like it could move. But one more thing:

I don't want physics where you drag the ball on the screen and it launches. I want it like a ball on a pool table with no holes. It won't move unless something else (the circle) comes in and hits it. Okay?

Credit will be given


#2

I got it all @Hoppertoscotch! I can help a lot with this project!


#3

I sadly don't have access to Hopscotch right now so I can't implement it, but here is how the logic of the ball bouncing off the wall could work:

You start off with two variables:
XVel
YVel

XVel is how fast it is going in the X direction, YVel is how fast it is going in the Y direction.
Then, have a rule:

When 7=7:
   Set Position to (x position)+XVel, (y position)+YVel

Now, set rules to check if the ball hits the top or bottom wall, and if it does, reverse the velocity:
If y position<6
YVel = Yvel * -1

If y position>790
YVel = Yvel * -1

And same with the two sides:

If x position<6
XVel = XVel * -1

If x position>980
XVel = XVel * -1

And bam! Thats how you make your ball bounce off the side. All you need now is to make it so that when the ball gets hi by something else, XVel or YVel get increased.


#4

I've made that! https://c.gethopscotch.com/p/xlulh83mb


#5

@SUPERSWAGGY Look at my topic again.

Also, THIS:

Things wrong:

  1. You did what I said NOT to.

  2. The ball bounces off a border YOU made, not the edge of the screen.


#6
  1. Sorry, I misread:sweat_smile:

  2. If you check my code, there is no actual border made, it's just a bunch pf positions, so if you change them to 0,1024,0,768 they will bump the edge of the screen


#7

@SUPERSWAGGY can you fix that?


#8

What should I fix?


#9

@BuildASnowman
Circuits Can Not Understand.
Too Complicated.
Malnfunction. Mulnfunction.
Beeeeeeerrrrrrrrrp.
The World Is Is Is Is Is Is Pre Pretty