type FlakeType : %This is a type d
record
x, y, speed, size : real
end record
var x, y, button : int := 0
var size : int := 200
var inuse : boolean := false
var Snow : array 1 .. size of FlakeType
const delaytime := 1000000
procedure DrawBack
var cox : array 1 .. 11 of int := init (123, 35, 85, 35, 85, 35, 211, 161, 211, 161, 211)
var coy : array 1 .. 11 of int := init (400, 300, 300, 230, 230, 150, 150, 230, 230, 300, 300)
var conx : array 1 .. 3 of int := init (400, 400, 470)
var cony : array 1 .. 3 of int := init (295, 275, 285)
var roofx : array 1 .. 4 of int := init (300, 400, 610, 700)
var roofy : array 1 .. 4 of int := init (300, 450, 450, 300)
drawfillbox (0, 0, 800, 600, black) %background
drawfillbox (0, 0, 800, 100, grey) %background
drawline (690, 80, 690, 10, brightred) %initial-H
drawline (730, 80, 730, 10, brightred) %initial-H
drawline (690, 45, 730, 45, brightred) %initial-H
drawarc (765, 45, 25, 35, 45, 315, brightred) %initial-C
drawfilloval (740, 520, 45, 45, grey) %moon
drawfilloval (710, 520, 30, 35, black) %moon
drawfillstar (690, 540, 700, 550, yellow)
drawfillstar (140, 570, 150, 580, yellow)
drawfillstar (200, 530, 210, 540, yellow)
drawfillstar (250, 580, 260, 590, yellow)
drawfillstar (320, 480, 330, 490, yellow)
drawfillstar (50, 530, 60, 540, yellow)
drawfillstar (470, 560, 480, 570, yellow)
drawfillstar (100, 490, 110, 500, yellow)
drawfillstar (400, 525, 410, 535, yellow)
drawfillstar (340, 555, 350, 565, yellow)
drawfillstar (280, 520, 290, 530, yellow)
drawfillstar (550, 585, 560, 595, yellow)
drawfillstar (530, 495, 540, 505, yellow)
drawfillstar (550, 585, 560, 595, yellow)
drawfillstar (600, 555, 610, 565, yellow)
drawfillbox (610, 300, 680, 500, red) %chimney
drawline (610, 360, 680, 360, white) %horizontal line on the chimney
drawline (610, 390, 680, 390, white) %horizontal line on the chimney
drawline (610, 420, 680, 420, white) %horizontal line on the chimney
drawline (610, 450, 680, 450, white) %horizontal line on the chimney
drawline (610, 480, 680, 480, white) %horizontal line on the chimney
drawline (645, 420, 645, 450, white) %vertical line on the chimney
drawline (670, 390, 670, 420, white) %vertical line on the chimney
drawline (670, 330, 670, 360, white) %vertical line on the chimney
drawline (620, 480, 620, 450, white) %vertical line on the chimney
drawline (670, 480, 670, 450, white) %vertical line on the chimney
drawline (645, 500, 645, 480, white) %vertical line on the chimney
Draw.FillPolygon (roofx, roofy, 4, 114) %roof
drawfillbox (320, 101, 680, 299, red) %house
drawline (320, 270, 680, 270, white) %horizontal line on the house's wall
drawline (320, 240, 550, 240, white) %horizontal line on the house's wall
drawline (660, 240, 680, 240, white) %horizontal line on the house's wall
drawline (320, 210, 550, 210, white) %horizontal line on the house's wall
drawline (660, 210, 680, 210, white) %horizontal line on the house's wall
drawline (320, 180, 550, 180, white) %horizontal line on the house's wall
drawline (660, 180, 680, 180, white) %horizontal line on the house's wall
drawline (320, 150, 550, 150, white) %horizontal line on the house's wall
drawline (660, 150, 680, 150, white) %horizontal line on the house's wall
drawline (320, 120, 550, 120, white) %horizontal line on the house's wall
drawline (660, 120, 680, 120, white) %horizontal line on the house's wall
drawline (610, 299, 610, 270, white) %vertical line on the house's wall
drawline (550, 299, 550, 270, white) %vertical line on the house's wall
drawline (490, 299, 490, 270, white) %vertical line on the house's wall
drawline (670, 299, 670, 270, white) %vertical line on the house's wall
drawline (580, 270, 580, 260, white) %vertical line on the house's wall
drawline (520, 270, 520, 240, white) %vertical line on the house's wall
drawline (640, 270, 640, 260, white) %vertical line on the house's wall
drawline (490, 240, 490, 210, white) %vertical line on the house's wall
drawline (670, 240, 670, 210, white) %vertical line on the house's wall
drawline (520, 210, 520, 180, white) %vertical line on the house's wall
drawline (670, 180, 670, 150, white) %vertical line on the house's wall
drawline (520, 150, 520, 120, white) %vertical line on the house's wall
drawfillbox (550, 101, 660, 259, 67) %door
drawfillbox (585, 200, 625, 235, 54) %window glass of the door
drawbox (585, 200, 625, 235, black) %outline of the window on the door
Draw.ThickLine (606, 232, 606, 202, 5, black) %blackline on the window
Draw.ThickLine (588, 218, 623, 218, 5, black) %blackline on the window
drawfilloval (640, 180, 10, 10, brown) %doorknob
drawfilloval (400, 150, 110, 110, white) %body of the snowman
drawfilloval (400, 290, 80, 80, white) %head of the snowman
drawfilloval (380, 310, 5, 5, black) %left eye of the snowman
drawfilloval (420, 310, 5, 5, black) %right eye of the snowman
Draw.FillPolygon (conx, cony, 3, 42) %nose of the snowman
drawfilloval (405, 260, 40, 10, black) %mouth of the snowman
drawfilloval (405, 265, 40, 10, white) %mouth of the snowman
drawfilloval (400, 237, 66, 10, brightred) %scarf on the snowman
drawfilloval (400, 243, 65, 5, white) %scarf on the snowman
drawfilloval (400, 200, 10, 10, black) %top button on snowman's body
drawfilloval (400, 150, 10, 10, black) %bottom button on snowmans's body
drawfillbox (95, 101, 151, 149, 114) %Xmas tree's trunk
Draw.FillPolygon (cox, coy, 11, green) %Xmas tree
end DrawBack
procedure GenerateFlakeArray
for i : 1 .. size
Snow (i).x := Rand.Int (0, maxx)
Snow (i).y := Rand.Int (0, maxy)
Snow (i).speed := Rand.Real * Rand.Int (1, 3)
Snow (i).size := Snow (i).speed
end for
end GenerateFlakeArray
process GenerateX
if (not (inuse)) then
x := Rand.Int (-600, 600)
inuse := true
delay (2500)
inuse := false
end if
end GenerateX
process LetItSnow
loop
fork GenerateX
for i : 1 .. size
if x < 500 and x > 300 then
x := 0
elsif x < 600 and x > 500 then
x := 200
elsif x < 700 and x > 600 then
x := 400
elsif x < 800 and x > 700 then
x := 600
elsif x < 300 and x > 200 then
x := -200
elsif x < 200 and x > 100 then
x := -400
elsif x < 100 and x > 0 then
x := -600
end if
Snow (i).y -= Snow (i).speed
Snow (i).x += round (x / 100)
if Snow (i).y < 0 then
Snow (i).y := Rand.Int (maxy, maxy + 100)
end if
if Snow (i).x > maxx then
Snow (i).x := Rand.Int (-10, 0)
end if
if Snow (i).x < 0 then
Snow (i).x := Rand.Int (maxx, maxx + 100)
end if
drawfilloval (round (Snow (i).x), round (Snow (i).y), round (Snow (i).size), round (Snow (i).size), white)
end for
View.Update
for o : 1 .. size
drawfilloval (round (Snow (o).x), round (Snow (o).y), round (Snow (o).size), round (Snow (o).size), blue)
end for
DrawBack %Prevents scratching the whole picture
end loop
end LetItSnow
%Main function:
View.Set ("graphics:800,600") %Set the view to 800x600 graphics mode.
View.Set ("offscreenonly")
View.Set ("title: Winter Scene With a Snowman!!") %Set drawing to offscreen only.
drawfillbox (0, 0, maxx, maxy, blue) %Draw the initial black background.
GenerateFlakeArray %Generate the snow flake array.
fork LetItSnow %Let it snow!
|