Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » two player battle game
- Delphoxboy234
-
10 posts
two player battle game
my brother is making a two player battle game and he is having a little troubble. can anyone help? thank you to anyone that is willing to pitch in.
when green flag clicked
forever
say [I need help!] for (2) secs
end
- ap453316
-
37 posts
two player battle game
Hello, @Delphoxboy234 , I know how to do this.
From the events section, grab a “when key pressed” block. You can use that block to move your character. (ex: when right arrow key pressed = move right, when left arrow key pressed = move left.) Grab another one of those blocks and use it to make the ability. Space bar or p key would be well.
For Player 2, use the “when key pressed” block again and use it with one of these keys: w, a, s, d. Use the opposite thing of what you did for Player one. If you used the Space Bar for player one, use the p key to do it for Player 2.
Go to the “variables” section and make a variable for both sprites. They can be named player one hp and player 2 hp.
Grab a “touching color?” or a “touching sprite?” block from the sensing area to make the character lose hp. For this to work, grab a wait block and change the number to 0.5. Also, above that block, grab a “change variable by” block and set it to -1.
So it should look like this:
From the events section, grab a “when key pressed” block. You can use that block to move your character. (ex: when right arrow key pressed = move right, when left arrow key pressed = move left.) Grab another one of those blocks and use it to make the ability. Space bar or p key would be well.
For Player 2, use the “when key pressed” block again and use it with one of these keys: w, a, s, d. Use the opposite thing of what you did for Player one. If you used the Space Bar for player one, use the p key to do it for Player 2.
Go to the “variables” section and make a variable for both sprites. They can be named player one hp and player 2 hp.
Grab a “touching color?” or a “touching sprite?” block from the sensing area to make the character lose hp. For this to work, grab a wait block and change the number to 0.5. Also, above that block, grab a “change variable by” block and set it to -1.
So it should look like this:
when green flag clicked
forever
if <touching [ v] ?> then
change [ v] by (-1a)
wait (0.5) secs
end
end
Last edited by ap453316 (July 2, 2024 15:00:03)
- twirleur
-
34 posts
two player battle game
excuse me but 2 days ago sacrtch made me become a scratcher but I said later and but now I'm going to become one. How do I do it?
- Delphoxboy234
-
10 posts
two player battle game
sorry I do not know. you can make your own post and ask other people
sorry that I could not help. but other people might! they may ask you again so keep an eye out. if you have an e-mail, you can also message the scratch team about it. hope this helps a little bit!

- Discussion Forums
- » Help with Scripts
-
» two player battle game