' Soldier -- By Krueg -- June 2012
' ARROWS to move
' SPACE to jump
' ESCAPE to quit
' Credit goes to GoToLoop and litedev for helping to make this program better.
' Thank You for your suggestions!
gw = 640 'Window width
gh = 480 'Window Height
gh32 = gh - 32 'Top of the brick line on the bottom
md = 1 'Man direction 1=left 2=right
z = 1 'Man's slide number for walking animation
IncX = 2 'Background speed X
IncY = 1 'Background speed Y, no real use yet
ManX = gw/2-16 'Man's position X, center on screen
ManY = gh32-64 'Man's position Y
IncZ = .1 'Walking appearance speed
Jp = 8 'Jump power
IncJy = .2 'Jump Gravity
If jump Then
ManY = ManY + Jy 'Adjust ManY for the jump
If Jy < Jp Then 'The man will only fall this fast
Jy = Jy + IncJy 'Add for gravity
EndIf
EndIf
If ManY > gh32-64 Then 'The man landed the brick line
jump = ""
ManY = gh32-64 'Put the man at the right height
EndIf
x = x + dx
y = y + dy
z = z + dz
If x < -32 Then
x = x + 32
ElseIf x > 0 Then
x = x -32
EndIf
If y < -32 Then
y = y + 32
ElseIf y > 0 Then
y = y -32
EndIf
If mdlast <> md Or mslast <> zInt Or jump Then
Shapes.Move(man[md][zInt],ManX,ManY)
Shapes.ShowShape(man[md][zInt])
Shapes.HideShape(man[mdlast][mslast])
EndIf
mdlast = md
mslast = zInt
If debug Then
DebugData()
EndIf
Program.Delay(Delay)
EndWhile
Sub OnKeyDown
key = GraphicsWindow.LastKey
If key = "Left" Then
dx = IncX
dz = IncZ
md = 1
ElseIf key = "Right" Then
dx = -IncX
dz = IncZ
md = 2
ElseIf key = "Space" and jump <> "True" Then
jump = "True"
Jy = -Jp
ElseIf key = "Up" Then
dy = IncY
ElseIf key = "Down" Then
dy = -IncY
ElseIf key = "Escape" Then
Program.End()
EndIf
EndSub
Sub OnKeyUp
key = GraphicsWindow.LastKey
If key = "Right" Or key = "Left" Then
dx = ""
dz = ""
ElseIf key = "Up" Or key = "Down" Then
dy = ""
EndIf