View.Set ("offscreenonly")
colorback (black)
cls
var time2 := 0
function distance (x1, y1, x2, y2 : real) : real
result (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** .5)
end distance
var chars : array char of boolean
type projectile_t :
record
startx, starty, x, y, angle, weight, velocity : real
end record
type player_t :
record
x, y, w, v, t : real
end record
var zx, zy := -100.0
procedure AI (var player : player_t, projectile : projectile_t, t : real)
var sl : real := 0
var dy := ((projectile.velocity * sind (projectile.angle) * (t + 2) - (projectile.weight) * (t + 3) ** 2 / 2) + projectile.starty)
var dx := ((projectile.velocity * cosd (projectile.angle) * (t + 2)) + projectile.startx)
/*if dy > 95 and dy < 105 then
zx := dx
zy := dy
end if%*/
%drawline (round (projectile.x), round (projectile.y), round (dx), round (dy), 4)
/*if player.x < projectile.x + 10 then
player.x += 2
elsif player.x > projectile.x + 10 and player.x > 350 then
player.x -= 2
end if%*/
if zx not= -100 then
if player.x < zx then
player.x += 2
elsif player.x > zx and player.x > 350 then
player.x -= 2
end if
drawfilloval (round (zx), round (zy), 5, 5, 3)
else
if player.x < dx then
player.x += 2
elsif player.x > dx and player.x > 350 then
player.x -= 2
end if
end if
end AI
procedure cleanAI (var player : player_t, projectile : projectile_t, t : real)
var sl : real := 0
var dy := ((projectile.velocity * sind (projectile.angle) * (t + 2) - (projectile.weight) * (t + 3) ** 2 / 2) + projectile.starty)
var dx := ((projectile.velocity * cosd (projectile.angle) * (t + 2)) + projectile.startx)
%drawline (round (projectile.x), round (projectile.y), round (dx), round (dy), black)
if zx not= -100 then
drawfilloval (round (zx), round (zy), 5, 5, 3)
end if
end cleanAI
var projectile_1 : projectile_t
var player_1, player_2 : player_t
var score1, score2 := 0
player_1.x := 100
player_1.y := 100
player_1.v := 50
player_1.w := 10
player_1.t := 0
player_2.x := 540
player_2.y := 100
player_2.v := 50
player_2.w := 10
player_2.t := 0
projectile_1.startx := 100
projectile_1.starty := 140
projectile_1.velocity := 80
projectile_1.angle := 90
projectile_1.weight := 10
var time1 := 0.0
var bjump_1 := false
procedure Projectile (var obj : projectile_t, t : real)
obj.x := (obj.velocity * cosd (obj.angle) * t) + obj.startx
obj.y := (obj.velocity * sind (obj.angle) * t - (obj.weight) * t ** 2 / 2) + obj.starty
end Projectile
procedure Jump (var obj : player_t)
obj.y := (obj.v * sind (90) * obj.t - (obj.w) * obj.t ** 2 / 2) + 100
obj.t += .1
end Jump
procedure ResetP (var obj : projectile_t, sx, sy, v, a, w : real)
zx := -100
zy := -100
projectile_1.startx := sx
projectile_1.starty := sy
projectile_1.velocity := v
projectile_1.angle := a
projectile_1.weight := w
end ResetP
color (10)
loop
if round (projectile_1.velocity) > 1 then
time1 += .1
else
if projectile_1.x < 320 then
score2 += 1
else
score1 += 1
end if
zx := -100
zy := -100
player_1.x := 100
player_1.y := 100
player_1.v := 50
player_1.w := 10
player_1.t := 0
projectile_1.startx := 100
projectile_1.starty := 140
projectile_1.velocity := 80
projectile_1.angle := 90
projectile_1.weight := 10
time1 := 0.0
locate (10, 10)
put "eeeshta!"
cls
delay (200)
end if
Projectile (projectile_1, time1)
if projectile_1.y < 105 then
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 2), projectile_1.angle, projectile_1.weight)
time1 := 0
end if
if projectile_1.x < 1 then
ResetP (projectile_1, 1, projectile_1.y, round (projectile_1.velocity / 1.7), projectile_1.angle - 90, projectile_1.weight)
time1 := 0
end if
if projectile_1.x > 639 then
ResetP (projectile_1, 639, projectile_1.y, round (projectile_1.velocity / 1.7), projectile_1.angle + 90, projectile_1.weight)
time1 := 0
end if
if projectile_1.y < 210 then
if projectile_1.x > 310 and projectile_1.x < 320 then
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), projectile_1.angle - 90, projectile_1.weight)
time1 := 0
end if
if projectile_1.x < 330 and projectile_1.x > 320 then
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), projectile_1.angle + 90, projectile_1.weight)
time1 := 0
end if
end if
if distance (player_1.x, player_1.y, projectile_1.x, projectile_1.y) < 40 then
if projectile_1.x not= player_1.x then
locate (1, 1)
if arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)) < 0 then
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), 180 + arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)),
projectile_1.weight)
else
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)), projectile_1.weight)
end if
else
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), 90, projectile_1.weight)
end if
time1 := 0
end if
if distance (player_2.x, player_2.y, projectile_1.x, projectile_1.y) < 40 then
if projectile_1.x not= player_2.x then
locate (1, 1)
if arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)) < 0 then
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), 180 + arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)),
projectile_1.weight)
else
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)), projectile_1.weight)
end if
else
ResetP (projectile_1, projectile_1.x, projectile_1.y, round (80), 90, projectile_1.weight)
end if
time1 := 0
end if
if bjump_1 then
Jump (player_1)
if player_1.y < 100 then
bjump_1 := false
player_1.t := 0
player_1.y := 100
end if
end if
AI (player_2, projectile_1, time1)
Input.KeyDown (chars)
if chars ('w') then
bjump_1 := true
end if
if chars ('a') then
player_1.x -= 2
end if
if chars ('d') then
player_1.x += 2
end if
if chars ('q') then
exit
end if
locate (1, 35)
put score1, "/", score2
drawline (320, 100, 320, 200, yellow)
drawfilloval (round (player_1.x), round (player_1.y), 30, 30, 9)
drawfilloval (round (player_2.x), round (player_2.y), 30, 30, 11)
drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, 12)
drawfillbox (0, 0, 640, 100, 10)
View.Update
delay (10)
cleanAI (player_2, projectile_1, time1)
drawfilloval (round (player_1.x), round (player_1.y), 30, 30, black)
drawfilloval (round (player_2.x), round (player_2.y), 30, 30, black)
drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, black)
drawline (320, 100, 320, 200, black)
end loop |