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

#1 2012-10-23 21:01:15

Nodrogchavez
New Scratcher
Registered: 2012-10-21
Posts: 7

Parameters

Is there a way to have a sprite moving full stage width on the x: axis, but within 60 and -75 on the y: axis? I would prefer that this movement be random rather than just moving across the stage on  a straight line. Ideally the sprite would reach x: -240 point and disappear, and then appear again from the left side at x: 240 and again wander across the stage. Also, I'm not looking for a continuous feed of one sprite following the other as soon as one reaches x: -240. There will be a random variable delay between the sprites. You can see my partially completed script at:

http://scratch.mit.edu/projects/Nodrogchavez/2852913

I want the sprite to move in the area between the existing sprites.

Gordon

Offline

 

#2 2012-10-23 21:23:43

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Parameters

You want the sprite to wander across the screen, but keep its y position between -75 and 60?

I can't guarantee it will stay exactly within -75 and 60, but the following script should work fairly well.  I would probably disable your rotation is you use it.  Hope that's what you wanted  smile

when gf clicked
forever
go to x:(-240) y:(0)
point in direction (90)
repeat until <(x position) > (240)>
if<<(y position) > (45)> and <(direction) < (90)>>
turn cw (4) degrees
else
if<<(y position) < (-60)> and <(direction) > (90)>>
turn ccw (4) degrees
else
turn cw (pick random (-4) to (4)) degrees
end
end
if<(direction) < (-90)>
point in direction (-180 v)
end
if<(direction) < (0)> // must follow "it" block above to work
point in direction (0 v)
end
move (3) steps
end
Edit: change to script to avoid rare glitches.
Y position can technically range from -102 to 87 at current values I believe.  After running some experiments though, it rarely strays below or above -75 and 60 (pretty good for some guessed-at values xD).

Last edited by MoreGamesNow (2012-10-23 21:33:01)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-10-23 22:18:54

Nodrogchavez
New Scratcher
Registered: 2012-10-21
Posts: 7

Re: Parameters

Thank you so much for that, and it does seem to work. I'll have to tweak things a little, as I want my photo (by the mike) to duck if that sprite is going to touch it. It does get as low as -85 sometimes, but I'll be able to figure out how to adjust that. I also need to slow down the occurrences, rather than have the sprite in a non-stop loop, So, I'll add in some random timing on that point. But overall you have gotten me further down the road in understanding how Scratch works.

I am new to the Scratch program, but am slowly getting there. Your input has helped me a lot on my learning curve of variables, operators and so on.

Thanks again.

Offline

 

#4 2012-10-24 14:56:08

Nodrogchavez
New Scratcher
Registered: 2012-10-21
Posts: 7

Re: Parameters

Is there a way to have 2 stages? I would like to first show just a whte stage with some credits on it for a period of something like 5 - 10 seconds, and then have the script move on to the Project 0 page where the presentation resides. I have looked at the 'go to front' and 'go back X layers', but don't see how that would help. I sense that the change backgrounds option when the stage is selected might be the answer, but not sure how I would get text onto that. Any suggestions would be appreciated.

Offline

 

#5 2012-10-24 15:17:46

Nodrogchavez
New Scratcher
Registered: 2012-10-21
Posts: 7

Re: Parameters

Problem solved.

Offline

 

Board footer