setscreen ("nooffscreenonly")
var speed, x, y, pastx, pasty, dir, bulletx, bullety, bulletdir, bulletspeed : real
var speed2, x2, y2, pastx2, pasty2, dir2, bulletx2, bullety2, bulletdir2 : real
var chars : array char of boolean
var shoot, shoot2 : int
var gamespeed, score1, score2 : int
var pics1, pics2 : array 0 .. 359 of int
var hit : boolean
hit := false
score1 := 0
score2 := 0
gamespeed := 2
%Pic.ScreenLoad ("man.bmp", 0, 0, picMerge)
drawdot(9,11,10)
drawdot(9,12,10)
drawdot(9,17,10)
drawdot(9,18,10)
drawdot(10,11,10)
drawdot(10,12,10)
drawdot(10,17,10)
drawdot(10,18,10)
drawfillbox(11,11,12,18,10)
drawfillbox(13,11,16,12,20)
drawfillbox(13,17,16,18,20)
drawfillbox(16,13,17,16,20)
drawfillbox(13,13,16,16,110)
drawfillbox(13,10,16,7,40)
drawfillbox(13,18,16,20,40)
drawfillbox(13,21,18,22,68)
drawfillbox(13,5,18,6,68)
drawfillbox(19,5,22,6,7)
drawfillbox(23,7,28,8,7)
pics1 (0) := Pic.New (0, 0, 28, 28)
cls
for angle : 1 .. 359
drawbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + 180, maxy div 2 + 50, 7)
drawfillbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 - 180 + (angle div 2), maxy div 2 + 50, 7)
%locate (3, 3)
%put "Creating picture rotated ", angle, " degrees"
pics1 (angle) := Pic.Rotate (pics1 (0), angle, 14, 14)
end for
%Pic.ScreenLoad ("man2.bmp", 0, 0, picMerge)
drawdot(9,11,6)
drawdot(9,12,6)
drawdot(9,17,6)
drawdot(9,18,6)
drawdot(10,11,6)
drawdot(10,12,6)
drawdot(10,17,6)
drawdot(10,18,6)
drawfillbox(11,11,12,18,6)
drawfillbox(13,11,16,12,42)
drawfillbox(13,17,16,18,42)
drawfillbox(16,13,17,16,42)
drawfillbox(13,13,16,16,110)
drawfillbox(13,10,16,7,56)
drawfillbox(13,18,16,20,56)
drawfillbox(13,21,18,22,68)
drawfillbox(13,5,18,6,68)
drawfillbox(19,5,22,6,7)
drawfillbox(23,7,28,8,7)
pics2 (0) := Pic.New (0, 0, 28, 28)
cls
for angle : 1 .. 359
%locate (3, 3)
drawbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + 180, maxy div 2 + 50, 7)
drawfillbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + (angle div 2), maxy div 2 + 50, 7)
%put "Creating picture rotated ", angle, " degrees"
pics2 (angle) := Pic.Rotate (pics2 (0), angle, 14, 14)
end for
cls
setscreen ("offscreenonly;nocursor")
loop
put "You are playing a game up to ", (50 * (6 - gamespeed)), " points."
put "Press any key to continue"
View.Update
cls
exit when hasch
end loop
speed := 1 * gamespeed
bulletspeed := 20 * gamespeed
dir := 180
x := maxx div 2 - 50
y := maxy div 2
shoot := 0
speed2 := 1 * gamespeed
dir2 := 0
x2 := maxx div 2 + 50
y2 := maxy div 2
shoot2 := 0
loop
shoot := 0
shoot2 := 0
loop
pastx := x
pasty := y
pastx2 := x2
pasty2 := y2
%1st Player Controls
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
x += cosd (dir) * speed
y += sind (dir) * speed
end if
if chars (KEY_DOWN_ARROW) then
x += cosd (dir) * -speed
y += sind (dir) * -speed
end if
if chars (KEY_LEFT_ARROW) then
dir += speed
end if
if chars (KEY_RIGHT_ARROW) then
dir -= speed
end if
if chars (KEY_CTRL) then
shoot := 1
end if
%2nd Player Controls
if chars ('w') then
x2 += cosd (dir2) * speed2
y2 += sind (dir2) * speed2
end if
if chars ('s') then
x2 += cosd (dir2) * -speed2
y2 += sind (dir2) * -speed2
end if
if chars ('a') then
dir2 += speed2
end if
if chars ('d') then
dir2 -= speed2
end if
if chars (KEY_SHIFT) then
shoot2 := 1
end if
%1st Player Bullet
if shoot = 1 then
bulletx += cosd (bulletdir) * bulletspeed
bullety += sind (bulletdir) * bulletspeed
else
bulletx := x + cosd (dir - 40) * 10
bullety := y + sind (dir - 40) * 10
bulletdir := dir
end if
if bulletx > 0 or bulletx < maxx or bullety > 0 or bullety < maxy then
shoot := 0
end if
%2nd Player Bullet
if shoot2 = 1 then
bulletx2 += cosd (bulletdir2) * bulletspeed
bullety2 += sind (bulletdir2) * bulletspeed
else
bulletx2 := x2 + cosd (dir2 - 40) * 10
bullety2 := y2 + sind (dir2 - 40) * 10
bulletdir2 := dir2
end if
if bulletx2 > 0 or bulletx2 < maxx or bullety2 > 0 or bullety2 < maxy then
shoot2 := 0
end if
if x <= 10 or x >= maxx - 20 or y <= 10 or y >= maxy - 30 then
x := pastx
y := pasty
end if
if x2 <= 10 or x2 >= maxx - 20 or y <= 10 or y2 >= maxy - 30 then
x2 := pastx2
y2 := pasty2
end if
if round (sqrt ((x2 - x) ** 2 + (y2 - y) ** 2)) < 35 then
x := pastx
y := pasty
x2 := pastx2
y2 := pasty2
end if
if dir <= 0 then
dir += 359
elsif dir >= 359 then
dir -= 359
end if
if dir2 <= 0 then
dir2 += 359
elsif dir2 >= 359 then
dir2 -= 359
end if
delay (0)
cls
Pic.Draw (pics1 (round (dir)), round (x) - 14, round (y) - 14, picMerge)
Pic.Draw (pics2 (round (dir2)), round (x2) - 14, round (y2) - 14, picMerge)
drawdot (round (bulletx), round (bullety), black)
drawdot (round (bulletx2), round (bullety2), black)
drawline (round (x + cosd (dir - 40) * 10), round (y + sind (dir - 40) * 10), round (bulletx), round (bullety), brightred)
drawline (round (x2 + cosd (dir2 - 40) * 10), round (y2 + sind (dir2 - 40) * 10), round (bulletx2), round (bullety2), brightred)
drawfillbox (0, maxy, maxx, maxy - 30, 7)
%drawline(0,maxy,
locatexy (0, maxy)
put score1
if score2 < 100 then
locatexy (maxx - 10, maxy)
else
locatexy (maxx - 20, maxy)
end if
put score2
Pic.ScreenLoad ("man.bmp", 30, maxy - 30, picMerge)
Pic.ScreenLoad ("man2.bmp", maxx - 60, maxy - 30, picMerge)
View.Update
if round (sqrt ((bulletx - x2) ** 2 + (bullety - y2) ** 2)) < 20 then
hit := true
shoot := 0
score1 += 1
end if
if round (sqrt ((bulletx2 - x) ** 2 + (bullety2 - y) ** 2)) < 20 then
hit := true
shoot2 := 0
score2 += 1
end if
exit when score1 > (50 * (6 - gamespeed)) or score2 > (5 * (6 - gamespeed)) or hit = true
end loop
exit when score1 > (50 * (6 - gamespeed)) or score2 > (5 * (6 - gamespeed))
end loop
if score1 > score2 then
locatexy (maxx div 2, maxy div 2)
put "Player 1 Wins"
else
locatexy (maxx div 2, maxy div 2)
put "Player 2 Wins"
end if
|