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

#1 2012-02-18 22:10:02

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

1 Sprite 1 Script

I am confused about how these work. If someone could help, that would be great!  smile


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#2 2012-02-18 22:26:20

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: 1 Sprite 1 Script

Quite basically it's just 1 sprite with 1 Script, an example would be the Scratch Cat with the script:

When gf clicked
Say [Hi]
smile

Last edited by laptop97 (2012-02-18 22:26:44)

Offline

 

#3 2012-02-18 22:30:18

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: 1 Sprite 1 Script

Basically, they use variables instead of broadcasts and multiple scripts. So something like this:

when gf clicked
set [score v] to (0)
set [lives v] to (3)

set [x1 v] to <pick random (-200) to (200)>
set [y1 v] to <pick random (-200) to (200)>

set [x2 v] to <pick random (-200) to (200)>
set [y2 v] to <pick random (-200) to (200)>

reset timer
forever
    go to x:(x1) y:(y1)
    point towards [mouse-pointer v]
    move <(timer) / (3)> steps
    set [x1 v] to (x position)
    set [y1 v] to (y position)

    if <touching [mouse-pointer v]?>
        change [score v] by (timer)
        change [lives v] by (-1)
        reset timer
        if <(lives) < (1)>
            stop script
        end
        set [x1 v] to <pick random (-200) to (200)>
        set [y1 v] to <pick random (-200) to (200)>
    end

    go to x:(x2) y:(y2)
    point towards [mouse-pointer v]
    move <(timer) / (3)> steps
    set [x2 v] to (x position)
    set [y2 v] to (y position)

    if <touching [mouse-pointer v]?>
        change [score v] by (timer)
        change [lives v] by (-1)
        reset timer
        if <(lives) < (1)>
            stop script
        end
        set [x2 v] to <pick random (-200) to (200)>
        set [y2 v] to <pick random (-200) to (200)>
    end
Two "enemies" or Scratch Cats spawn and chase the mouse-pointer. The goal is to wave the mouse-pointer around and "survive" until you loose all your lives.

But the point is, there are "two" sprites moving, even though there is only one.

Last edited by Magnie (2012-02-18 22:31:53)

Offline

 

#4 2012-02-18 22:31:34

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

Re: 1 Sprite 1 Script

Thanks for your feedback, but I'm talking about a project like this:
World Jump


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#5 2012-02-18 22:34:16

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

Re: 1 Sprite 1 Script

Sorry Magnie97, you posted while I posted my last post. I will study your script.  smile  Thanks!


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#6 2012-02-18 22:39:28

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

Re: 1 Sprite 1 Script

Okay, so basically, there is one sprite that goes back and forth between two locations, but it switches back and forth so fast that it looks like there are two sprites?


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#7 2012-02-18 22:40:47

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: 1 Sprite 1 Script

pi3 wrote:

Thanks for your feedback, but I'm talking about a project like this:
World Jump

That game was made by stamping (I think) the floor/world/monsters/items/etc then stamping the character. Then they check for user-input, act accordingly. Then they check for collisions, act accordingly. Then check for anything else (for the end of the level, a coin, etc), and once again, act accordingly.

The script I made can probably be done in simpler terms with lists. But for the sake of clearly showing what's happening, it's been made like that.  smile

Edit:

pi3 wrote:

Okay, so basically, there is one sprite that goes back and forth between two locations, but it switches back and forth so fast that it looks like there are two sprites?

Yes, exactly.  smile

Last edited by Magnie (2012-02-18 22:42:31)

Offline

 

#8 2012-02-18 22:52:01

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

Re: 1 Sprite 1 Script

Thanks so much! You've been a big help!  smile


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#9 2012-02-18 22:53:54

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: 1 Sprite 1 Script

pi3 wrote:

Thanks so much! You've been a big help!  smile

Anytime. Did you try it? I need to make sure the script works, since I never tested it in Scratch.  wink

Offline

 

#10 2012-02-19 01:56:29

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: 1 Sprite 1 Script

@pi3: You're right that it switches back and forth, but it often stamps its costume in multiple places.  There is a slight delay in Scratch's "repeat" and "forever" blocks (between each execution of the script inside the loop), so the stamped images remain on the screen for a fraction of a second before the stage is cleared and the sprites stamp themselves in new locations.  One of my projects is 1s1s, but uses the pen instead of stamping.

Offline

 

#11 2012-02-19 09:43:55

Haiming
Scratcher
Registered: 2011-08-20
Posts: 1000+

Re: 1 Sprite 1 Script

1s1s are really fun, but complex 1s1s games are really hard.

Offline

 

#12 2012-03-31 22:24:25

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: 1 Sprite 1 Script

Don't forget to stamp!

Offline

 

#13 2012-04-11 10:40:10

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: 1 Sprite 1 Script

1s1s games are a type of game usually created as a challenge to the creator. Some are really simple, while others are extremely complicated (I think I've seen one that ran out of space in the programming area). 1s1s games use stamping to give the illusion of other sprites. Another form, 1s1s1c, only has one costume, so stamping other "sprites" is out of the question. In this case, most 1s1s1c games are single-level, interacting with the colors of the backround. The multi-level 1s1s1c games cannot have changing backrounds, or it would by a 1s2s1c game. Instead, the creator would use pen to create levels, which creates extremely long scripts.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#14 2012-04-11 10:50:54

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

Re: 1 Sprite 1 Script

Hmm...


Why are the secret organizations getting all the attention?  mad

Offline

 

#15 2012-04-15 11:21:25

chipguy
Scratcher
Registered: 2009-09-09
Posts: 500+

Re: 1 Sprite 1 Script

i made a ton of them if you want to see some scripts.


http://scratch.mit.edu/static/projects/chipguy/2919121_sm.png by yours truly  big_smile

Offline

 

Board footer