How to make a sword fighting game on scratch

  • Discussion Forums
  • » Help with Scripts
  • » Help? How can i make a character use a sword against a Sprite?

Colors-of-Code

How to make a sword fighting game on scratch
Scratcher
11 posts

Help? How can i make a character use a sword against a Sprite?

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.

when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]

But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.

How to make a sword fighting game on scratch

footsocktoe

How to make a sword fighting game on scratch
Scratcher
1000+ posts

Help? How can i make a character use a sword against a Sprite?

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch

It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.

Colors-of-Code

How to make a sword fighting game on scratch
Scratcher
11 posts

Help? How can i make a character use a sword against a Sprite?

footsocktoe wrote:

Colors-of-Code wrote:

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch

It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.

_______________________________________________________
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.

How to make a sword fighting game on scratch

deck26

How to make a sword fighting game on scratch
Scratcher
1000+ posts

Help? How can i make a character use a sword against a Sprite?

Colors-of-Code wrote:

footsocktoe wrote:

Colors-of-Code wrote:

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch

It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
_______________________________________________________
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.
How to make a sword fighting game on scratch

What @footsocktoe means is it will happen 30 times a second and since you're using a broadcast the receiver script probably won't have time to complete before it is restarted. So broadcast and wait may be better and you may prefer not to let a broadcast happen for, say, a quarter second after the previous one.

Colors-of-Code

How to make a sword fighting game on scratch
Scratcher
11 posts

Help? How can i make a character use a sword against a Sprite?

deck26 wrote:

Colors-of-Code wrote:

footsocktoe wrote:

Colors-of-Code wrote:

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch

It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
_______________________________________________________
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.
How to make a sword fighting game on scratch
What @footsocktoe means is it will happen 30 times a second and since you're using a broadcast the receiver script probably won't have time to complete before it is restarted. So broadcast and wait may be better and you may prefer not to let a broadcast happen for, say, a quarter second after the previous one.

____________________________________
thx very much i will try that know.

How to make a sword fighting game on scratch
How to make a sword fighting game on scratch
How to make a sword fighting game on scratch

bastiaan1200

How to make a sword fighting game on scratch
Scratcher
17 posts

Help? How can i make a character use a sword against a Sprite?

Script inside your guy that fights

when green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
broadcast [Hit monster v] and wait

else

end
end

This should work (Tip: Dont work allot with broad cast you can do thiswith an variable to

when green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
set [Hit.Monster v] to [1]

else
set [Hit.Monster v] to [0]

end
end


when green flag clicked
forever
if <(Hit.Monster) = [1]> then
change [Monsterhealth v] by (-10)
if <(Monsterhealth) < [1]> then
YOURSCRIPT
end

else

end
end

Now add an delay in and you are done!

I hope i helped you!

Last edited by bastiaan1200 (Aug. 1, 2016 14:41:20)


https://scratch.mit.edu/projects/117474083/

when green flag clicked
forever
[Yell v] [Bastiaan1200=Cool] Tone (100)
<<::motion><::looks><::operators><::obsolete><::sound><::events><::control><::variables><::list><::custom><::grey>::pen>

Colors-of-Code

How to make a sword fighting game on scratch
Scratcher
11 posts

Help? How can i make a character use a sword against a Sprite?

bastiaan1200 wrote:

Script inside your guy that fights
when green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
broadcast [Hit monster v] and wait

else

end
end


This should work (Tip: Dont work allot with broad cast you can do thiswith an variable to
when green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
set [Hit.Monster v] to [1]

else
set [Hit.Monster v] to [0]

end
end


when green flag clicked
forever
if <(Hit.Monster) = [1]> then
change [Monsterhealth v] by (-10)
if <(Monsterhealth) < [1]> then
YOURSCRIPT
end

else

end
end


Now add an delay in and you are done!

I hope i helped you!

__________________________________
thx very much not what i was looking for exactly but what you added will go great in the game so i'm using that know thx. (i'll put everyone who helped in the comments)

hornbeef

How to make a sword fighting game on scratch
Scratcher
34 posts

Help? How can i make a character use a sword against a Sprite?

Colors-of-Code wrote:

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch

are you actually touching the monster when you press space?



((((((((((((lVl :: undefined) :: custom ) :: list) :: variables ) :: operators) :: sensing) :: control) :: events) :: pen) :: sound) :: looks) :: motion) // RAINBOW BLOCK!!!!!!!!!!

Colors-of-Code

How to make a sword fighting game on scratch
Scratcher
11 posts

Help? How can i make a character use a sword against a Sprite?

hornbeef wrote:

Colors-of-Code wrote:

I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
How to make a sword fighting game on scratch
are you actually touching the monster when you press space?

________________________________________________________________
yes.

kuct

How to make a sword fighting game on scratch
New to Scratch
1 post

Help? How can i make a character use a sword against a Sprite?

Help, how do i create a script that makes when touching a sword you can use it to attack enemies! PLEEAASSE HELP!

deck26

How to make a sword fighting game on scratch
Scratcher
1000+ posts

Help? How can i make a character use a sword against a Sprite?

kuct wrote:

Help, how do i create a script that makes when touching a sword you can use it to attack enemies! PLEEAASSE HELP!

If the above doesn't help please create your own topic rather than necroposting and share what you currently have.

erc122potter

How to make a sword fighting game on scratch
New to Scratch
1 post

Help? How can i make a character use a sword against a Sprite?

I need a lot of help! I need to make it so when you touch the sword you can use it and i need to find out how to strike with it. hope you can help me

How to make a sword fighting game on scratch

deck26

How to make a sword fighting game on scratch
Scratcher
1000+ posts

Help? How can i make a character use a sword against a Sprite?

erc122potter wrote:

I need a lot of help! I need to make it so when you touch the sword you can use it and i need to find out how to strike with it. hope you can help me
How to make a sword fighting game on scratch

Create your own new topic rather than necroposting please and share the project.

5Proll

How to make a sword fighting game on scratch
Scratcher
1 post

Help? How can i make a character use a sword against a Sprite?

i can not turn my sword horizontal way

  • Discussion Forums
  • » Help with Scripts
  • » Help? How can i make a character use a sword against a Sprite?

What is the easiest game to create a Scratch?

Maze Game. Maze games are not too difficult to make on Scratch, which is why they are great for beginners! In a maze game, the Sprite must navigate a maze, or world, by dodging obstacles and finding the correct path. You can even program different levels to make your game more interesting!

How do you make a game on Scratch?

How to make a game on Scratch.
Brainstorm. Before jumping into building, it's important kids think about their game and what they want to accomplish with it. ... .
Add a Backdrop. ... .
Add a Sprite. ... .
Adding Code. ... .
Make the Sprite Move. ... .
Add Difficulty. ... .
Add Sound. ... .
Increase the Score..

Can Scratch be used to create games?

Scratch is the world's largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations.

How do you make a Scratch game for kids?

How do you make a simple game on Scratch?.
Create a free Scratch account. First, go to the Scratch website and create a free account for your child. ... .
Choose a backdrop and sprite. ... .
Make your character move. ... .
Add a second sprite. ... .
You did it!.