%Adrian Pomber
% The "wallgame" program.
View.Set ("graphics, nooffscreenonly")
var x, y, j, k, i, h, q, w, r, e, t, u, z, b, n, m, s, d : int := 0
var speed, speed2 : int
var top, left, bottom, right : int := 0
colorback (black)
cls
color (white)
Text.Locate (10, 32)
put "Set initial speed: " ..
get speed
speed2 := speed + 2
Text.Locate (11, 32)
put "Enter starting position: "
Text.Locate (12, 32)
put "x: " ..
get x
Text.Locate (13, 32)
put "y: " ..
get y
loop
exit when top > 2 or bottom > 2 or right > 2 or left > 2 or (top >= 1 and bottom >= 1 and right >= 1 and left >= 1)
Draw.FillOval (x, y, 10, 10, 42)
drawfillstar (j, h, k, i, yellow)
drawfillstar (q, w, r, e, yellow)
drawfillstar (t, u, z, b, yellow)
drawfillstar (s, d, n, m, yellow)
View.Update
delay (10)
View.Update
cls
x += speed
y += speed2
if (x) <= 0 then
speed := -speed - Rand.Int (1, 5)
left += 1
j := x - 20
h := y - 20
k := x + 20
i := y + 20
drawfillstar (j, h, k, i, yellow)
sound (1000, 50)
end if
if (x) >= maxx - 10 then
speed := -speed - Rand.Int (1, 5)
right += 1
q := x - 20
w := y - 20
r := x + 20
e := y + 20
drawfillstar (q, w, r, e, yellow)
sound (1000, 50)
end if
if (y) <= 0 then
speed2 := -speed2 - Rand.Int (1, 5)
bottom += 1
t := x - 20
u := y - 20
z := x + 20
b := y + 20
drawfillstar (t, u, z, b, yellow)
sound (1000, 50)
end if
if (y) >= maxy - 10 then
speed2 := -speed2 - Rand.Int (1, 5)
top += 1
s := x - 20
d := y - 20
n := x + 20
m := y + 20
drawfillstar (s, d, n, m, yellow)
sound (1000, 50)
end if
end loop
cls
put "You hit the top wall ", top, " times"
put "You hit the bottom wall ", bottom, " times"
put "You hit the left wall ", left, " times"
put "You hit the right wall ", right, " times"
if top >= 1 and bottom >= 1 and right >= 1 and left >= 1 then
delay (1000)
cls
colorback (black)
cls
color (white)
Text.Locate (10, 32)
put "You hit all the walls!!" ..
end if
|