View.Set ("graphics:600;450,position:center;center,nobuttonbar")
const heatshot := 12
const speedshot := 5
const maxhp := 100
var font : int := 0
var chars : array char of boolean
var heat1, heat2 : int := 0
var hp1, hp2 : int := 100
var y1, y2, lasery1, lasery2 : int := 0
var laser1, laser2 : boolean := false
font := Font.New ("sans serif:14:bold")
proc cannons
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
y2 += 1
elsif chars (KEY_DOWN_ARROW) then
y2 -= 1
end if
if chars ('w') then
y1 += 1
elsif chars ('s') then
y1 -= 1
end if
if y2 > 335 then
y2 -= 1
elsif y2 < 15 then
y2 += 1
end if
if y1 > 335 then
y1 -= 1
elsif y1 < 15 then
y1 += 1
end if
Draw.FillOval (0, y1, 15, 15, 43)
Draw.FillBox (0, y1 - 2, 20, y1 + 2, 43)
Draw.FillOval (maxx, y2, 15, 15, brightgreen)
Draw.FillBox (maxx, y2 - 2, maxx - 20, y2 + 2, brightgreen)
if chars (KEY_CTRL) then
laser1 := true
end if
if chars (' ') then
laser2 := true
end if
end cannons
proc bars
Draw.Box (25, maxy - 25, 225, maxy - 50, black)
Draw.FillBox (26, maxy - 26, 24 + (hp1 * 2), maxy - 49, 43)
Draw.Box (maxx - 25, maxy - 25, maxx - 225, maxy - 50, black)
Draw.FillBox (maxx - 26, maxy - 26, maxx - 24 - (hp2 * 2), maxy - 49, brightgreen)
Font.Draw ("Health", 100, maxy - 43, font, black)
Font.Draw ("Health", maxx - 150, maxy - 43, font, black)
Draw.Box (25, maxy - 55, 225, maxy - 80, black)
Draw.FillBox (26, maxy - 56, 224, maxy - 79, brightblue)
Draw.Box (maxx - 25, maxy - 55, maxx - 225, maxy - 80, black)
Draw.FillBox (maxx - 26, maxy - 56, maxx - 224, maxy - 79, brightblue)
end bars
proc lasers
if laser1 = true then
heat1 -= heatshot
lasery1 := y1
for i : maxx .. 0 by speedshot
cannons
Draw.Line (i, lasery1, i - 20, lasery1, brightgreen)
if i <= 0 then
laser1 := false
end if
end for
end if
if laser2 = true then
heat2 -= heatshot
lasery2 := y2
for o : 0 .. maxx by speedshot
cannons
Draw.Line (o, lasery2, o + 20, lasery2, 43)
if o >= maxx then
laser2 := false
end if
end for
end if
end lasers
View.Set ("offscreenonly")
loop
cls
Draw.Box (maxx, maxy, 0, 0, black)
Draw.Line (maxx, 350, 0, 350, black)
cannons
lasers
bars
View.Update
delay (5)
end loop
|