View.Set ("graphics:780;590,position:middle;middle,nobuttonbar,offscreenonly")
var font := Font.New ("Comic Sans MS:20")
var playerColor : int
var mx, my, b, sx, playerTurn, column := 0
var spot : array 1 .. 7, 1 .. 6 of int
var row : array 1 .. 7 of int
const width := 570
const height := 490
const radius := 35
for x : 1 .. 7
for y : 1 .. 6
spot (x, y) := 0
end for
end for
for i : 1 .. 7
row (i) := 1
end for
proc drawBoard
for y : 1 .. 6
for x : 1 .. 7
Draw.Oval ((x - 1) * 80 + (2 * radius) + 25, (y - 1) * 80 + (2 * radius) + 25, radius, radius, 7)
end for
end for
if playerTurn mod (2) not= 1 then
playerColor := 7
elsif playerTurn mod (2) not= 0 then
playerColor := 12
end if
drawbox (50, 50, maxx - 160, maxy - 50, 7)
Draw.Fill (51, 51, yellow, 7)
Font.Draw ("Player Turn", 630, 550, font, 7)
Draw.FillOval (700, 500, radius, radius, playerColor)
Draw.Oval (700, 500, radius, radius, 7)
end drawBoard
procedure drawSpot
sx := column
if b = 1 then
if row (column) = 7 then
return
end if
if playerTurn = 0 then
spot (sx, row (column)) := 1
elsif playerTurn = 1 then
spot (sx, row (column)) := 2
end if
if playerTurn = 0 then
playerTurn := 1
else
playerTurn := 0
end if
row (column) += 1
end if
end drawSpot
procedure playerPut
Mouse.Where (mx, my, b)
if mx > 50 and mx < 135 then
Draw.Box (50, 25, 135, maxy - 25, 7)
column := 1
drawSpot
elsif mx > 135 and mx < 215 then
Draw.Box (135, 25, 215, maxy - 25, 7)
column := 2
drawSpot
elsif mx > 215 and mx < 295 then
Draw.Box (215, 25, 295, maxy - 25, 7)
column := 3
drawSpot
elsif mx > 295 and mx < 375 then
Draw.Box (295, 25, 375, maxy - 25, 7)
column := 4
drawSpot
elsif mx > 375 and mx < 455 then
Draw.Box (375, 25, 455, maxy - 25, 7)
column := 5
drawSpot
elsif mx > 455 and mx < 535 then
Draw.Box (455, 25, 535, maxy - 25, 7)
column := 6
drawSpot
elsif mx > 535 and mx < maxx - 160 then
Draw.Box (535, 25, maxx - 160, maxy - 25, 7)
column := 7
drawSpot
else
end if
for i : 1 .. 7
for j : 1 .. 6
if spot (i, j) = 1 then
drawfilloval ((i - 1) * 80 + (radius * 2) + 25, (j - 1) * 80 + (radius * 2) + 25, radius - 1, radius - 1, 7)
end if
end for
end for
for i : 1 .. 7
for j : 1 .. 6
if spot (i, j) = 2 then
drawfilloval ((i - 1) * 80 + (radius * 2) + 25, (j - 1) * 80 + (radius * 2) + 25, radius - 1, radius - 1, 12)
end if
end for
end for
end playerPut
loop
cls
drawBoard
playerPut
View.Update
delay (100)
end loop
|