How to make physics in hopscotch



With help from oio
(Meaning that he does it all.)



Anyway, here's a link to a post about simple gravity: Here's da post


So, Doc, you asked about gravity earlier. And I see the second post. Tell me, in your own words, what you think is going on, when gravity pulls on something. Specifically, what can we SEE happen?


The earth's orbit is pulling on the object! Simple, like when we jump, it pulls us back. But i do not know HOW it pulls us back.
Oh, and @oio, how old are you?


Yes, gravity "pulls" us down. That is right. We see that happen all around us. But have you ever noticed how things fall?

Have you ever noticed how things kind of speed-up, when they fall down? Or... slow down, when you throw them up, stop, then start falling faster and faster? This is important, if you want to get the physics into your code.

As for my age, old enough to be able to share some things that you will find useful. :smile:

I want to know... have you noticed the speeding-up? The "acceleration"?


Yes! But i thought that was velocity?


I am glad you said that. See, it's really important that we understand the difference between "velocity" and "acceleration." Lots of grown-up people don't! But you are about to...

Velocity is a measure of how fast you are going, and in what direction. For now, you can just think of it as "speed", even though that isn't exactly right.

But, Doc, gravity doesn't cause velocity. It causes acceleration. We say it does that by exerting a "force" on things. Like... my little star that's going around the black hole. :smile:

Do you want to know more...?


Aha! Yes, i would like to know more.
(Maybe how to implement this, as well!)


Of course. We will definitely get to the part where you put this new understanding into practice. But we just have to get a few things worked-out.

So, we know that gravity "pulls" stuff down. We know that stuff "has" velocity, but that gravity doesn't "cause" velocity. It causes "acceleration".

Okay... so... what is "acceleration"? I'll tell you. Acceleration is a change in velocity, just like velocity is a change in position. Change, change, change... That's what physics is almost all about.


Okay... this is really off topic, but ohm's law apply to physics?
(Voltage = current * resistance)


So, as you're contemplating your next question, let me spell some things out for you the way I wish they had been spelled-out for me. K?

You already know that we can specify "where" things are on the iPad screen. We use (X and Y) and call "(X,Y)" the "position" of the object we're talking about..


If we make X or Y or both change by some amount for every amount of time that goes by, then we have defined a "velocity" - a "speed". And just like in the real world, if we don't change the velocity in our code, the object will keep moving with the same "speed" in the same direction FOREVER...forever...forever.... (echo...echo...echo...)


Aha! So you must implement FRICTION!


Ohm's law? It is neat that you have this question, but I don't want to try to talk about too many things at oce. I like bananas and I like pizza, but I can't stuff both into my mouth at the same time.. . Ok, well, I guess I could, but that would be yucky.

Try to be patient... One discovery at a time, Isaac Newton. :sunny:


Sorry to come in randomly, but I'm fascinated too! :smiley:

Ohm's Law related to electricity as I know it! Circuits, specifically

And we use values for friction?


Now, you said something about "friction." Yes, that is, in fact, one way to change velocity. In general, it slows stuff down. And I used some of that in the HoRiZoN code. Yep. But that's really a kinda boring force. It's not the one that makes things move in beautiful parabolic paths when you throw them up in the air, like a baseball. It's just the one that makes things stop moving... eventually.

We are ready to talk about FORCES and, specifically, GRAVITY!

You ready?


No, just put in a repeat forever block and decrease the accelaration slowly
Edit:sorry i replied to the wrong person, i meant to say that to @CreativeCoder.


Sorry, @CreativeCoder. :smile: I didn't pay attention to the fact that it was you speaking. You are absolutely welcome to join in this conversation.


Yes! this had to be twenty characters.


AUGGHH! Our conversation is out of order!


Heh, talking. Sure. And yay! This is so reminiscent of last year's science class to me.. I have another 10-30 minutes to spare. Why not :smile: