View.Set ("graphics:max,max")
var x, y, groundy, layery, jumpup, jumpheight, shotx, shoty, scrollm, test : int
var jumpFlag, dblJumpFlag, dashFlag, shootFlag : boolean := false
var direction : boolean := true
shotx := 0
shoty := 0
scrollm := 0
x := 200
y := 54
jumpup := 20
jumpheight := jumpup
groundy := 50
layery := groundy
test := Font.New ("Verdana:6")
View.Set ("offscreenonly")
var chars : array char of boolean
proc ground
%drawfill (1, groundy + 1, blue, black)
drawline (0, layery, maxx, layery, black)
Draw.DashedLine (50, 0, 50, maxy, drawDot, red)
Draw.DashedLine (maxx - 50, 0, maxx - 50, maxy, drawDot, red)
Draw.DashedLine (100, 0, 100, maxy, drawDot, red)
Draw.DashedLine (maxx - 100, 0, maxx - 100, maxy, drawDot, red)
end ground
proc scroll
if x >= maxx - 100 then
scrollm := scrollm + 3
elsif
x <= 100 then
scrollm := scrollm - 3
end if
if x >= maxx - 50 then
scrollm := scrollm + 15
elsif
x <= 50 then
scrollm := scrollm - 15
end if
%Draws a Background
drawline (1300 - scrollm, layery, 1325 - scrollm, 100, black)
drawline (1325 - scrollm, 100, 1350 - scrollm, layery, black)
drawoval (1400 - scrollm, layery + 500, 50, 50, black)
drawfill (1401 - scrollm, layery + 501, yellow, black)
% Platform Test
end scroll
proc platform1
% Platform Test
drawbox (700 - scrollm, 70 + layery, 800 - scrollm, 80 + layery, black)
if x > 700 - scrollm + 5 and x > 800 - scrollm + 5 then %and y > layery then %and y-4 < groundy then
drawbox (800 - scrollm + 5, 70 + layery, 800 - scrollm - 5 + 20, 80 + layery, red)
groundy := layery
if jumpFlag not= true and dblJumpFlag not = true then
y := layery+4
end if
elsif x < 700 - scrollm + 5 and x < 800 - scrollm + 5 then %and y > layery then %and y-4 < groundy then
drawbox (700 - scrollm + 5 - 20, 70 + layery, 700 - scrollm - 5, 80 + layery, red)
groundy := layery
if jumpFlag not= true and dblJumpFlag not = true then
y := layery+4
end if
elsif x >= 700 - scrollm and x <= 800 - scrollm then %and y > 80 + layery then
drawfill (700 - scrollm + 1, 70 + layery + 1, red, black)
groundy := layery + 80
end if
end platform1
proc platform2
% Platform Test
drawbox (500 - scrollm, 30 + layery, 600 - scrollm, 40 + layery, black)
if x > 500 - scrollm + 5 and x > 600 - scrollm + 5 then %and y > layery then %and y-4 < groundy then
drawbox (600 - scrollm + 5, 30 + layery, 600 - scrollm - 5 + 20, 40 + layery, red)
groundy := layery
elsif x < 500 - scrollm + 5 and x < 600 - scrollm + 5 then %and y > layery then %and y-4 < groundy then
drawbox (500 - scrollm + 5 - 20, 30 + layery, 500 - scrollm - 5, 40 + layery, red)
groundy := layery
elsif x >= 500 - scrollm and x <= 600 - scrollm then %and y > 40 + layery then
drawfill (500 - scrollm + 1, 30 + layery + 1, red, black)
groundy := layery + 40
end if
end platform2
proc jump
if jumpFlag = true then
y += jumpup
jumpup -= 1
if y <= jumpheight then
jumpFlag := false
y := groundy + 4
jumpup := 20
end if
end if
end jump
proc dblJump
if dblJumpFlag = true then
y += jumpup * 2
jumpup -= 1
if y <= jumpheight then
dblJumpFlag := false
y := groundy + 4
jumpup := 20
end if
end if
end dblJump
proc dash
if dashFlag = true then
if direction = true then
x += 40
elsif direction = false then
x -= 40
end if
end if
dashFlag := false
end dash
proc shoot
if shootFlag = true then
shotx := x
shoty := y
if direction = true then
shotx += 10
drawfilloval (shotx, shoty, 4, 2, yellow)
%drawline(shotx, shoty,maxx,shoty,yellow)
Draw.DashedLine (shotx, shoty, maxx, shoty, drawDot, red)
shootFlag := false
elsif direction = false then
shotx -= 10
drawfilloval (shotx, shoty, 4, 2, yellow)
%drawline(shotx, shoty,0,shoty,yellow)
Draw.DashedLine (shotx, shoty, 0, shoty, drawDot, red)
shootFlag := false
end if
if shotx >= maxx and shotx <= 0 then
shootFlag := false
end if
end if
%shootFlag := false
end shoot
proc move
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and jumpFlag = false then
jumpFlag := true
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
direction := true
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
direction := false
end if
if chars (KEY_DOWN_ARROW) then %and y >= groundy + 9 then
%y := y - 5
dashFlag := true
end if
if chars (KEY_CTRL) then
shootFlag := true
end if
if chars (KEY_SHIFT) then
dblJumpFlag := true
end if
end move
loop
scroll
platform1
%platform2
ground
move
dash
dblJump
jump
shoot
drawoval (x, y, 4, 4, red)
delay (10)
View.Update
cls
locate (1, 1)
put jumpFlag, " ", dblJumpFlag, " ", direction, " ", scrollm ..
locate (2, 1)
put x, " x", y, " y", "layery", layery, "groundy", groundy ..
end loop