TRWinner wrote:
hi , I'm making a BMX game and i don't no how to make gravity.
Any suggestions ?
thanks
TRWinner![]()
To make gravity you need to make a variable called Yvelocity. Once you have done so put this at the start of a forever loop:
[blocks]<change{ Yvelocity }by( HowStrongYouWantTheGravityToBe[/blocks]
The gravity strength must be Negative or the Object will float upwards. Next - put this in with the movement for your object:
[blocks]<change y by( <{ Yvelocity }>[/blocks]
Remember that collision when working with gravity can get quite complicated. There are many tutorials on how to do accurate collision about the scratch site.
Offline
One way is to have color sensing collision.
If <touching color[black]> <----Make the platforms black
Set yvelocity to (-1*gravity) <-----This way it counter-acts the gravity, because X+(-1*X)=0
When it gets complicated, this isn't always the best method. But if you want to use this method, I reccomend having green grass, and on the top of the grass is a short layer of darker green, and instead of sensing black, it senses the dark green.
Last edited by Lucario621 (2009-11-10 08:42:53)
Offline
TRWinner wrote:
sorry can you say that a bit simpler for me,
coz I'm a bit of a sub-zero moron![]()
cheers
TRWinner
Lol
<if><touching color[ color of ground ]>
<set{ yvelocity }to( ((-1 <*> <{ gravity }> ))
Last edited by Lucario621 (2009-11-10 09:13:25)
Offline
TRWinner wrote:
thanx loads.
how could I make tilt?, i.e going up a ramp
thanx
TRWinner![]()
Hmm, that would be a bit tricker, as it would require and such, so I'm not sure if you would be ready for that, but there are some common ways to go up a ramp, not neccecarily tilting:
Instead of the previous blocks, have this:
<if><touching color[ color of ground ]>
<set{ yvelocity }to( ((-2 <*> <{ gravity }> ))
Instead of -1 I have -2. That should work, I think.
Offline
Lucario621 wrote:
TRWinner wrote:
sorry can you say that a bit simpler for me,
coz I'm a bit of a sub-zero moron![]()
cheers
TRWinnerLol
<if><touching color[ color of ground ]>
<set{ yvelocity }to( ((-1 <*> <{ gravity }> ))
whats "gravity" mean in that script?
Offline
Try using the scripts from this project
http://scratch.mit.edu/projects/archmage/145760
Offline
archmage wrote:
Try using the scripts from this project
http://scratch.mit.edu/projects/archmage/145760
Yeah thats a good example, thats probably what you want.
Offline
TRWinner wrote:
Thanx - but I changed the costume of player to a BMXer
and it wouldn't go past terrain 2 ?![]()
Any thoughts ?
Ohh... you're making a biking/racing game... well that changes everything. Then you really should use sensors and tilting. I'll try to find something for ya'.
Offline
follow this tutorial to add more terrain sprites http://scratch.mit.edu/forums/viewtopic.php?id=2440
Offline
TRWinner wrote:
how do you put signatures on your post ?
To the bottom of where it says 'Scratch Forums', it says Profile. Click on it. On the left there should be a list of options to go to. Click on Personality. Then in the text box put what you want to say. And click submit!
Offline
Lucario621 wrote:
TRWinner wrote:
Thanx - but I changed the costume of player to a BMXer
and it wouldn't go past terrain 2 ?![]()
Any thoughts ?Ohh... you're making a biking/racing game... well that changes everything. Then you really should use sensors and tilting. I'll try to find something for ya'.
can i make it tilt ,or is that to much for a sub-zero moron lik me, should i just forget this whole thing and do something else?
oh and thanks for telling me about signatures.
cheers TRWinner
Offline
Why do you keep calling yourself a sub-zero moron. I don't even know what it is.
Offline
TRWinner wrote:
Lucario621 wrote:
TRWinner wrote:
Thanx - but I changed the costume of player to a BMXer
and it wouldn't go past terrain 2 ?![]()
Any thoughts ?Ohh... you're making a biking/racing game... well that changes everything. Then you really should use sensors and tilting. I'll try to find something for ya'.
can i make it tilt ,or is that to much for a sub-zero moron lik me, should i just forget this whole thing and do something else?
oh and thanks for telling me about signatures.
cheers TRWinner![]()
Don't bother with tilting at this point. Just modify that example project I posted.
Offline