setscreen ("offscreenonly")
var padx, pady, padheight, padwidth, life, col : int
var ballx, bally, velx, vely, blocklength, blockheight : int
var dropx, dropy, dropi, dropr, dropc, timer : int
var blockx, blockx2, blockx3, blockyr1, blockyr2, blockyr3 : array 1 .. 19 of int
var blocknum : int
var x, y, button : int
var sdrop, getdrop : boolean := false
var font1, font2, font3, font4 : int
font1 := Font.New ("serif:12")
font2 := Font.New ("sans serif:18:bold")
font3 := Font.New ("mono:9")
font4 := Font.New ("Palatino:24:Bold,Italic")
blocknum := 7
padheight := 5
padwidth := 70
ballx := 200
bally := 300
velx := 2
vely := 2
blocklength := 30
blockheight := 10
life := 1
randint (dropr, 360, 380)
randint (dropc, 0, maxx)
dropx := dropc
dropy := dropr
assert font1 > 0 and font2 > 0 and font3 > 0 and font4 > 0
for decblock : 1 .. 18
blockx (decblock) := 10
blockx2 (decblock) := 10
blockx3 (decblock) := 10
blockyr1 (decblock) := 380
blockyr2 (decblock) := 360
blockyr3 (decblock) := 340
end for
for r1dec : 2 .. 18
blockx (r1dec) := blockx (r1dec - 1) + 35
blockx2 (r1dec) := blockx2 (r1dec - 1) + 35
blockx3 (r1dec) := blockx3 (r1dec - 1) + 35
end for
loop
View.Update
delay (5)
cls
mousewhere (x, y, button)
drawfillbox (x, 20, x + padwidth, 20 + padheight, 7)
drawfilloval (ballx, bally, 5, 5, 7)
ballx += velx
bally += vely
if ballx >= maxx then
velx *= -1
elsif ballx <= 0 then
velx *= -1
end if
if bally >= maxy then
vely *= -1
elsif bally <= 0 then
vely *= -1
end if
if ballx > x and ballx < x + padwidth - 56 and bally > 20 and bally < 20 + padheight then
vely *= -1
velx := 3
end if
if ballx > x + 14 and ballx < x + padwidth - 42 and bally > 20 and bally < 20 + padheight then
vely *= -1
velx := 2
end if
if ballx > x + 28 and ballx < x + padwidth - 28 and bally > 20 and bally < 20 + padheight then
vely *= -1
velx := 1
end if
if ballx > x + 42 and ballx < x + padwidth - 14 and bally > 20 and bally < 20 + padheight then
vely *= -1
velx := -2
end if
if ballx > x + 56 and ballx < x + padwidth and bally > 20 and bally < 20 + padheight then
vely *= -1
velx := -3
end if
for row1 : 1 .. 18
drawfillbox (blockx (row1), blockyr1 (row1), blockx (row1) + blocklength, blockyr1 (row1) + blockheight, 7)
drawfillbox (blockx2 (row1), blockyr2 (row1), blockx2 (row1) + blocklength, blockyr2 (row1) + blockheight, 7)
drawfillbox (blockx3 (row1), blockyr3 (row1), blockx3 (row1) + blocklength, blockyr3 (row1) + blockheight, 7)
end for
for colr1 : 1 .. 18
if ballx > blockx (colr1) and ballx < blockx (colr1) + blocklength and bally > blockyr1 (colr1) and bally < blockyr1 (colr1) + blockheight then
blockx (colr1) := 5000
vely *= -1
bally -= 10
end if
if ballx > blockx2 (colr1) and ballx < blockx2 (colr1) + blocklength and bally > blockyr2 (colr1) and bally < blockyr2 (colr1) + blockheight then
blockx2 (colr1) := 5000
vely *= -1
bally -= 10
end if
if ballx > blockx3 (colr1) and ballx < blockx3 (colr1) + blocklength and bally > blockyr3 (colr1) and bally < blockyr3 (colr1) + blockheight then
blockx3 (colr1) := 5000
vely *= -1
bally -= 10
end if
end for
if ballx > dropc and ballx < dropc + 30 and bally > dropr and bally < dropr + 10 and sdrop = false then
sdrop := true
end if
if sdrop = true then
drawfilloval (dropx, dropy, 5, 5, 12)
dropy -= 1
if x < dropx and x + padwidth > dropx and 20 > dropy and 20 < dropy + 3 then
life += 1
dropx := 5000
getdrop := true
end if
end if
locate (maxrow - 1, maxcol)
put life
if getdrop = false then
timer := 0
end if
if getdrop = true and timer < 500 then
timer += 1
randint (col, 1, 14)
Font.Draw ("EXTRA LIFE", maxx div 2 - 20, maxy div 2, font2, col)
end if
end loop
|