# Health Points • ### Question

•   ``` 'guy being kicked/punched has 100 HP and if it reaches 0 HP he dies.HP = 100
If HP = 0 then
Shapes.HideShape(oneone)
endif'A is a punchHow do I make it so that if I touch the stickfigure with any part of the arm or leg while my figure is kicking or punching he loses 10 HP.I know that HP = HP - 10 but what do I do before that?If Key["A"] and Direction = "R" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (punch1)
Shapes.Move(punch1,x,y - 175)
Program.Delay(100)
Shapes.HideShape(punch1)
endif```

` `

```GraphicsWindow.KeyDown = KeyDown
GraphicsWindow.KeyUp = KeyUp
GraphicsWindow.CanResize = "False"

Timer.Tick = WalkAni 'how often walking animation occurs
Timer.Interval = 100

HP = 100

Shapes.Move(oneone,600,377)

If HP = 0 then
Shapes.HideShape(oneone)
endif

Gravity = 1500
Speed = 1
CurLev = 1

Direction = "R"

'walking animations

'punch,kick,and guard moves

Shapes.HideShape(punch1)
Shapes.HideShape(punch2)
Shapes.HideShape(kick1)
Shapes.HideShape(Kick2)
Shapes.HideShape(Guard1)
Shapes.HideShape(Guard2)

'p = Block
's = start location
'd = death zone
'e = exit (for level to the next)

'each level is a layer
Level =  "p__s__ppppppppppppppppppppppppppppp_____p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level =  "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "p_______________________________________p"
Level = "ppppppppppppppppppppppppppppppppppppppppp"

SetupLev()

'controls
While 1 = 1
Program.Delay(5)

If Key["A"] and Direction = "R" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (punch1)
Shapes.Move(punch1,x,y - 175)
Program.Delay(100)
Shapes.HideShape(punch1)
endif

If Key["A"] and Direction = "L" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (punch2)
Shapes.Move(punch2,x-55,y - 175)
Program.Delay(100)
Shapes.HideShape(punch2)
endif

If Key["S"] and Direction = "R" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (Guard1)
Shapes.Move(guard1,x-5,y - 173)
Program.Delay(100)
Shapes.HideShape(guard1)
endif

If Key["S"] and Direction = "L" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (guard2)
Shapes.Move(guard2,x-15,y - 175)
Program.Delay(100)
Shapes.HideShape(guard2)
endif

If Key["D"] and Direction = "R" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (kick1)
Shapes.Move(kick1,x,y - 175)
Program.Delay(100)
Shapes.HideShape(kick1)
endif

If Key["D"] and Direction = "L" Then
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
Shapes.HideShape(Walk["S" + Direction][StandAnimNum])
Shapes.HideShape(Walk[Direction][Animationnum])
Shapes.ShowShape (kick2)
Shapes.Move(kick2,x-55,y - 175)
Program.Delay(100)
Shapes.HideShape(kick2)
endif

If Key["Right"] Then
Direction = "R"
If Canmove["Right"] Then
X = X + Speed
EndIf
EndIf

If Key["Left"] Then
Direction = "L"
If Canmove["Left"] Then
X = X - Speed
EndIf
EndIf

If Key["Up"] Then
IsJumping = "True"
Canmove["Down"] = "True"
EndIf

If Key["Left"] <> "True" And Key["Right"] <> "True" Then
Standing = "True"
Else
Standing = "False"
StandAnimNum = 0
EndIf

If Canmove["Down"] Then
Time = Time + .005
If IsJumping Then
Velocity = 50
Else
Velocity = 0
EndIf

Vv = Math.GetDegrees(Math.Sin(-90)) * Velocity / 5
y = Vv * Time + (Math.Power(Time,2) * (Gravity / 2)) + LastJumpPos

EndIf

If Text.GetSubText(Level[CurLev][Math.Round((Y + 5) / 30) + 1], Math.Round((X) / 30) + 1,1) = "p" Then
Canmove["Down"] = "False"
Time = 0
LastJumpPos = Y
IsJumping = "False"
Else
Canmove["Down"] = "True"
EndIf

If Text.GetSubText(Level[CurLev][Math.Round(Y / 30) + 1], Math.Round((X) / 30) + 1,1) = "e" Or Text.GetSubText(Level[CurLev][Math.Round((Y - 30)  / 30) + 1], Math.Round((X) / 30) + 1,1) = "e" Then
CurLev = CurLev + 1
SetupLev()
EndIf

If Text.GetSubText(Level[CurLev][Math.Round(Y / 30) + 1], Math.Round((X+9) / 30) + 1,1) = "p" Or Text.GetSubText(Level[CurLev][Math.Round((Y - 30)  / 30) + 1], Math.Round((X+9) / 30) + 1,1) = "p" Then
Canmove["Right"] = "False"
Else
Canmove["Right"] = "True"
EndIf

If Text.GetSubText(Level[CurLev][Math.Round(Y / 30) + 1], Math.Round((X-13) / 30) + 1,1) = "p" Or Text.GetSubText(Level[CurLev][Math.Round((Y-30) / 30) + 1], Math.Round((X-13) / 30) + 1,1) = "p" Then
Canmove["Left"] = "False"
Else
Canmove["Left"] = "True"
EndIf

For t = 1 To 4
Shapes.Move(Walk["R"][t],X,Y - 175)
Shapes.Move(Walk["L"][t],X,Y - 175)
Shapes.Move(Walk["SL"][t],X,Y - 175)
Shapes.Move(Walk["SR"][t],X,Y - 175)
EndFor

EndWhile

Sub Keydown
Lastkey = GraphicsWindow.LastKey
Key[LastKey] = "True"
EndSub
Sub KeyUp
Lastkey = GraphicsWindow.LastKey
Key[LastKey] = "False"
EndSub

Sub WalkAni
Animationnum = Animationnum + 1
If Animationnum >= 4 Then
Animationnum = 1
EndIf
For i = 1 To 43
Shapes.HideShape(Walk["R"][i])
Shapes.HideShape(Walk["L"][i])
Shapes.HideShape(Walk["SR"][i])
Shapes.HideShape(Walk["SL"][i])
EndFor
If Standing = "False" Then
Shapes.ShowShape(Walk[Direction][Animationnum])
Else
If StandAnimNum < 2 Then
StandAnimNum = StandAnimNum + 1
EndIf
Shapes.ShowShape(Walk["S" + Direction][StandAnimNum])
EndIf
EndSub

Sub SetupLev
bc = GraphicsWindow.BrushColor
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(0,0,GraphicsWindow.Width,GraphicsWindow.Height)
GraphicsWindow.BrushColor = bc
GraphicsWindow.DrawResizedImage(Program.Directory + "/Background.jpg",0,0,1620,800)

For xtile = 1 To 50
For ytile = 1 To 30
If Text.GetSubText(Level[CurLev][ytile],xtile,1) = "p" Then
GraphicsWindow.DrawImage(Program.Directory + "/Brick.png", (xtile * 30) -30, (ytile * 30) - 30)
EndIf

If Text.GetSubText(Level[CurLev][ytile],xtile,1) = "s" Then
x = (xtile * 30)
y =  (ytile * 30)
LastJumpPos = y
IsJumping = "False"
Velocity = 0
Time = 0
EndIf
EndFor
EndFor
EndSub```

• Edited by Monday, September 1, 2014 11:17 PM
Monday, September 1, 2014 11:15 PM

• It can be done in Small Basic or any other language that can do graphics.  Also the logic will be similar and frankly easier in Small Basic than almost any other I can think of (i.e. you will have to work out and code the logic for a hit).

Perhaps you could consider Scratch as the simplest graphical type programming environment which may come closest.

I did add this (its a nice programming challenge well suited to Small Basic) as a suggestion for this month's challenges and do expect some good solutions to this so you may want to check back for these.

It is not easy to answer your question, which is why I expect there are no replies for this post yet, so I will try.

It is hard to do is take 300+ lines of code with images we don't have, create images, modify it to work (rewrite some or all of it making all sorts of coding and design decisions) and at the same time explain how the modified code did what you want, assuming we understood exactly what this is.  This is not practical or really helpful so I am not doing this.

'How do I make it so that if I touch the stick figure with any part of the arm or leg while my figure is kicking or punching he loses 10 HP.'  The best is probably to make some simplifying assumptions about what proximity is a hit.  i.e. the left player doing a punch has an X coordinate sufficiently close to the X coordinate of player 2.

So during the attack check the location of the 2 players and decide if they are close enough for a score.

There are lots of different approaches to writing a stick man fighting game - I would do it differently to you and some-one else different again - there isn't really a right and wrong, but with experience some approaches will turn out to be better than others - this is what learning is about - we are all learning.

Good luck.

• Proposed as answer by Thursday, September 4, 2014 1:21 AM
• Marked as answer by Sunday, September 7, 2014 2:35 PM
Tuesday, September 2, 2014 9:35 PM
• Part of the problem at least is this line

`If 550 < x > 650 thenThis should beIf (x > 550 And x < 650) Then`

What you have make sense to me and you, but the syntax is not understood by Small Basic, each condition must evaluate to true or false and then combined if you want with And or Or keywords.  A condition is two values (can be any small basic variable or literal) compared with =, <, >, <=, >= or <>.

• Proposed as answer by Thursday, September 4, 2014 1:21 AM
• Marked as answer by Sunday, September 7, 2014 2:36 PM
Wednesday, September 3, 2014 5:25 PM

### All replies

• I can assume you can't make a fighting game on Small Basic.

Does anyone know a free computer language which I can use to make a fighting game?

Tuesday, September 2, 2014 8:36 PM
• It can be done in Small Basic or any other language that can do graphics.  Also the logic will be similar and frankly easier in Small Basic than almost any other I can think of (i.e. you will have to work out and code the logic for a hit).

Perhaps you could consider Scratch as the simplest graphical type programming environment which may come closest.

I did add this (its a nice programming challenge well suited to Small Basic) as a suggestion for this month's challenges and do expect some good solutions to this so you may want to check back for these.

It is not easy to answer your question, which is why I expect there are no replies for this post yet, so I will try.

It is hard to do is take 300+ lines of code with images we don't have, create images, modify it to work (rewrite some or all of it making all sorts of coding and design decisions) and at the same time explain how the modified code did what you want, assuming we understood exactly what this is.  This is not practical or really helpful so I am not doing this.

'How do I make it so that if I touch the stick figure with any part of the arm or leg while my figure is kicking or punching he loses 10 HP.'  The best is probably to make some simplifying assumptions about what proximity is a hit.  i.e. the left player doing a punch has an X coordinate sufficiently close to the X coordinate of player 2.

So during the attack check the location of the 2 players and decide if they are close enough for a score.

There are lots of different approaches to writing a stick man fighting game - I would do it differently to you and some-one else different again - there isn't really a right and wrong, but with experience some approaches will turn out to be better than others - this is what learning is about - we are all learning.

Good luck.

• Proposed as answer by Thursday, September 4, 2014 1:21 AM
• Marked as answer by Sunday, September 7, 2014 2:35 PM
Tuesday, September 2, 2014 9:35 PM
• The best is probably to make some simplifying assumptions about what proximity is a hit.  i.e. the left player doing a punch has an X coordinate sufficiently close to the X coordinate of player 2.

So during the attack check the location of the 2 players and decide if they are close enough for a score.

Yeah I am trying to do that and I didn't know how to explain it. Just can't figure out how to do it.

https://www.mediafire.com/folder/76c1k2w6tg3di/ST

pictures

when my guy moves into the x range the other guy doesnt disappear? ```HP = 100

Shapes.Move(oneone,600,377)

If 550 < x > 650 then
HP = HP - 100
endif

If HP = 0 then
Shapes.HideShape(oneone)
endif```

• Edited by Wednesday, September 3, 2014 3:59 PM
Tuesday, September 2, 2014 11:44 PM
• Part of the problem at least is this line

`If 550 < x > 650 thenThis should beIf (x > 550 And x < 650) Then`

What you have make sense to me and you, but the syntax is not understood by Small Basic, each condition must evaluate to true or false and then combined if you want with And or Or keywords.  A condition is two values (can be any small basic variable or literal) compared with =, <, >, <=, >= or <>.

• Proposed as answer by Thursday, September 4, 2014 1:21 AM
• Marked as answer by Sunday, September 7, 2014 2:36 PM
Wednesday, September 3, 2014 5:25 PM
• The thing contains essential plant add-ins alongside urgent vitamins which are need as to amend muscles progression. The specific development hormone get over it a fantastic accelerating period when this alternative ascensions into action. Logically analyzed notwithstanding created it can be 100% danger free system notwithstanding considered an incredible supplier to revel in reliably.

• 