Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i need help with making a cartoon design with sno falling in the background all i have is snow piling up please help
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jesse kazomi




PostPosted: Tue Jun 17, 2014 12:17 pm   Post subject: i need help with making a cartoon design with sno falling in the background all i have is snow piling up please help

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
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: