View.Set (" nocursor, graphics: 600; 400")
proc car (x, y, length, height, clr : int)
Draw.FillBox (x, y, x + length, y + height, yellow) % body of car
Draw.FillOval (x + length div 4, y, height div 5, height div 5, black) % wheels
Draw.FillOval (x + 3 * length div 4, y, height div 5, height div 5, black)
Draw.Arc (x + length div 2, y + height, length div 4, length div 6, 0, 180, clr) %roof of car
end car
proc carErase (x, y, length, height, clr : int)
Draw.FillBox (x, y, x + length, y + height, clr) % body of car
Draw.FillOval (x + length div 4, y, height div 5, height div 5, black) % wheels
Draw.FillOval (x + 3 * length div 4, y, height div 5, height div 5, black)
Draw.Arc (x + length div 2, y + height, length div 4, length div 6, 0, 180, clr) %roof of car
end carErase
proc house (x, y, size : int)
Draw.FillBox (x, y, x + size, y + size, red) % main house
Draw.Line (x, y + size, x + size div 2, y + 3 * size div 2, red) % roof
Draw.Line (x + size div 2, y + 3 * size div 2, x + size, y + size, red)
Draw.Fill (x + size div 2, y + size + 1, red, red) % fill in roof
end house
proc scene (x, y : int)
Draw.FillBox (x, y + maxy div 2, maxx, maxy, blue) % sky
Draw.FillBox (x, y, maxx, maxy div 2, green) % green
end scene
proc animation1 % car moves across screene
var speed : int := 5
scene (0, 0)
house (250, 120, 75)
house (350, 120, 75)
house (450, 120, 75)
for x : 0 .. maxx by speed
car (x, 60, 100, 40, brightred) % draw carin new spot
delay (50)
carErase (x, 60, 100, 40, green)
end for
end animation1
proc animation2
var x : int := 0
var speed : int := 5
scene (0, 0)
loop
car (maxx div 2 - 100, maxy div 4, 100, 40, brightred)
delay (75)
scene (0, 0)
house (x + maxx, 120, 75)
house (x + maxx, -100, 75)
house (x + maxx, -200, 75)
x := x - speed
if x < -maxx then
x := 0
end if
speed:= speed+ 10
end loop
end animation2
% mainline
animation1
cls
animation2
|