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

#1 2012-08-13 19:12:29

Rasengankirby
Scratcher
Registered: 2012-05-15
Posts: 14

How do you make your character have health?

I doing a Kirby Super Star Ultra game and I need help with that.

Offline

 

#2 2012-08-13 19:18:59

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: How do you make your character have health?

The kind of block "variables" is good for values that can be changed or set to something, like health. So you could go to the "Variables" section on Scratch and make a variable called "Health", and change it whenever you lose or gain health. For example, for when your sprite is hurt:

when gf clicked
forever
if <touching color [bad color]?>
change [health v] by [negative number you want]
end
if <touching color [heath restoration color]?>
change [health v] by [positive number you want]
end
end


http://i48.tinypic.com/2072ctw.gif

Offline

 

#3 2012-08-13 19:41:22

gfchll
Scratcher
Registered: 2012-04-21
Posts: 100+

Re: How do you make your character have health?

and if you want a health bar, just do many sprites(in one character).one full, next one less.. ect.

 when gf clicked
forever
if< touching color [bad color]?>
change [health v] by [negative # you want]
next costume// aka health meter less
end
if <touching color [health restoration color]?>
change [health v] by [positive number you want]
switch to costume ((costume #) - (1))// previous costume( which means bigger health bar)
end 
end

Last edited by gfchll (2012-08-13 19:45:21)


HELLO EVERYBODY!

Offline

 

#4 2012-08-15 18:33:06

Rasengankirby
Scratcher
Registered: 2012-05-15
Posts: 14

Re: How do you make your character have health?

But what if it's not a bad color, what if its a bad sprite?

Offline

 

#5 2012-08-15 18:49:33

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: How do you make your character have health?

Let's say you have 4 sprites that are bad. You could do this:

1. Make a list of these 4 bad sprites. Name them exactly how they're named. For example, "Sprite One" would be put on the list as "Sprite One".

2. Add this script in the forever loop of the good guy (you):

when gf clicked
set [on v] to (1)
forever
other scripts
repeat (length of [list v])
if <(on) > [4]> // see below note :)
set [on v] to (1)
else
set [on v] to ((on) + (1))
end
if <touching (item (on) of [list v])?>
change [health v] by (-1) // or any negative # you want
end
end

Hope this helps!

Note: the 4 in the statement with the comment with it should be the length of your list; if you had, say 20 sprites on the list than that "4" would be a "20"

Last edited by powerpoint56 (2012-08-15 18:53:14)


http://i48.tinypic.com/2072ctw.gif

Offline

 

Board footer