var screen : int
screen := Window.Open ("graphics:700;800,nobuttonbar")
View.Set ("title:GAME;offscreenonly")
var x : int := 673
var y : int := 60
var jv : int := 15
var key : array char of boolean
var back : int := Pic.FileNew ("back.bmp")
var fall, jump, horizontal : boolean := false
var Possible_Jump : boolean := true
var grav : real := 1
var del : int
var x1,y1,x2,y2 : int
Pic.Draw (back, 0, 0, picMerge)
View.UpdateArea (0, 0, maxx, maxy)
loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INITIALIZE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
del := 2
Possible_Jump := true
horizontal := false
Pic.Draw (back, 0, 0, picMerge)
Input.KeyDown (key)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MOVE TO THE RIGHT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if key ('d') and whatdotcolour (x + 5, y - 5) ~= 7 and whatdotcolour (x + 5, y) ~= 7 and jump = false and fall = false then
x += 2
horizontal := true
for a : 1 .. 8
if whatdotcolour (x, y - a - 5) = 7 then
y -= a
exit
end if
end for
elsif key ('d') and whatdotcolour (x + 5, y + 5) ~= 7 and jump = false and fall = false then
x += 2
horizontal := true
for decreasing a : 8 .. 1
if whatdotcolour (x, (y + a) - 5) = 7 then
y += a
exit
end if
end for
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MOVE TO THE LEFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if key ('a') and whatdotcolour (x - 5, y - 5) ~= 7 and whatdotcolour (x - 5, y) ~= 7 and jump = false and fall = false then
x -= 2
put 1 ..
horizontal := true
for a : 1 .. 8
if whatdotcolour (x, y - a - 5) = 7 then
y -= a
exit
end if
end for
elsif key ('a') and whatdotcolour (x - 5, y + 5) ~= 7 and whatdotcolour (x - 5, y - 5) = 7 and jump = false and fall = false then
x -= 2
put 2 ..
horizontal := true
for decreasing a : 8 .. 1
if whatdotcolour (x, (y + a) - 5) = 7 then
y += a
exit
end if
end for
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% POSSIBLE JUMP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for a : 1 .. 10
if whatdotcolour (x, y + 5 + a) = 7 then
Possible_Jump := false
end if
end for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% JUMP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if key ('w') and whatdotcolour (x, y - 5) = 7 and jump = false and whatdotcolour (x, y + 5) ~= 7 and Possible_Jump then
if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
x += 3
end if
if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
x -= 3
put 3 ..
end if
y += jv
jump := true
del := 16
for a : y - jv .. y
if whatdotcolour (x, a + 5) = 7 then
jump := false
jv := 15
y := a
exit
end if
end for
elsif jump = true and whatdotcolour (x, y + 5) ~= 7 then
if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
x += 3
end if
if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
x -= 3
put 4 ..
end if
y += jv
for a : y - jv .. y
if whatdotcolour (x, a + 5) = 7 then
jump := false
jv := 15
y := a
exit
end if
end for
jv -= 1
del := 16
if jv < 2 then
jump := false
jv := 15
end if
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FALL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if whatdotcolour (x, y - 5) ~= 7 and fall = false then
grav := 1
y -= grav div 1
if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
x += 3
end if
if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
x -= 3
put 5 ..
end if
grav += 0.5
fall := true
del := 16
elsif fall = true then
y -= grav div 1
for decreasing a : y + grav div 1 .. y
if whatdotcolour (x, a - 5) = 7 then
fall := false
grav := 1
y := a
exit
end if
end for
if grav < 12 then
grav += 0.5
else
grav := 13
end if
if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
x += 3
end if
if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
x -= 3
put 6 ..
end if
del := 16
end if
if whatdotcolour (x, y - 5) = 7 then
grav := 1
fall := false
jump := false
jv := 15
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VARIABLE TRACE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
exit when whatdotcolour (x, y) = 145
drawfilloval (x, y, 3, 3, 3)
locate (2, 1)
put "fall : ", fall, " ", "jump : ", jump, " ", " X/Y ", x, " ", y
put "jumpvalue : ", jv, " ", "gravity : ", grav
put "Dot colour for positive slopes: ", whatdotcolour (x + 5, y - 5), " ", whatdotcolour (x + 5, y + 5)
put "Dot colour for negative slopes: ", whatdotcolour (x - 5, y - 5), " ", whatdotcolour (x - 5, y + 5)
View.UpdateArea (0, 0, maxx, maxy)
delay (del)
cls
end loop
|