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

#1 2008-03-23 17:32:52

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Quick question...

Hey I was wondering if someone cold help me with this...
I want to make a sprite appeer in different places each time I press the green flag...
can someone help me do this?
Thanks! smile

Offline

 

#2 2008-03-23 17:42:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Quick question...

<when green flag clicked>
<go to x sad  <pick random(1  )to( 480 )y sad  <pick random(1  )to( 360

That script will make your sprite appear in a random location every time the green flag is clicked.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-03-23 17:45:16

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Re: Quick question...

thanks  smile

Offline

 

#4 2008-03-23 17:49:52

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Re: Quick question...

Wait....I tried this and well...here is what happens
I am a starfish sprite and i'm trying to collect money(which is the sprite that moves in different places)

My background is scrolling, so how do i collect the money?

Offline

 

#5 2008-03-23 17:58:31

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Quick question...

Post what you have so far, and we can make better informed suggestions.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#6 2008-03-23 18:09:52

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Re: Quick question...

ok...look for "money hunt"

Offline

 

#7 2008-03-23 18:31:57

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Quick question...

Hey I noticed that your is a remix of one of my projects. It would be nice if you mentioned that you used my codes in your project notes. I think you may want to double check my project because there are a lot of overlapping area sprites because you never set the y positions of the area sprites.

Ok now for the random positioning.

Every non-player sprite affected by scrolling will have a script that looks like this. The sprite needs to have 2 variables to store it's x and y position. I called these variables freemoveX and freemoveY.


<when green flag clicked>
<forever>
<go to x sad  (( <{ scrollX }> <+> <{ freemoveX }> )) )y sad   (( <{ scrollY }> <+> <{ freemoveY }> ))
<end>

If you want to randomize the position of these variables on the scrolling screen just randomize the freemoveX and freemoveY variables.

like this

<when green flag clicked>
<set{ freemoveX }to(<pick random( 1 )to( 2400
<set{ freemoveY }to(<pick random( 1 )to( 1400

Last edited by archmage (2008-03-23 18:32:56)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2008-03-24 01:38:27

scra
Scratcher
Registered: 2008-03-23
Posts: 1

Re: Quick question...

I have found an easier method to do scrolling with many sprites . It requires only 2 variables.[blocks]first make a variable <{scroll x}> After that make a variable <{ steps }>
then go to the stage and write in this script <when green flag clicked><forever><if><key[right arrow]pressed?><set{scroll x}to(-3)<wait( 3)secsc> <set{  scroll x}to( 0) and for left arrow do the same thing but change -3 to 3.Then also write<when green flag clicked><forever><if><key[right arrow]pressed?><change{ steps }by(1). Do the same thing for the left arrow but exchange 1 by -1. Then write in if the Green flag pressed Forever If Steps = 30 or >30 then broadcast come on. Then make a sprite and in it  write Forever change x by scroll x. Then type when Green flag pressed hide . Then type When i receive come on go to x 230 and y 100 or wherever you want show and then snap the previous script to it. and then type When green flag clicked forever wait until x < 150 and touching edge
hide. Then go to the stage and type if steps <250 broadcast come again. And in the sprite type If i receive come again go to x-238 and y100 or whatever you want it to be . Now it will not flicker when it comes .thanks. :-)

Offline

 

#9 2008-03-24 19:33:50

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Re: Quick question...

thx man!

Last edited by auburn1996 (2008-03-24 19:42:28)

Offline

 

#10 2008-03-24 19:43:29

auburn1996
Scratcher
Registered: 2008-03-18
Posts: 15

Re: Quick question...

sorry archmage...I will be sure to mention you  smile

Offline

 

#11 2008-03-28 21:37:24

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Quick question...

HOW DO YOU MAKE SCROLLING GAMES!!!


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#12 2008-03-28 22:51:10

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Quick question...

Go to http://scratch.mit.edu/forums/viewtopic.php?id=2440 for scrolling help.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer