I want to know how to start the physics


#1

I really want to know how to start physics instead of using change x and y inefficiently..


#2

What do you mean, use physics?


#3

Make a value "XV"

When game starts set XV to 0

Repeat forever,
Check if XV > 0
Increase XV by -.02

Repeat forever
Check if XV < 0
Increase XV by .02

When iPad is tapped,
Check if touch x is greater than Balls x position
Set XV to touch x - Balls x position divide 16
Else
Set XV to Balls x position - touch x divide 16

When balls x position is greater than 1023
Set XV to 0 - XV

When balls x position is less than 2
Set XV to 0 + XV

When game starts
Repeat forever,
Set Balls X position to XV, Set y position to ?(384)

Try this out to see if you like it.
Adjust the number "16" and make it higher or lower to suit yourself

If you want a bouncy gravity ball code check my project
Drag-Shoot or something similar on Hopscotch.
Can't provide a link at the moment


#4

Woah. You should have a tutorial topic, your good at explaining stuff.


#5

Thanks for the compliment.
I only remember this because i'm coding something like this for a game on another program.
I've coded some projects on Hopscotch 4 or more months ago and i don't remember how i did it. I sometimes even confuse myself

1 error i made

use this instead of the similar code i typed.

When game starts,
repeat forever
Set balls x position to 512+XV Set y position to ?(384)


#6

That is a really long script I guess. Anyways I Could TRY to understand it and I do like your nice scripting skills :ok_hand:


#7

I mean like the laws of physics like dropping a ball would make it fall,right? That is called physics.


#8

The code I previously typed is for rolling left/right.

For bouncing off the screen bottom,

When game starts,
Set YV to 384
Repeat forever,
Check if balls y position is greater than 5
Increase YV value by -.0125

When balls y position is less than 5
Set YV to 0+YV /1.2

When balls y position is less than 2
Set YV to 1

When game starts, repeat forever
Set balls x position to ?, Y position to YV

When iPad is tapped set YV to ?(5)

Try this and see if it works.
You can change the -.0125 and the /1.2 to change the bounciness-fall speed


#9

I don't think we have any physics blocks, but you can make it similar by using values, like the example above.