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 Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jesse kazomi




PostPosted: Tue Jun 17, 2014 12:18 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 What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Jesse Kazemi




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

Well to show u something that i found from someone i think this will help

View.Set ("graphics:800;600,nobuttonbar,nocursor,noecho")
View.Set ("offscreenonly")
%set up the snow
const NoOfFlakes := 400
var flakeX : array 1 .. NoOfFlakes of int
var flakeY : array 1 .. NoOfFlakes of int

for flake : 1 .. NoOfFlakes
flakeX (flake) := Rand.Int (0, maxx)
flakeY (flake) := Rand.Int (0, maxy)
end for

loop
%Make the background
Draw.FillBox (0, 0, 800, 300, 29)
Draw.FillBox (0, 300, 800, 600, blue)

%snowman
%body
Draw.FillOval (100, 110, 60, 60, white)
Draw.FillOval (100, 195, 45, 45, white)
Draw.FillOval (100, 260, 27, 27, white)
%eyes
Draw.FillOval (110, 270, 5, 5, black)
Draw.FillOval (90, 270, 5, 5, black)
%nose
Draw.Line (105, 263, 95, 263, 42)
Draw.Line (100, 250, 95, 263, 42)
Draw.Line (100, 250, 105, 263, 42)
Draw.Line (100, 250, 104, 263, 42)
Draw.Line (100, 250, 103, 263, 42)
Draw.Line (100, 250, 102, 263, 42)
Draw.Line (100, 250, 101, 263, 42)
Draw.Line (100, 250, 100, 263, 42)
Draw.Line (100, 250, 99, 263, 42)
Draw.Line (100, 250, 98, 263, 42)
Draw.Line (100, 250, 97, 263, 42)
Draw.Line (100, 250, 96, 263, 42)
%mouth
Draw.Line (105, 245, 95, 245, black)
Draw.Arc (100, 245, 5, 5, 180, 0, black)

%Hand
Draw.FillOval (60, 195, 25, 20, white)
Draw.FillOval (140, 195, 25, 20, white)
%Flag
Draw.ThickLine (155, 185, 155, 240, 2, black)
Draw.FillBox (156, 240, 195, 215, brightred)
%Draw.Arc ()


%Hat
Draw.ThickLine (127, 287, 73, 287, 3, black)
Draw.ThickLine (127, 291, 73, 291, 4, white)
Draw.ThickLine (127, 294, 73, 294, 3, black)
Draw.ThickLine (129, 287, 129, 294, 2, black)
Draw.ThickLine (73, 287, 73, 294, 2, black)
Draw.FillBox (80, 294, 120, 330, black)
%Buttons
Draw.FillOval (100, 165, 5, 5, black)
Draw.FillOval (100, 185, 5, 5, black)
Draw.FillOval (100, 205, 5, 5, black)
Draw.FillOval (100, 225, 5, 5, black)

%sky
%Moon
Draw.FillOval (65, 550, 40, 40, yellow)
Draw.FillOval (89, 556, 45, 45, blue)
%stars
Draw.FillStar (300, 500, 310, 510, yellow)
Draw.FillStar (265, 465, 255, 455, yellow)
Draw.FillStar (400, 550, 410, 540, yellow)
Draw.FillStar (200, 510, 210, 520, yellow)
Draw.FillStar (115, 550, 125, 560, yellow)
Draw.FillStar (375, 485, 365, 475, yellow)
Draw.FillStar (65, 480, 75, 490, yellow)
Draw.FillStar (130, 420, 140, 410, yellow)
Draw.FillStar (750, 550, 760, 560, yellow)

%Big Bear
Draw.FillStar (690, 455, 700, 465, yellow)
Draw.FillStar (720, 430, 730, 440, yellow)
Draw.FillStar (700, 400, 710, 410, yellow)
Draw.FillStar (670, 405, 680, 415, yellow)
Draw.FillStar (630, 380, 640, 390, yellow)
Draw.FillStar (605, 350, 615, 360, yellow)
Draw.FillStar (600, 320, 610, 330, yellow)

%Draw.FillStar (500, 500, 490, 490, yellow)
%Polar
Draw.FillStar (530, 550, 545, 565, yellow)
%Small Bear
Draw.FillStar (510, 530, 500, 520, yellow)
Draw.FillStar (495, 500, 485, 490, yellow)
Draw.FillStar (490, 470, 480, 460, yellow)
Draw.FillStar (490, 430, 480, 420, yellow)
Draw.FillStar (460, 475, 450, 465, yellow)
Draw.FillStar (460, 430, 450, 420, yellow)

%Christamas tree
%Trunk
Draw.FillBox (380, 100, 420, 170, 113)
%Leaves?
Draw.Line (300, 170, 500, 170, green)
Draw.Line (300, 170, 380, 250, green)
Draw.Line (500, 170, 420, 250, green)
Draw.Line (320, 250, 380, 250, green)
Draw.Line (420, 250, 480, 250, green)
Draw.Line (320, 250, 380, 310, green)
Draw.Line (480, 250, 420, 310, green)
Draw.Line (380, 310, 340, 310, green)
Draw.Line (420, 310, 460, 310, green)
Draw.Line (340, 310, 380, 350, green)
Draw.Line (460, 310, 420, 350, green)
Draw.Line (420, 350, 440, 350, green)
Draw.Line (380, 350, 360, 350, green)
Draw.Line (400, 390, 360, 350, green)
Draw.Line (400, 390, 440, 350, green)
Draw.Fill (400, 200, brightgreen, green)
%star
Draw.FillStar (380, 385, 420, 425, 40)
%presents
%#1
Draw.FillBox (340, 100, 370, 130, brightred)
Draw.Line (340, 105, 365, 130, green)
Draw.Line (345, 100, 370, 125, green)
Draw.Line (340, 100, 340, 105, green)
Draw.Line (340, 100, 345, 100, green)
Draw.Line (370, 130, 365, 130, green)
Draw.Line (370, 130, 370, 125, green)
Draw.Fill (360, 120, green, green)
%#2
Draw.FillBox (330, 100, 290, 130, brightgreen)
Draw.Line (290, 105, 325, 130, brightpurple)
Draw.Line (295, 100, 330, 125, brightpurple)
Draw.Line (290, 100, 290, 105, brightpurple)
Draw.Line (290, 100, 295, 100, brightpurple)
Draw.Line (325, 130, 330, 130, brightpurple)
Draw.Line (330, 130, 330, 125, brightpurple)
Draw.Fill (310, 115, brightpurple, brightpurple)

%Home
Draw.Arc (650, 275, 220, 220, 240, 300, black)
Draw.ThickLine (760, 85, 620, 360, 2, black)
Draw.ThickLine (540, 85, 650, 360, 2, black)
Draw.ThickLine (590, 65, 642, 200, 2, black)
Draw.ThickLine (712, 65, 642, 200, 2, black)
Draw.Fill (642, 100, 43, black)
Draw.Fill (642, 210, 114, black)
Draw.Arc (650, 275, 220, 220, 255, 285, 43)
Draw.Arc (650, 274, 220, 220, 255, 285, 43)

%person
%Draw.FillOval

for flake : 1 .. NoOfFlakes
%Drop The Flake
flakeY (flake) -= Rand.Int (1, 5)
%flakeX (flake) += Rand.Int (-1, 1)
if flakeY (flake) < 0 then
flakeY (flake) := maxy
flakeY (flake) := Rand.Int (0, maxx)
end if
Draw.FillOval (flakeX (flake), flakeY (flake), 1, 1, white)
end for
%Update the screen (because of offscreen only)
View.Update
delay (25)
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: