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

#1 2012-11-02 16:52:07

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

How to do a health bar and when you hit your opponent it lower

I mean like fighting games

Offline

 

#2 2012-11-02 17:12:35

pokemongardevoir
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: How to do a health bar and when you hit your opponent it lower

I think this belongs in Help With Scripts- I'll request it to be moved for you!


http://i48.tinypic.com/n50dt.gifhttp://tiny.cc/oj6plwhttp://tiny.cc/creepforum
My website has been approved by the Scratch Team.  (^_^)

Offline

 

#3 2012-11-02 17:21:41

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: How to do a health bar and when you hit your opponent it lower

Make a variable called "health" for each player.

(health)
The simplest way to make a health bar is to use many costumes.

For example: it the maximum health is 10, make 10 costumes, one for each amount of health.

Now order the costumes from least to greatest in the costume tab by dragging them.

Insert this script in the health-bar sprite. You can use a "forever" loop or make it update upon losing health.

switch to costume (health)
Hope it helped!

Last edited by thebriculator (2012-11-02 17:22:28)


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#4 2012-11-02 17:32:59

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

Re: How to do a health bar and when you hit your opponent it lower

Thanks but I want to know how to do it when you hit you'r opponent like Street Fighter and Super Smash Bros games please

Offline

 

#5 2012-11-02 17:41:41

maurootjr
New Scratcher
Registered: 2012-11-02
Posts: 6

Re: How to do a health bar and when you hit your opponent it lower

I dont or its possible in scratch

Offline

 

#6 2012-11-02 18:01:48

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

Re: How to do a health bar and when you hit your opponent it lower

What do you mean?

Offline

 

#7 2012-11-03 01:33:18

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: How to do a health bar and when you hit your opponent it lower

Do what thebriculator said and then when your character gets hits do 'change health by -1'.


http://i50.tinypic.com/ded8m.png

Offline

 

#8 2012-11-03 01:53:16

Blazingwave
Scratcher
Registered: 2012-10-27
Posts: 500+

Re: How to do a health bar and when you hit your opponent it lower

maurootjr wrote:

I dont or its possible in scratch

Of course its possible in scratch!

Also you could make the enemies one colour that nothing else is then when it is touched it will switch to a costume of your character getting hit or somthing and then health will go down like this :

forever 
  if touching colour <#000000>
  switch to costume [knocked out]
  think [ahhhhhh]
  change variable [health] (-1)
