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

#1 2011-10-01 18:20:59

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Help with health system & variables??

I'm trying to make a health system using only number sprites and hidden variables. The health starts out at 200. I have a separate sprite for the hundreds, tens and ones place (so I have a 2, a 0 and a 0) How can I make it to where the number sprites change costumes to make it look like the health is decreasing by however much I need it to?
(Without having to make one sprite with 200 costumes -___-)

I've seen this done in alot of games on scratch, but I can't find any of them. Please please please help. Thank you and have a nice day.


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#2 2011-10-01 19:49:45

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Re: Help with health system & variables??

BUMP. please help!!!!!!!!


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#3 2011-10-01 20:16:36

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Help with health system & variables??

umm this would be verry time consuming it would be easier to have aa veriable large readout but iff you must use your current system you have to do this
[blocks]
<forever>
  <if><( <{ health }> <=> 200 )>
<switch to costume[ 2
[/blocks]

you would have to do that for every number and each numeral sprite

or you could make one sprite have 200 costumes and do this

[blocks]
<forever>
<switch to costume[ <{ health }>

Last edited by slayerrobe7 (2011-10-01 20:19:08)


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#4 2011-10-01 21:00:12

nextstorm
Scratcher
Registered: 2009-12-13
Posts: 1000+

Re: Help with health system & variables??

okay

hundreths digit:

setCostumeTo( letter ( length of health - 2) of health )

tenth:

setCostumeTo( letter ( length of health - 1) of health )

ones:

setCostumeTo( letter ( length of health ) of health )

sorry i didn't use blocks i was too lazy  wink


bye

Offline

 

#5 2011-10-02 10:46:22

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Re: Help with health system & variables??

nextstorm wrote:

okay

hundreths digit:

setCostumeTo( letter ( length of health - 2) of health )

tenth:

setCostumeTo( letter ( length of health - 1) of health )

ones:

setCostumeTo( letter ( length of health ) of health )

sorry i didn't use blocks i was too lazy  wink

It didn't help me dude. It does something weird to the health (of the sprites) when the green flag is clicked. It starts off at "011" and when I decrease the variable it increases.  I made sure I did everything correctly. I don't know if this will help you help me, but; my costumes for the health sprites decrease from the highest number (except the tens and ones, which start from the top at zero). So from the hundreds, my 2 starts with a 2 for the first costume, 1 for second and of course, 0 for the last. My tens starts off with a zero for the first, 9 for the second, 8 for the third, etc. and same for the ones place sprite. Now that you have all of this information, is there any way you can re-help? lol much appreciated.


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#6 2011-10-03 22:17:54

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

Re: Help with health system & variables??

I would suggest making costumes 0-9 and then have it stamp each digit on the screen.

An example: http://scratch.mit.edu/projects/Magnie/2062927

Offline

 

Board footer