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

#1 2012-06-02 21:20:00

bconrad1
New Scratcher
Registered: 2012-06-02
Posts: 3

Have sprite move in random direction, not just straight down?

I have a ball I need to hit a paddle and bounce up. It has to go in a random direction when it hits the paddle and when it starts. It can't just go down. I tried using the glide control but it wouldn't register when it hit an object since it was for a set amount of seconds. My only other thought was.

-If it hits paddle
     -Change y by 4
     -Set X to random number

But that just makes the ball go crazy. Any thoughts.

Offline

 

#2 2012-06-02 21:23:30

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Have sprite move in random direction, not just straight down?

bconrad1 wrote:

I have a ball I need to hit a paddle and bounce up. It has to go in a random direction when it hits the paddle and when it starts. It can't just go down. I tried using the glide control but it wouldn't register when it hit an object since it was for a set amount of seconds. My only other thought was.

-If it hits paddle
     -Change y by 4
     -Set X to random number

But that just makes the ball go crazy. Any thoughts.

Is the ball using an actual direction to move? Or is it dependent on x and y movement?


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2012-06-02 23:37:40

bconrad1
New Scratcher
Registered: 2012-06-02
Posts: 3

Re: Have sprite move in random direction, not just straight down?

I just need to the have the ball moving down towards the paddle, although it may not be straight down, it could be 50 points to the left or 100 to the right the number will be random. I just can't figure out how get it move diagonally.

Offline

 

#4 2012-06-02 23:44:29

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Have sprite move in random direction, not just straight down?

You could use the pick random number block, in conjunction with move and direction blocks, it should work.


Why are the secret organizations getting all the attention?  mad

Offline

 

#5 2012-06-02 23:57:23

bconrad1
New Scratcher
Registered: 2012-06-02
Posts: 3

Re: Have sprite move in random direction, not just straight down?

sonicfan12p wrote:

You could use the pick random number block, in conjunction with move and direction blocks, it should work.

I have move 5 steps and in direction of (random direction) but the x goes crazy because I think it sets a new direction for every step.

Heres what it looks like
http://www.flickr.com/photos/50130125@N08/7324786202/

Offline

 

Board footer