Discuss Scratch

korneliuss
Scratcher
53 posts

Help with my Punching Game script!

Hey Scratchers, So I am currently in the works of a punching-tycoon type game and there is something that I am having trouble with, within the scripts. I want the player to hit the punching bag and the health goes down and when it hits 0 it goes to the next punching bag and increases they health by 3. Though when I am doing this, the punching bag health just goes to the negatives or doesn't even change for some reason. Here is the link to the game so that you can experiment with the code https://scratch.mit.edu/projects/528548061/ Thank you!

when green flag clicked
say [Thanks for your help!]

Check Out My Account Here!- https://scratch.mit.edu/users/korneliuss/
- I Love To Make Clicker And Rpg Games
- I Am Currently Making A Turn-Based RPG Game
- I Am Somewhat New To Scratch So If You Have ANY Tips About Scratch Let Me Know! I'd Love To Hear From Experts!
-Scratch On!
- Here Is One Of My BEST Games! https://scratch.mit.edu/projects/489347461/
Joemamaistaken
Scratcher
24 posts

Help with my Punching Game script!

when I receive [Game start!]
forever
if <touching [Player] ?> then
change [HP] by (-1)
if <[HP] = [0]> then
next costume
end

Last edited by Joemamaistaken (May 11, 2021 15:59:10)

CITHCrate
Scratcher
57 posts

Help with my Punching Game script!

its because you're constantly setting the hp to 3. In the punching bag sprite under the when game start block on the right, you made it so that it constantly sets the hp to 3 or 6 depending on the costume. You can fix this by taking the costume detector out of the forever block, making a new message that broadcasts when the hp reaches 0, and make the costume detecting blocks run when the message is broadcasted. I apologize for not being able to make the block visual things as i am new to the forums and dont know how to do that

Last edited by CITHCrate (May 11, 2021 15:49:46)


The guy
CITHCrate
Scratcher
57 posts

Help with my Punching Game script!

oh yeah another thing, if it goes into the negatives make it detect when the health is less than 1 instead of detecting when the health is 0, this will fix it going into the negatives if you add stuff like increasing damage per punch

The guy
korneliuss
Scratcher
53 posts

Help with my Punching Game script!

CITHCrate wrote:

its because you're constantly setting the hp to 3. In the punching bag sprite under the when game start block on the right, you made it so that it constantly sets the hp to 3 or 6 depending on the costume. You can fix this by taking the costume detector out of the forever block, making a new message that broadcasts when the hp reaches 0, and make the costume detecting blocks run when the message is broadcasted. I apologize for not being able to make the block visual things as i am new to the forums and dont know how to do that
Wow thank you for responding! I will tried this method out and It's actually working! Thank you a lot for the help I really appreciate it!

Check Out My Account Here!- https://scratch.mit.edu/users/korneliuss/
- I Love To Make Clicker And Rpg Games
- I Am Currently Making A Turn-Based RPG Game
- I Am Somewhat New To Scratch So If You Have ANY Tips About Scratch Let Me Know! I'd Love To Hear From Experts!
-Scratch On!
- Here Is One Of My BEST Games! https://scratch.mit.edu/projects/489347461/
korneliuss
Scratcher
53 posts

Help with my Punching Game script!

CITHCrate wrote:

oh yeah another thing, if it goes into the negatives make it detect when the health is less than 1 instead of detecting when the health is 0, this will fix it going into the negatives if you add stuff like increasing damage per punch
That makes lots sense! Thanks again! Really helped!

Check Out My Account Here!- https://scratch.mit.edu/users/korneliuss/
- I Love To Make Clicker And Rpg Games
- I Am Currently Making A Turn-Based RPG Game
- I Am Somewhat New To Scratch So If You Have ANY Tips About Scratch Let Me Know! I'd Love To Hear From Experts!
-Scratch On!
- Here Is One Of My BEST Games! https://scratch.mit.edu/projects/489347461/

Powered by DjangoBB