setscreen ("offscreenonly, graphics:500;300")
var cx : flexible array 1 .. 1 of int
var cy : flexible array 1 .. 1 of int
proc fillArray (tx, ty : int)
drawdot (tx, ty, 0)
if whatdotcolor (tx + 1, ty) = 7 then
new cx, upper (cx) + 1
new cy, upper (cy) + 1
cx (upper (cx)) := tx + 1
cy (upper (cy)) := ty
fillArray (tx + 1, ty)
end if
if whatdotcolor (tx - 1, ty) = 7 then
new cx, upper (cx) + 1
new cy, upper (cy) + 1
cx (upper (cx)) := tx - 1
cy (upper (cy)) := ty
fillArray (tx - 1, ty)
end if
if whatdotcolor (tx, ty + 1) = 7 then
new cx, upper (cx) + 1
new cy, upper (cy) + 1
cx (upper (cx)) := tx
cy (upper (cy)) := ty + 1
fillArray (tx, ty + 1)
end if
if whatdotcolor (tx, ty - 1) = 7 then
new cx, upper (cx) + 1
new cy, upper (cy) + 1
cx (upper (cx)) := tx
cy (upper (cy)) := ty - 1
fillArray (tx, ty - 1)
end if
end fillArray
proc findCoords
for x : 1 .. maxx by 20
for y : 1 .. maxy by 20
if whatdotcolor (x, y) = 7 then
cx (1) := x
cy (1) := y
fillArray (x, y)
exit
end if
exit when whatdotcolor (x, y) = 7
end for
end for
if upper (cx) = 1 then
return
end if
var tx := 0
var ty := 0
for i : 1 .. upper (cx)
tx += cx (i)
ty += cy (i)
end for
tx := tx div upper (cx)
ty := ty div upper (cy)
locate (1, 1)
put "Puck Coordinates: ", tx, " ", ty
new cx, 1
new cy, 1
end findCoords
var mx, my, md : int
loop
mousewhere (mx, my, md)
drawfilloval (mx, my, 15, 15, 7)
findCoords
put "Mouse Coordinates: ", mx, " ", my
drawfilloval (mx, my, 15, 15, 7)
View.Update
cls
end loop |