var gmaxx, gmaxy, gsizex, gsizey : int
gmaxx := 650
gmaxy := 510
gsizex:=300
gsizey:=300
setscreen ("graphics:300;300,nobuttonbar,nocursor,noecho,offscreenonly")
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var exsize, eysize : int
var win, jump, dying, dead := true
var cheats, temp : string
var enemies, ecount := 5
var ecolor : array 1 .. enemies of int
var ex : array 1 .. enemies of real
var ey : array 1 .. enemies of real
var evy, evx : array 1 .. enemies of real
var ejump, edead : array 1 .. enemies of boolean
var coins := 10
var cx : array 1 .. coins of int
var cy : array 1 .. coins of int
var cdead : array 1 .. coins of boolean
var coincount, tempcoincount : int := 0
var mx, my, mb : int
var mlocate, nofalldie, cheatlevel := false
var bgcolor, brickcol, lavacol, doorcol : int
var starx, stary : array 1 .. 100 of int
var starsize : int
var timer : int := 1
const dyingspeed := 10
procedure gdrawline (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
drawline (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawline
procedure gdrawfilloval (x1 : int, y1 : int, xr : int, yr : int, col : int)
drawfilloval (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, xr, yr, col)
end gdrawfilloval
procedure gdrawoval (x1 : int, y1 : int, xr : int, yr : int, col : int)
drawfilloval (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, xr, yr, col)
end gdrawoval
procedure gdrawbox (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
drawbox (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawbox
procedure gdrawfillbox (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
drawfillbox (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawfillbox
procedure gdrawdot (x1 : int, y1 : int,col : int)
drawdot (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1,col)
end gdrawdot
function gwhatdotcolor (x1 : int, y1 : int) : int
var col : int
if round (maxx - x - (maxx div 2)) + x1 > 0 and round (maxx - x - (maxx div 2)) + x1 < maxx and round (maxy - y - (maxy div 2)) + y1 > 0 and round (maxy - y - (maxy div 2)) + y1 < maxy then
col:=whatdotcolor (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
else
col:= brickcol
end if
result col
end gwhatdotcolor
function coinwhatdotcolor (x1 : int, y1 : int) : int
var col : int
if round (maxx - x - (maxx div 2)) + x1 > 0 and round (maxx - x - (maxx div 2)) + x1 < maxx and round (maxy - y - (maxy div 2)) + y1 > 0 and round (maxy - y - (maxy div 2)) + y1 < maxy then
col:=whatdotcolor (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
else
col:= bgcolor
end if
result col
end coinwhatdotcolor
%procedure glocatexy (x1:int,y1:int)
%locatexy (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
%end glocatexy
procedure InitRoom1
timer := 1
grav := 0.3
brickcol := 2
doorcol := 4
lavacol := 12
bgcolor := 7
exsize := 8
eysize := 6
cheatlevel := false
tempcoincount := 0
colorback (bgcolor)
%Enemies' starting positions
ex (1) := 218
ex (2) := 317
ex (3) := 508
ex (4) := 45
ex (5) := 120
ey (1) := 429
ey (2) := 298
ey (3) := 129
ey (4) := 135
ey (5) := 433
%Coin Positions
cx (1) := 525
cy (1) := 490
cx (2) := 483
cy (2) := 472
cx (3) := 207
cy (3) := 385
cx (4) := 442
cy (4) := 457
cx (5) := 23
cy (5) := 198
cx (6) := 83
cy (6) := 482
cx (7) := 619
cy (7) := 115
cx (8) := 255
cy (8) := 213
cx (9) := 199
cy (9) := 185
cx (10) := 146
cy (10) := 162
for i : 1 .. coins
cdead (i) := false
end for
ecount := 5
x := xsize + 20 %Player's starting position
y := ysize + 100 %Player's starting position
for i : 1 .. enemies %Initialize enemie's stuff
edead (i) := false
ejump (i) := false
evy (i) := 0
if i mod 2 = 0 then
ecolor (i) := 1
evx (i) := 1.5
else
ecolor (i) := 0
evx (i) := 1.1
end if
end for
for i : 1 .. 100
starx (i) := Rand.Int (0, gmaxx)
stary (i) := Rand.Int (0, gmaxy)
end for
end InitRoom1
procedure InitRoom2
timer := 0
grav := 0.3
brickcol := 15
doorcol := 4
lavacol := 112
bgcolor := 7
exsize := 8
eysize := 6
cheatlevel := false
tempcoincount := 0
colorback (bgcolor)
%Enemies' starting positions
ex (1) := 406
ex (2) := 575
ex (3) := 125
ex (4) := 212
ex (5) := 254
ey (1) := 353
ey (2) := 388
ey (3) := 433
ey (4) := 246
ey (5) := 171
ecount := 5
%Coin Positions
cx (1) := 166
cy (1) := 87
cx (2) := 114
cy (2) := 144
cx (3) := 163
cy (3) := 197
cx (4) := 202
cy (4) := 197
cx (5) := 561
cy (5) := 282
cx (6) := 424
cy (6) := 304
cx (7) := 144
cy (7) := 292
cx (8) := 167
cy (8) := 405
cx (9) := 305
cy (9) := 404
cx (10) := 541
cy (10) := 327
for i : 1 .. coins
cdead (i) := false
end for
x := xsize + 20 %Player's starting position
y := ysize + 50 %Player's starting position
for i : 1 .. enemies %Initialize enemie's stuff
edead (i) := false
ejump (i) := false
evy (i) := 0
if i mod 2 = 0 then
ecolor (i) := 1
evx (i) := 1.5
else
ecolor (i) := 0
evx (i) := 1.1
end if
end for
for i : 1 .. 100
starx (i) := Rand.Int (0, gmaxx)
stary (i) := Rand.Int (0, gmaxy)
end for
end InitRoom2
procedure DrawRoom1
if timer < 3000 then
timer += 1
end if
bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
brickcol := RGB.AddColor (timer / 10000, 0.3 + timer / 10000, timer / 10000)
colorback (bgcolor)
cls
for i : 1 .. 100
randint (starsize, 0, 1)
gdrawfilloval (starx (i) - timer div 110, stary (i) - timer div 60, starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
end for
for i : 1 .. 25
gdrawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
end for
for i : 1 .. coins
if ~cdead (i) then
gdrawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
end if
end for
gdrawfillbox (-gmaxx div 2, -gmaxy div 2,0,gmaxy + gmaxy div 2,brickcol)
gdrawfillbox (gmaxx + gmaxx div 2, -gmaxy div 2,gmaxx,gmaxy + gmaxy div 2,brickcol)
gdrawfillbox (-gmaxx div 2, -gmaxy div 2,gmaxx div 2 + gmaxx, 0,brickcol)
gdrawfillbox (-gmaxx div 2, gmaxy div 2+gmaxy,gmaxx div 2 + gmaxx, gmaxy,brickcol)
gdrawfillbox (648, 97, -29, -22, brickcol)
gdrawfilloval (277, 97, 107, -19, lavacol)
gdrawfillbox (128, 139, 168, 122, brickcol)
gdrawfillbox (186, 165, 218, 146, brickcol)
gdrawfillbox (243, 192, 270, 176, brickcol)
%gdrawfillbox (354, 161, 382, 140, brickcol)
gdrawfillbox (398, 194, 437, 173, brickcol)
gdrawfillbox (455, 236, 530, 216, brickcol)
gdrawfillbox (545, 275, 605, 255, brickcol)
gdrawfillbox (399, 110, 383, 89, brickcol)
gdrawfillbox (172, 112, 151, 84, brickcol)
gdrawfillbox (519, 311, 437, 296, brickcol)
gdrawfillbox (387, 276, 200, 263, brickcol)
gdrawfillbox (387, 290, 373, 276, brickcol)
gdrawfillbox (209, 293, 199, 270, brickcol)
gdrawfilloval (289, 274, -17, -4, lavacol)
gdrawfilloval (237, 276, -14, -2, lavacol)
gdrawfilloval (346, 275, -13, -2, lavacol)
gdrawfillbox (154, 316, 116, 305, brickcol)
gdrawfillbox (56, 345, 98, 331, brickcol)
gdrawfillbox (16, 384, 60, 366, brickcol)
gdrawfillbox (76, 413, 252, 401, brickcol)
gdrawfillbox (252, 432, 235, 401, brickcol)
gdrawfillbox (89, 433, 76, 402, brickcol)
gdrawfillbox (153, 369, 211, 355, brickcol)
gdrawfilloval (180, 368, 21, -6, lavacol)
gdrawfillbox (159, 429, 168, 411, brickcol)
gdrawfillbox (193, 428, 206, 409, brickcol)
gdrawfillbox (295, 420, 339, 403, brickcol)
gdrawfillbox (373, 418, 408, 401, brickcol)
gdrawfillbox (428, 440, 459, 426, brickcol)
gdrawfillbox (470, 456, 499, 442, brickcol)
gdrawfillbox (506, 477, 545, 463, brickcol)
gdrawfillbox (572, 478, 654, 460, brickcol)
gdrawfillbox (626, 478, 656, 526, doorcol)
gdrawfilloval (633, 496, 2, 2, yellow)
gdrawfillbox (169, 421, 192, 388, bgcolor)
gdrawfillbox (187, 409, 195, 379, bgcolor)
gdrawfillbox (199, 376, 158, 391, bgcolor)
gdrawfillbox (634, 96, 649, 463, brickcol)
gdrawfillbox (12, 95, -6, 527, brickcol)
end DrawRoom1
procedure DrawRoom2
if timer < 3000 then
timer += 1
end if
bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
brickcol := RGB.AddColor (0.3 + timer / 10000, 0.3 + timer / 10000, 0.3 + timer / 10000)
colorback (bgcolor)
cls
for i : 1 .. 100
randint (starsize, 0, 1)
gdrawfilloval (starx (i), stary (i), starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
end for
for i : 1 .. 25
gdrawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
end for
for i : 1 .. coins
if ~cdead (i) then
gdrawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
end if
end for
gdrawfillbox (-gmaxx div 2, -gmaxy div 2,0,gmaxy + gmaxy div 2,brickcol)
gdrawfillbox (gmaxx + gmaxx div 2, -gmaxy div 2,gmaxx,gmaxy + gmaxy div 2,brickcol)
gdrawfillbox (-gmaxx div 2, -gmaxy div 2,gmaxx div 2 + gmaxx, 0,brickcol)
gdrawfillbox (-gmaxx div 2, gmaxy div 2+gmaxy,gmaxx div 2 + gmaxx, gmaxy,brickcol)
gdrawfillbox (648, 25, 0, 0, lavacol)
gdrawfillbox (25, 508, -2, -5, brickcol)
gdrawfillbox (622, 508, 677, -19, brickcol)
gdrawfillbox (25, 43, 91, -6, brickcol)
gdrawfillbox (140, 71, 194, 46, brickcol)
gdrawfillbox (92, 125, 137, 101, brickcol)
gdrawfillbox (69, 152, 16, 179, brickcol)
gdrawfillbox (272, 207, 69, 232, brickcol)
gdrawfillbox (234, 162, 266, 136, brickcol)
gdrawfillbox (296, 121, 415, 93, brickcol)
gdrawfillbox (139, 188, 224, 171, brickcol)
gdrawfillbox (139, 185, 140, 179, brickcol)
gdrawfillbox (139, 186, 151, 211, brickcol)
gdrawfillbox (295, 121, 266, 93, brickcol)
gdrawfillbox (399, 137, 414, 119, brickcol)
gdrawfillbox (141, 270, 150, 232, brickcol)
gdrawfillbox (258, 249, 270, 230, brickcol)
gdrawfilloval (145, 270, 4, -4, lavacol)
gdrawfillbox (255, 137, 269, 118, brickcol)
gdrawfilloval (332, 120, 40, -2, lavacol)
%gdrawfilloval (433, 96, 22, -23, brickcol)
%gdrawfilloval (490, 84, 25, -19, brickcol)
gdrawfilloval (529, 140, 22, -17, brickcol)
gdrawfilloval (480, 181, 11, -7, brickcol)
gdrawfilloval (510, 228, 21, -14, brickcol)
gdrawfilloval (561, 259, 20, -13, brickcol)
gdrawfilloval (503, 323, 10, -10, brickcol)
gdrawfilloval (480, 284, 10, -10, brickcol)
gdrawfilloval (543, 303, 8, -9, brickcol)
gdrawfillbox (522, 372, 622, 345, brickcol)
gdrawfillbox (273, 411, 477, 427, brickcol)
gdrawfillbox (333, 396, 142, 381, brickcol)
gdrawfillbox (41, 430, 190, 417, brickcol)
gdrawfillbox (318, 410, 330, 395, brickcol)
gdrawfillbox (139, 417, 156, 393, brickcol)
gdrawfillbox (521, 367, 529, 388, brickcol)
gdrawfilloval (399, 347, 75, 23, brickcol)
gdrawfillbox (452, 339, 350, 388, bgcolor)
gdrawfillbox (296, 292, 424, 258, brickcol)
gdrawfillbox (95, 473, 624, 485, brickcol)
gdrawfillbox (605, 485, 625, 510, doorcol)
gdrawfilloval (609, 500, 2, 2, yellow)
gdrawfilloval (358, 292, 60, 8, lavacol)
end DrawRoom2
for level : 1 .. 2
loop
if level = 1 then
InitRoom1
elsif level = 2 then
InitRoom2
end if
vx := 0
vy := 0
grav := 0.3
dying := false
dead := false
win := false
loop
delay (15)
cls
Input.KeyDown (chars)
if chars ('p') then
loop
exit when hasch
end loop
end if
if chars (KEY_CTRL) then
get cheats
if cheats = "gravity" or cheats = "grav" then
get grav
end if
if cheats = "locate" then
if ~mlocate then
mlocate := true
else
mlocate := false
end if
end if
if cheats = "locatexy" then
get x, y
end if
if cheats = "killall" then
for i : 1 .. enemies
edead (i) := true
ecount -= 1
end for
end if
if cheats = "nextlevel" then
cheatlevel := true
end if
if cheats = "color" then
get temp
if temp = "background" then
get bgcolor
colorback (bgcolor)
cls
elsif temp = "brick" then
get brickcol
elsif temp = "door" then
get doorcol
elsif temp = "lava" then
get lavacol
end if
end if
if cheats = "nofalldie" then
if ~nofalldie then
nofalldie := true
else
nofalldie := false
end if
end if
if cheats = "restart" then
if level = 1 then
InitRoom1
elsif level = 2 then
InitRoom2
end if
end if
if cheats = "speedup" then
get timer
end if
end if
if chars (KEY_UP_ARROW) and not jump then
vy := 5
jump := true
elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
ysize := 7
if vy > 0 then
vy *= -0.5
end if
elsif chars (KEY_DOWN_ARROW) and jump then
if vy > 0 then
vy *= -1
end if
ysize := 6
elsif chars (KEY_DOWN_ARROW) and not jump then
ysize := 6
else
ysize := 10
end if
if chars (KEY_LEFT_ARROW) then
vx := -3
elsif chars (KEY_RIGHT_ARROW) then
vx := 3
else
vx := 0
end if
if jump then
y += vy
vy -= grav
else
vy := 0
end if
if ~nofalldie and vy < -dyingspeed then
dying := true
end if
ysize += round (vy / 2)
x += vx
%ENEMY STUFF
for i : 1 .. enemies
if not edead (i) then
ex (i) += evx (i)
if ejump (i) then
ey (i) += evy (i)
evy (i) -= grav
else
evy (i) := 0
end if
end if
end for
if level = 1 then
DrawRoom1
elsif level = 2 then
DrawRoom2
end if
%gdrawfillbox (0, gmaxy, maxx, maxy, brickcol)
%if coincount < coins then
% gdrawfilloval (gmaxx - 15, gmaxy + 8, timer mod 4, 5, red)
% glocatexy (gmaxx - 5, gmaxy + 8)
% color (0)
% put coincount
%else
% gdrawfilloval (gmaxx - 35, gmaxy + 8, timer mod 4, 5, red)
% %locatexy (maxx - 15, gmaxy + 8)
% color (0)
% put coincount
%end if
for i : 1 .. enemies
if not edead (i) then
for k : 1 .. 5
gdrawfilloval (round (ex (i)), round (ey (i)), exsize - k, eysize - k, RGB.AddColor (k / 5 * ecolor (i), k / 5, k / 5 * ecolor (i)))
end for
gdrawfilloval (round (ex (i) + (evx (i)) * 3), round (ey (i)), 1, 1, 7)
gdrawline (round (ex (i) + (evx (i)) * -6), round (ey (i)) - 2, round (ex (i) + (evx (i)) * -9), round (ey (i)) - 2, 7)
end if
end for
for i : 0 .. 5
gdrawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
end for
gdrawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
gdrawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
gdrawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
gdrawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
gdrawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 4)
%Draw.FillOval (round(x+vx), round (y+vy+ysize), 5,5,0)
if gwhatdotcolor (round (x), round (y) + ysize + 1) = brickcol and gwhatdotcolor (round (x), round (y) - ysize - 1) ~= brickcol then
y -= 1
elsif gwhatdotcolor (round (x), round (y) + ysize + 1) = brickcol and gwhatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
y += 1
end if
if gwhatdotcolor (round (x), round (y + vy - ysize - 1)) = brickcol then
jump := false
elsif gwhatdotcolor (round (x), round (y + vy - ysize - 1)) = bgcolor then
jump := true
end if
if gwhatdotcolor (round (x), round (y + vy + ysize + 1)) = brickcol then
vy := -0.5
elsif ~chars (KEY_DOWN_ARROW) and gwhatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
y += 2
end if
if chars (KEY_LEFT_ARROW) and gwhatdotcolor (round (x) - xsize - 1, round (y)) = brickcol then
x -= vx
end if
if chars (KEY_RIGHT_ARROW) and gwhatdotcolor (round (x) + xsize + 1, round (y)) = brickcol then
x -= vx
end if
if gwhatdotcolor (round (x), round (y) - ysize - 1) ~= bgcolor and dying then
dead := true
end if
if gwhatdotcolor (round (x), round (y) - ysize - 1) = lavacol then
dead := true
end if
%ENEMY STUFF
for i : 1 .. enemies
if not edead (i) then
if gwhatdotcolor (round (ex (i)), round (ey (i)) - eysize - 1) = bgcolor then
ejump (i) := true
else
ejump (i) := false
end if
if gwhatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = brickcol or gwhatdotcolor (round (ex (i)) + 9, round (ey (i))) = brickcol or gwhatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = yellow or gwhatdotcolor (round (ex (i)) + 9, round (ey (i))) = yellow then
evx (i) *= -1
end if
if sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy < -1.3 then
edead (i) := true
ecount -= 1
if chars (KEY_UP_ARROW) then
vy := 7
else
vy := 4
end if
elsif sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy > -1.3 then
dead := true
end if
end if
end for
%COIN STUFF
for i : 1 .. coins
if coinwhatdotcolor (cx (i), cy (i) - 6) ~= bgcolor and ~cdead (i) then
cdead (i) := true
tempcoincount += 1
coincount += 1
end if
end for
if ecount = 0 and gwhatdotcolor (round (x) + xsize + 4, round (y)) = doorcol then
win := true
elsif gwhatdotcolor (round (x) + xsize + 4, round (y)) = 4 and ecount ~= 0 then
for i : 1 .. 10
cls
colorback (RGB.AddColor (i / 10, i / 10, 0))
delay (100)
View.Update
end for
colorback (bgcolor)
x := xsize + 20 %Player's starting position
y := ysize + 100 %Player's starting position
end if
if mlocate then
mousewhere (mx, my, mb)
if mb = 1 then
x := mx
y := my
vy := 0
color (0)
locate (1, 1)
put "(", mx, ",", my, ")"
end if
end if
View.Update
exit when dead or win or cheatlevel
end loop
if dead then
for i : 1 .. 10
cls
colorback (RGB.AddColor (i / 10, 0, 0))
delay (100)
View.Update
end for
coincount -= tempcoincount
else
for i : 1 .. 10
cls
colorback (RGB.AddColor (0, i / 10, 0))
delay (100)
View.Update
end for
end if
colorback (0)
exit when not dead
end loop
end for
|