var gmaxx, gmaxy : int := 1000
setscreen ("graphics:500,500;offscreenonly")
var timer : int := 0
var x, y, dir, speed : real
var chars : array char of boolean
var bullets : int := 0
var size := 30
var bulletx, bullety, bulletdir, bulletvz, bulletz : flexible array 1 .. bullets of real
var explosions : int := 0
var explodex, explodey, explodetime : flexible array 1 .. explosions of real
const bulletdelay := 20
var temp := bulletdelay
var temp1 := 0
var hit, beep : boolean := false
var checkx, checky : real
x := maxx div 2
y := maxy div 2
var grav : real := 0.1
dir := 0
speed := 1
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 gdrawfill (x1 : int, y1 : int, col1 : int, col2 : int)
drawfill (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, col1, col2)
end gdrawfill
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
loop
timer += 1
cls
%delay (1)
Input.KeyDown (chars)
if chars (KEY_LEFT_ARROW) then
dir += 1
elsif chars (KEY_RIGHT_ARROW) then
dir -= 1
end if
if chars (KEY_UP_ARROW) then
checky := y + sind (dir) * speed
checkx := x + cosd (dir) * speed
if checky >= 10 + size and checky <= gmaxy - 10 - size then
y := checky
end if
if checkx >= 10 + size and checkx <= gmaxx - 10 - size then
x := checkx
end if
beep := false
elsif chars (KEY_DOWN_ARROW) then
checky := y - sind (dir) * speed / 4
checkx := x - cosd (dir) * speed / 4
if checky >= 10 + size and checky <= gmaxy - 10 - size then
y := checky
end if
if checkx >= 10 + size and checkx <= gmaxx - 10 - size then
x := checkx
end if
beep := true
else
beep := false
end if
if chars ('a') then
size -= 1
elsif chars ('d') then
size += 1
end if
temp += 1
if chars (KEY_ENTER) and temp >= bulletdelay then
loop
Input.KeyDown (chars)
if temp1 <= 300 then
delay (2)
temp1 += 1
end if
exit when ~chars (KEY_ENTER)
end loop
temp := 0
bullets += 1
new bulletx, bullets
new bullety, bullets
new bulletdir, bullets
new bulletvz, bullets
new bulletz, bullets
bulletx (bullets) := x + cosd (dir) * size
bullety (bullets) := y + sind (dir) * size
bulletdir (bullets) := dir
bulletz (bullets) := 50
bulletvz (bullets) := temp1 / 50
temp1 := 0
end if
%drawoval (x div 1, y div 1, size, size, 7)
gdrawline (round (x + cosd (dir) * size), round (y + sind (dir) * size), round (x + cosd (dir) * (size / 2)), round (y + sind (dir) * (size / 2)), 7)
gdrawfilloval (round (x + cosd (dir) * (size / 2)), round (y + sind (dir) * (size / 2)), size div 5, size div 5, 7)
gdrawfilloval (round (x + cosd (dir) * (size / 2)), round (y + sind (dir) * (size / 2)), size div 10, size div 10, 0)
gdrawfilloval (round (x + cosd (dir) * (size / 2)), round (y + sind (dir) * (size / 2)), size div 40, size div 40, 7)
gdrawfilloval (round (x + cosd (dir - size) * size), round (y + sind (dir - size) * size), 2, 2, 7)
gdrawfilloval (round (x + cosd (dir + size) * size), round (y + sind (dir + size) * size), 2, 2, 7)
gdrawfilloval (round (x - cosd (dir - size) * size), round (y - sind (dir - size) * size), 2, 2, 7)
gdrawfilloval (round (x - cosd (dir + size) * size), round (y - sind (dir + size) * size), 2, 2, 7)
gdrawline (round (x + cosd (dir - size) * size), round (y + sind (dir - size) * size), round (x + cosd (dir + size) * size), round (y + sind (dir + size) * size), 7)
gdrawline (round (x - cosd (dir - size) * size), round (y - sind (dir - size) * size), round (x - cosd (dir + size) * size), round (y - sind (dir + size) * size), 7)
gdrawline (round (x - cosd (dir - size) * size), round (y - sind (dir - size) * size), round (x + cosd (dir + size) * size), round (y + sind (dir + size) * size), 7)
gdrawline (round (x + cosd (dir - size) * size), round (y + sind (dir - size) * size), round (x - cosd (dir + size) * size), round (y - sind (dir + size) * size), 7)
%gdrawfill (x div 1, y div 1, 2, 7)
if beep and timer mod 100 > 50 then
gdrawfilloval (round (x - cosd (dir) * (size / 1.5)), round (y - sind (dir) * (size / 1.5)), size div 10, size div 10, 12)
end if
gdrawbox (10, 10, gmaxx - 10, gmaxy - 10, 7)
for i : 1 .. bullets
bulletx (i) += cosd (bulletdir (i)) * speed * 2
bullety (i) += sind (bulletdir (i)) * speed * 2
bulletz (i) += bulletvz (i)
bulletvz (i) -= grav
gdrawfilloval (bulletx (i) div 1, bullety (i) div 1, bulletz (i) div 50, bulletz (i) div 50, RGB.AddColor (1 - bulletz (i) / 300, 1 - bulletz (i) / 300, 1 -
bulletz (i) / 300))
if bulletx (i) > 20 and bulletx (i) < gmaxx - 20 and bullety (i) > 20 and bullety (i) < gmaxy - 20 and bulletz (i) >= 49 then
else
explosions += 1
new explodex, explosions
new explodey, explosions
new explodetime, explosions
explodex (explosions) := bulletx (i)
explodey (explosions) := bullety (i)
explodetime (explosions) := 30
for k : i .. bullets - 1
bulletx (k) := bulletx (k + 1)
bullety (k) := bullety (k + 1)
bulletdir (k) := bulletdir (k + 1)
bulletz (k) := bulletz (k + 1)
bulletvz (k) := bulletvz (k + 1)
end for
bullets -= 1
end if
end for
for i : 1 .. explosions
explodetime (i) -= 1
gdrawfilloval (explodex (i) div 1, explodey (i) div 1, explodetime (i) div 4 + 7, explodetime (i) div 4 + 7, RGB.AddColor (explodetime (i) / 15, explodetime (i) / 45, 0))
if explodetime (i) <= 0 then
for k : i .. explosions - 1
explodex (k) := explodex (k + 1)
explodey (k) := explodey (k + 1)
explodetime (k) := explodetime (k + 1)
end for
explosions -= 1
end if
end for
View.Update
end loop
|