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

#1 2010-07-11 09:15:26

Gveradux
Scratcher
Registered: 2010-06-18
Posts: 100+

need help with a certain variable....

I have three costumes. I want them to switch costume depending on how many points there is, for e.g.

if there are 1-25 points switch to costume 1
if there are 26-50 points switch to costume 2
if there are 51-76 or over points switch to costume 3

plz help!

Offline

 

#2 2010-07-11 09:27:59

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: need help with a certain variable....

Here you go!

When Green Flag Clicked
Set points to 0
Forever
    if points < 26
    switch to costume 1
    else
        if points <51
        switch to costume 2
        else
            switch to costume 3

and in blocks:
[blocks]
<when green flag clicked>
<set{ points }to( 0
<forever>
   <if> <( <{ points }> <<> 26 )>
   <switch to costume[ 1
   <else>
      <if> <( <{ points }> <<> 51 )>
      <switch to costume[ 2
      <else>
         <switch to costume[ 3
      <end>
   <end>
<end>
[/blocks]
I hope that helped!

Last edited by shadow_7283 (2010-07-11 09:31:06)

Offline

 

#3 2010-07-11 09:37:32

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: need help with a certain variable....

Yeah- shadow_7283 beat me to it  tongue

That's essentially what you need to solve the problem.

Offline

 

#4 2010-07-11 18:57:46

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: need help with a certain variable....

If you wanted this to increase every 25 points, with a very large number of possible costumes to switch to, you could use this:

http://i31.tinypic.com/335gsva.gif

The problem with this is that if it's possible for your score to decrease, the costume won't change back. Also, it has to land exactly on 26, 51, 76, etc. for this to work.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer