setscreen ("offscreenonly")
drawfillbox (0, 0, maxx, 20, brightgreen)
var player1locationX, player1locationY, player2locationX, player2locationY : int
var radius : int
radius := 15
player1locationX := 150
player1locationY := 20
player2locationX := 450
player2locationY := 20
drawfilloval (player1locationX, player1locationY, radius, radius, brightred)
drawfilloval (player1locationX, player1locationY, 3, 3, black)
drawfilloval (player2locationX, player2locationY, radius, radius, brightblue)
drawfilloval (player2locationX, player2locationY, 3, 3, black)
% variables for player 1's and 2's power
var power1, power2 : int
power1 := 0
power2 := 0
% p1angle and p2angle
var p1angle, p2angle : int
p1angle := 0
p2angle := 180
% small oval coordinates
var oval1X, oval1Y, oval2X, oval2Y : int
oval1X := 25 + player1locationX
oval1Y := player1locationY
oval2X := 25 + player2locationX
oval2Y := player2locationY
loop
% movement variables
var chars : array char of boolean
Input.KeyDown (chars)
if chars ('w') then
p1angle := p1angle + 1
delay (25)
elsif chars ('s') then
p1angle := p1angle - 1
delay (25)
end if
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
p2angle := p2angle + 1
delay (25)
elsif chars (KEY_DOWN_ARROW) then
p2angle := p2angle - 1
delay (25)
end if
% set p1angle parameters
if p1angle > 180 then
p1angle := 180
elsif p1angle < 0 then
p1angle := 0
end if
if p2angle > 180 then
p2angle := 180
elsif p2angle < 0 then
p2angle := 0
end if
% display the p1angle on the screen
locate (1, 10)
put "PLAYER 1's ANGLE:", p1angle, " PLAYER 1's POWER: ", power1
% display the p2angle on the screen
locate (2, 10)
put "PLAYER 2's ANGLE:", p2angle, " PLAYER 2's POWER: ", power2
%Keys for player 1 to change their power
Input.KeyDown (chars)
if chars ('d') then
power1 := power1 + 1
drawfillbox (50, 450, 50 + power1, 470, brightred)
delay (25)
end if
% keys for player 2 to change their power
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
power2 := power2 + 1
drawfillbox (850, 450, 850 + power2, 470, brightblue)
delay (25)
end if
% for player 1's missile must go up, and then come down at a certain time
% put time in a for loop
for t : 1 .. 100
% name missile variables
var health1 : int
health1 := 100
locate (1, 60)
put "HP = ", health1
var currentXlocation1, currentYlocation1, gravity : real
gravity := -1
currentXlocation1 := player1locationX + (cosd (p1angle) * power1 * t) % calculate the missiles current x position
currentYlocation1 := player1locationY + (sind (p1angle) * power1 * t + 0.5 * gravity * (t) ** 2) % calculate the missiles current y position
% draw player 1's missile missile
Input.KeyDown (chars)
if chars ('q') and currentYlocation1 < 15 then
drawfilloval (round (currentXlocation1), round (currentYlocation1), 3, 3, black)
for c : 1 .. 15
drawfilloval (round (currentXlocation1), round (currentYlocation1), c, c, white)
delay (10)
end for
end if
end for
% for player 2's missile must go up, and then come down at a certain time
% put time in a for loop
for t : 1 .. 100
% name missile variables
var health2 : int
health2 := 100
locate (2, 60)
put "HP = ", health2
var currentXlocation2, currentYlocation2, gravity : real
gravity := -1
currentXlocation2 := player2locationX + (cosd (p2angle) * power2 * t) % calculate ht emissiles current x position
currentYlocation2 := player2locationY + (sind (p2angle) * power2 * t + 0.5 * gravity * (t) ** 2) % calculate the missile current y position
% draw player 2's missile missile
Input.KeyDown (chars)
if chars (KEY_ENTER) and currentYlocation2 < 15 then
drawfilloval (round (currentXlocation2), round (currentYlocation2), 3, 3, black)
for c : 1 .. 15
drawfilloval (round (currentXlocation2), round (currentYlocation2), c, c, white)
delay (10)
end for
end if
end for
View.Update
end loop
|