Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with scripts for a fighting game.
- RetroDoofus
- New to Scratch
2 posts
Help with scripts for a fighting game.
I need help with some scripts for a small fighting game I was working on. There's just a couple things I need help knowing the scripts for.
So, the first thing I need help with is when the characters are fighting, how do I make the game stop once a character's health bar hits zero? When I was testing my game the characters would keep hitting until the numbers went below zero and reached negative numbers. Also when the character hits zero how do I make the defeated character change the sprite into it's defeated sprite?
Second problem is how do I make the characters change sprites when hitting each other? For example when player 1 hits player 2 how do I change the sprite so that when the second player is hit, the sprite of the character is switched out with a quick hurt pose. I'd also like to know how to switch the winning character's pose with its victory sprite once the battle is won.
I think this might be all I'd like to know. I'd really appreciate if anyone could help me, thank you.
So, the first thing I need help with is when the characters are fighting, how do I make the game stop once a character's health bar hits zero? When I was testing my game the characters would keep hitting until the numbers went below zero and reached negative numbers. Also when the character hits zero how do I make the defeated character change the sprite into it's defeated sprite?
Second problem is how do I make the characters change sprites when hitting each other? For example when player 1 hits player 2 how do I change the sprite so that when the second player is hit, the sprite of the character is switched out with a quick hurt pose. I'd also like to know how to switch the winning character's pose with its victory sprite once the battle is won.
I think this might be all I'd like to know. I'd really appreciate if anyone could help me, thank you.
- BKFighter
- Scratcher
1000+ posts
Help with scripts for a fighting game.
For your first problem, your operators (green blocks) should look like this:
For your second problem, when one character punches or fights another, have the first one broadcast a message:
<<(health) = [0]> or <(health) < [0]>>
For your second problem, when one character punches or fights another, have the first one broadcast a message:
//blah blah recognize punch do damagethen have the second one use this code:
broadcast [1 punched 2 v]
//continue with script
when I receive [1 punched 2 v]For the second part of question two (victory stance) when one sprite detects is health is less than zero stop all the scripts related to the game, and have the sprite that still has health switch the costume. The stop other scripts in sprite or stop this script only blocks might be helpful to stopping only the fight but keeping other scripts running.
switch costume to [punched v]
wait (0.2) secs //can adjust to fit
switch costume to [normal v]
stop [other scripts in sprite v]
say [notice you can place other blocks under this one]
stop [this script v]
say [not here]
Need a reason to check out my profile?
How about things like:
Simulators?
Games?
Amazing Creations?
This siggy protected by: BKFighter Kumquataway Ltd
Created from processed Kumquat byproduct
Purchase for free* at this website! asdfasdfasdfasdfasdfasdfadfadfadadfasdfas;
- RetroDoofus
- New to Scratch
2 posts
Help with scripts for a fighting game.
Thank you very much! Also, I forgot to ask but, I'd like to know what I can do to make a functioning block attack. I want the character to actually be able to block without taking in damage. Thank you.
- asivi
- Scratcher
1000+ posts
Help with scripts for a fighting game.
Hi, create a costume with a attack-blocking look and asign an specific key for it to be showed for a while ,
So, when you change the health you can avoid decreasing it
So, when you change the health you can avoid decreasing it
if <not <(costume #) = [here the number of the defensive costume]>> then
change [health v] by ()
end
- Mathoutloud
- New to Scratch
1 post
Help with scripts for a fighting game.
Hey, I'm trying to make a fighting game and I wanted to know how to end the game once a health bar reaches zero. If ya'll could help, that'd be great
(^.^")
(I'm using the health variable, don't know if that matters XD)
(^.^")
(I'm using the health variable, don't know if that matters XD)
Last edited by Mathoutloud (Dec. 6, 2017 22:40:30)
- Discussion Forums
- » Help with Scripts
- » Help with scripts for a fighting game.