Same here but u can start by putting snow in it:)
Turing: |
module Snow
export snowflake, create, fall, draw, pileup
type snowflake :
record
x, y : real
yvel : real
alive : int
end record
var pileup : real := 0
function create : snowflake
var temp : snowflake
temp.x := Rand.Int (0, maxx)
temp.y := maxy + (Rand.Real * 10)
temp.yvel := (Rand.Real * 3) + 1
temp.alive := 1
result temp
end create
function fall (flake : snowflake ) : snowflake
var temp := flake
temp.y - = temp.yvel
if temp.y < pileup then
temp.alive := 0
pileup + = 0. 005
end if
result temp
end fall
procedure draw (flake : snowflake )
drawfilloval (round (flake.x ), round (flake.y ), 1, 1, white)
end draw
end Snow
module StaticFlake
import Snow
export draw, create, staticflake
type staticflake :
record
x, y : int
end record
fcn create (flake : Snow.snowflake ) : staticflake
var temp : staticflake
temp.x := round (flake.x )
temp.y := round (flake.y )
result temp
end create
proc draw (flake : staticflake )
drawfilloval (flake.x, flake.y, 2, 2, white)
end draw
end StaticFlake
var win := Window.Open ("offscreenonly")
colourback (black)
colour (white)
var cur := 0
var snow : array 1 .. 1000 of Snow.snowflake %creates 100 snowflakes
var static : flexible array 1 .. 0 of StaticFlake.staticflake
for i : 1 .. upper (snow )
snow (i ) := Snow.create %creates all dem snowflakes
snow (i ).y - = Rand.Real * 100
end for
loop %main loop
for i : 1 .. upper (snow )
if snow (i ).alive ~ = 0 then
snow (i ) := Snow.fall (snow (i )) %the snow flake falls a bit
else
if upper (static ) < 1000 then
new static, upper (static ) + 1
static (upper (static )) := StaticFlake.create (snow (i ))
else
cur := cur rem 1000
cur + = 1
Text.Locate (1, 1)
put cur
static (cur ) := StaticFlake.create (snow (i ))
end if
snow (i ) := Snow.create
end if
end for
cls
for i : 1 .. upper (snow )
Snow.draw (snow (i )) %draws the snowflake
end for
for i : 1 .. upper (static )
StaticFlake.draw (static (i ))
end for
drawfillbox (0, 0, maxx, round (Snow.pileup )- 5, white)
View.Update
Time.DelaySinceLast (20)
end loop
|
Mod Edit:
Please wrap your code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code: |
[syntax="turing"] ... code ... [/syntax]
[code] ... code ... [/code ]
|
|