This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-22 14:45:49

beeezy
New Scratcher
Registered: 2011-03-22
Posts: 3

How to change speed in game?

Hello!

Could anyone help me with this: How can I put the speed of an object depend on the pointss in the game, like if earn more points then object start moving faster?

Thank you!

Offline

 

#2 2011-03-22 14:53:19

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: How to change speed in game?

Make a variable called Speed. Set Speed to the initial value of what you change x (or y) by. Finally, when you get a certain number of points, change speed by a certain number.


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#3 2011-03-22 19:53:29

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: How to change speed in game?

Your sprite could include a WAIT () block.  Put a variable in there that gets smaller as the score goes up.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#4 2011-03-22 22:31:12

kingofdallamas
Scratcher
Registered: 2010-03-07
Posts: 500+

Re: How to change speed in game?

scratcher7_13 wrote:

Make a variable called Speed. Set Speed to the initial value of what you change x (or y) by. Finally, when you get a certain number of points, change speed by a certain number.

Yes, scratcher7_13 is correct.  smile  Basically, you these scripts:
<when green flag clicked>
<set{speed  }to( 2
<set{level } to (1
<set x to( speed
forever
if <level> =2
<change{speed } by (1
else <level> =3
<change {speed} by (2
etc.etc.

There are many variations of how to do it though. Hope this helps!!


http://i853.photobucket.com/albums/ab99/Gilgamesh1192/Ninja%20Saga/ElementalJutsus2.gifhttp://i27.photobucket.com/albums/c192/BoomKaTish/GIF/thgfhgfhfhgf.gif
ハロー友だち!

Offline

 

#5 2011-03-23 03:19:01

beeezy
New Scratcher
Registered: 2011-03-22
Posts: 3

Re: How to change speed in game?

I tried it like this, but it did not work it goes very slow all the way now:

<when green flag clicked>
<set{ speed }to( 2
<set{ count }to( 0
<forever>
<set x to( speed
<if><(  count  )>2
<change{ speed }by( 4

any ideas??

Offline

 

#6 2011-03-23 08:29:11

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: How to change speed in game?

The problem you have is the "set x to (speed)" block. Really you want to change x by speed, but there is another small problem with your scripts, as soon as you reach count 2 the sprite will move too quickly. Try these scripts:
http://img716.imageshack.us/img716/8812/screenshot20110323at827.png

The second script makes it so every time the score increase, speed also does.

I hope this helps  smile


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#7 2011-03-23 11:01:02

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to change speed in game?

demosthenes wrote:

The problem you have is the "set x to (speed)" block. Really you want to change x by speed, but there is another small problem with your scripts, as soon as you reach count 2 the sprite will move too quickly. Try these scripts:
http://img716.imageshack.us/img716/8812 … 3at827.png

The second script makes it so every time the score increase, speed also does.

I hope this helps  smile

Set count to count? I think you mean set old count to count.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#8 2011-03-23 16:38:51

beeezy
New Scratcher
Registered: 2011-03-22
Posts: 3

Re: How to change speed in game?

Still can't make it work.
Where does this "old count" comes from?, do I need to put it some other script aswell?

Offline

 

Board footer