var winID : int
var mx, my, mbutton : int
var xoff, yoff : int
var width1, height1 : int := 500
var rx1, lx1, ty1, by1 : real
var rx2, lx2, ty2, by2 : real
var rx3, lx3, ty3, by3 : real
var rx4, lx4, ty4, by4 : real
var obsx, obsy, rad1 : real
var ang1 : int := 0
var ang2 : int := ang1 + 270
var anginc : int := 10
var rotdir : int := 1
%%% variables for the gates %%%
var dividedinto : real := 20
var divfac1 : real := 0.125
var divfacacc1 : real := 0.125
var divfacacc2 : real := 0.125
%%% variables for the gates %%%
var score1 : int := 0
var font : int
font := Font.New ("serif:12")
winID := Window.Open ("position:center;center,graphics:" + intstr (width1) + ";" + intstr (height1) + ",nobuttonbar")
loop
setscreen ("offscreenonly")
loop
% mouse
Mouse.Where (mx, my, mbutton)
mx := maxx - mx
my := maxy - my
if mx >= width1 then
mx := width1
elsif mx <= 0 then
mx := 0
end if
if my >= width1 then
my := width1
elsif my <= 0 then
my := 0
end if
if mx = (width1 div 2) then
xoff := 0
else
xoff := mx - (width1 div 2)
end if
if my = (width1 div 2) then
yoff := 0
else
yoff := my - (width1 div 2)
end if
% variable area 1
rx1 := ((width1 div 2) + xoff) + 355
ty1 := ((width1 div 2) + yoff) + 355
lx1 := ((width1 div 2) + xoff) - 355
by1 := ((width1 div 2) + yoff) - 355
rx2 := ((width1 div 2) + xoff div 70) + 5
ty2 := ((width1 div 2) + yoff div 70) + 5
lx2 := ((width1 div 2) + xoff div 70) - 5
by2 := ((width1 div 2) + yoff div 70) - 5
rx3 := rx1 + (rx1 - (width1 div 2)) * 2
ty3 := ty1 + (ty1 - (width1 div 2)) * 2
lx3 := lx1 - ((width1 div 2) - lx1) * 2
by3 := by1 - ((width1 div 2) - by1) * 2
%%% gate movement (finds position and radius) %%%
obsx := 250 + xoff div dividedinto * divfac1
obsy := 250 + yoff div dividedinto * divfac1
rad1 := 500 div dividedinto * divfac1
%%% gate movement (finds position and radius) %%%
% draw area 1
Draw.Line ((width1 div 2), (width1 div 2), round (rx1 + 145), ((width1 div 2) + yoff), red)
Draw.Line ((width1 div 2), (width1 div 2), round (lx1 - 145), ((width1 div 2) + yoff), red)
Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), round (ty1 + 145), red)
Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), round (by1 - 145), red)
Draw.Line ((width1 div 2), (width1 div 2), round (rx1), round (ty1), red)
Draw.Line ((width1 div 2), (width1 div 2), round (rx1), round (by1), red)
Draw.Line ((width1 div 2), (width1 div 2), round (lx1), round (ty1), red)
Draw.Line ((width1 div 2), (width1 div 2), round (lx1), round (by1), red)
Draw.Line (round (rx3), round (ty3), round (rx1), round (ty1), red)
Draw.Line (round (rx3), round (by3), round (rx1), round (by1), red)
Draw.Line (round (lx3), round (ty3), round (lx1), round (ty1), red)
Draw.Line (round (lx3), round (by3), round (lx1), round (by1), red)
Draw.FillOval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (7), (7), white)
Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (9), (9), white)
Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (11), (11), white)
Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (14), (14), white)
Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (18), (18), white)
Draw.Oval (round ((((rx2 - lx2) div 2) + lx2)), round ((((ty2 - by2) div 2) + by2)), (23), (23), white)
% Draw.Oval ((((rx2 - lx2) div 2) + lx2), (((ty2 - by2) div 2) + by2), (14), (14), red)
%%% Drawing Gate %%%
Draw.FillArc (round (obsx), round (obsy), round (rad1), round (rad1), ang1, ang1 + ang2, grey)
Draw.FillOval (round (obsx), round (obsy), round (rad1 div 3), round (rad1 div 3), grey)
Draw.Oval (round (obsx), round (obsy), round (rad1), round (rad1), black)
%%% Drawing Gate %%%
%Draw.Line ((width1 div 2), (width1 div 2), ((width1 div 2) + xoff), ((width1 div 2) + yoff), brightgreen)
Draw.Text ("score: " + intstr (score1), 5, 5, font, black)
% variable area 2
%%% acceleration addition %%%
divfacacc1 += divfacacc2
divfac1 += divfacacc1
%%% acceleration addition %%%
if rotdir = 1 then
ang1 += anginc
elsif rotdir = 2 then
ang1 -= anginc
end if
if divfac1 > dividedinto + 25 then
%%% variable reset %%%
divfac1 := 0.125
divfacacc1 := 0.125
ang1 := Rand.Int (0, 360)
anginc := Rand.Int (0, 10)
rotdir := Rand.Int (1, 2)
%%% variable reset %%%
elsif divfac1 > dividedinto + 10 and whatdotcolor (maxx div 2, maxy div 2) = grey then
exit
end if
if ang1 > 360 then
ang1 := 0
end if
score1 += 1
% end of frame
delay (100)
View.Update
cls
end loop
cls
setscreen ("graphic")
put "you lose"
View.Update
delay (1000)
divfac1 := 0.125
divfacacc1 := 0.125
ang1 := Rand.Int (0, 360)
anginc := Rand.Int (0, 10)
rotdir := Rand.Int (1, 2)
score1 := 0
end loop
|