end
(where the the #000000 is you will actually put the small square of what pen color the enemy is)

(do several of the with different pen colours for different enemies and you can make the health points go further down (e.g -2) if its a stronger enemy)

You can also use the same script for going on something that will boost your points except dont put the - in the health point change. or If you want your health to go up over time :

show timer
forever 
 if timer = (500)
  change variable [health] (+10)
  reset timer
end


http://i42.tinypic.com/t8nrlh.gif  http://blocks.scratchr.org/API.php?user=Blazingwave&amp;action=onlineStatus&amp;online=http://i49.tinypic.com/25flloj.gif=http://i45.tinypic.com/o8i97l.gif
http://i41.tinypic.com/s1lyyo.jpg

Offline

 

#9 2012-11-03 01:57:03

Blazingwave
Scratcher
Registered: 2012-10-27
Posts: 500+

Re: How to do a health bar and when you hit your opponent it lower

Blazingwave wrote:

maurootjr wrote:

I dont or its possible in scratch

Of course its possible in scratch!

Also you could make the enemies one colour that nothing else is then when it is touched it will switch to a costume of your character getting hit or somthing and then health will go down like this :

forever 
  if touching colour <#000000>
  switch to costume [knocked out]
  think [ahhhhhh]
  change variable [health] (-1)
end
(where the the #000000 is you will actually put the small square of what pen color the enemy is)

(do several of the with different pen colours for different enemies and you can make the health points go further down (e.g -2) if its a stronger enemy)

You can also use the same script for going on something that will boost your points except dont put the - in the health point change. or If you want your health to go up over time :

show timer
forever 
 if timer = (500)
  change variable [health] (+10)
  reset timer
end

Lots of this is in red meaning its not a real script but im not so good with scratch blocks so this is not the exact script. The red bits you will have to swap for the bits you know it accually is but that will be easy


http://i42.tinypic.com/t8nrlh.gif  http://blocks.scratchr.org/API.php?user=Blazingwave&amp;action=onlineStatus&amp;online=http://i49.tinypic.com/25flloj.gif=http://i45.tinypic.com/o8i97l.gif
http://i41.tinypic.com/s1lyyo.jpg

Offline

 

#10 2012-11-03 05:26:10

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

Re: How to do a health bar and when you hit your opponent it lower

Blazingwave wrote:

Blazingwave wrote:

maurootjr wrote:

I dont or its possible in scratch

Of course its possible in scratch!

Also you could make the enemies one colour that nothing else is then when it is touched it will switch to a costume of your character getting hit or somthing and then health will go down like this :

forever 
  if touching colour <#000000>
  switch to costume [knocked out]
  think [ahhhhhh]
  change variable [health] (-1)
end
(where the the #000000 is you will actually put the small square of what pen color the enemy is)

(do several of the with different pen colours for different enemies and you can make the health points go further down (e.g -2) if its a stronger enemy)

You can also use the same script for going on something that will boost your points except dont put the - in the health point change. or If you want your health to go up over time :

show timer
forever 
 if timer = (500)
  change variable [health] (+10)
  reset timer
end

Lots of this is in red meaning its not a real script but im not so good with scratch blocks so this is not the exact script. The red bits you will have to swap for the bits you know it accually is but that will be easy

Thanks but the answer is not there yet I'll like to know how to make your opponent lose health when I hit them e.g. say Link is vs Yoshi and Link hit Yoshi Yoshi will lose some health how to do it like that

Offline

 

#11 2012-11-03 18:04:02

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to do a health bar and when you hit your opponent it lower

Blazingwave wrote:

Blazingwave wrote:

maurootjr wrote:

I dont or its possible in scratch

Of course its possible in scratch!

Also you could make the enemies one colour that nothing else is then when it is touched it will switch to a costume of your character getting hit or somthing and then health will go down like this :

forever 
 if (touching color [#000000]?)
  switch to costume [knocked out v]
  think [ahhhhhh]
  change [health v] by (-1)
 end
(where the the #000000 is you will actually put the small square of what pen color the enemy is)

(do several of the with different pen colours for different enemies and you can make the health points go further down (e.g -2) if its a stronger enemy)

You can also use the same script for going on something that will boost your points except dont put the - in the health point change. or If you want your health to go up over time :

show timer
forever 
 if <(timer) = (500)>
  change [health v] by (10)
  reset timer
 end

Lots of this is in red meaning its not a real script but im not so good with scratch blocks so this is not the exact script. The red bits you will have to swap for the bits you know it accually is but that will be easy

Fixed.

Last edited by ErnieParke (2012-11-03 18:04:26)


http://i46.tinypic.com/35ismmc.png

Offline

 

#12 2012-11-04 00:29:40

Blazingwave
Scratcher
Registered: 2012-10-27
Posts: 500+

Re: How to do a health bar and when you hit your opponent it lower

If you want to do what I did simply use the same script but broadcast a message which the enemy will recieve telling it to go down HP


http://i42.tinypic.com/t8nrlh.gif  http://blocks.scratchr.org/API.php?user=Blazingwave&amp;action=onlineStatus&amp;online=http://i49.tinypic.com/25flloj.gif=http://i45.tinypic.com/o8i97l.gif
http://i41.tinypic.com/s1lyyo.jpg

Offline

 

#13 2012-11-04 03:39:29

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

Re: How to do a health bar and when you hit your opponent it lower

Ok how do I do that?

Offline

 

#14 2012-11-04 19:20:48

awesomeness321
Scratcher
Registered: 2012-08-10
Posts: 100+

Re: How to do a health bar and when you hit your opponent it lower

Blazingwave wrote:

maurootjr wrote:

I dont or its possible in scratch

Of course its possible in scratch!

Also you could make the enemies one colour that nothing else is then when it is touched it will switch to a costume of your character getting hit or somthing and then health will go down like this :

forever 
  if <touching color [#000000]?>
  switch to costume [knocked out v]
  think [ahhhhhh]
  change [health v] by (-1)
end
(where the the #000000 is you will actually put the small square of what pen color the enemy is)

(do several of the with different pen colours for different enemies and you can make the health points go further down (e.g -2) if its a stronger enemy)

You can also use the same script for going on something that will boost your points except dont put the - in the health point change. or If you want your health to go up over time :

show timer//this doesn't exist....
forever 
 if <(timer) = (500)>
  change [health v] by (10)
  reset timer
end

Fixed.


My newest project:http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=projects&amp;type=newest&amp;return=image&amp;num=1Color:#30F9A5 I am currently http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=onlineStatus&amp;type=text

Offline

 

#15 2012-11-04 23:31:25

jh1234l
Scratcher
Registered: 2012-10-23
Posts: 19

Re: How to do a health bar and when you hit your opponent it lower

This is not exactly a health bar, but it still does work.

1st, Make a variable called "Health"

2nd, Make it so that touching the other player lowers it.

when gf clicked
Forever if <Touching Player2>
  Change Health by [-5]
end
(Please note that this is not how the blocks actually look like when you are programming.)

3. Make it so that the game stops if your health is lower than 0.

when gf clicked
Forever if <(Health) < [0]>
  Stop all
end

Offline

 

#16 2012-11-05 05:22:11

Blazingwave
Scratcher
Registered: 2012-10-27
Posts: 500+

Re: How to do a health bar and when you hit your opponent it lower

Link904 wrote:

Ok how do I do that?

This is what your character will add to the script I wrote already for you

Forever if <touching [enemy1]?>
   broadcast [GO DOWN HP]
   change [health] by (-1)
   switch to costume [dieing]
end

This is the script for the enemy
when I receive [GO DOWN HP]
switch to costume [kick/punch]
This is the script for the stage

When i receive [end of game]
switch to costume [you  died]
wait (6) secs
switch to costume [homepage]


http://i42.tinypic.com/t8nrlh.gif  http://blocks.scratchr.org/API.php?user=Blazingwave&amp;action=onlineStatus&amp;online=http://i49.tinypic.com/25flloj.gif=http://i45.tinypic.com/o8i97l.gif
http://i41.tinypic.com/s1lyyo.jpg

Offline

 

#17 2012-11-05 11:20:30

Link904
New Scratcher
Registered: 2012-11-02
Posts: 16

Re: How to do a health bar and when you hit your opponent it lower

Thanks

Offline

 

Board footer