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

Username:   Password: 
 RegisterRegister   
 Christmas Scene
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kardaron




PostPosted: Mon Jan 12, 2009 1:35 pm   Post subject: Christmas Scene

code:

setscreen ("graphics")

%Christmas Scene Summative



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)

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 (1500)
        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
    end loop
    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
end LetItSnow
DrawBack         %Prevents scratching the whole picture

for i : 0 .. maxx
    %Draw the Ground
    drawfillbox (0, 0, 680, 380, white)

    %Draw the Background
    drawfillbox (0, 100, 650, 900, black)

    %Draw a house
    drawfillbox (5, 150, 125, 100, 3)

    drawfilloval (maxx div 2, 125, 35, 25, white)
    drawfilloval (maxx div 2, 175, 30, 25, white)
    drawfilloval (maxx div 2, 225, 25, 25, white)
    drawline (maxx div 2 - 25
     j : 1 .. 15
        drawfillstar (x, y, x + 20, y + 20, yellow)
    end for

    delay (50)

    %Draw a sled
    drawline (50 + i, 100, 0 - 50 + 1, 100, black)
    drawfillbox (150 + i, 50, 50 + i, 75, 2)
    delay (20)
    cls
    drawfillbox (150 + i, 110, 130 + i, 60, 2)
    delay (20)
    cls
    drawfillbox (0 - 150 + i, 50, 0 - 50 + i, 75, black)
end for

%Main function:

View.Set ("offscreenonly")
View.Set ("title: Winter Scene With a Snowman!!")                %Set drawing to offscreen only.


    GenerateFlakeArray                      %Generate the snow flake array.
    fork LetItSnow                          %Let it snow!


I need help, for some reason, this program doesn't work on Turing 4.0.5
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Jan 12, 2009 2:05 pm   Post subject: RE:Christmas Scene

Why not show us the error message? Most of us are too lazy to actually run it.
The_Bean




PostPosted: Mon Jan 12, 2009 3:11 pm   Post subject: Re: Christmas Scene

Turing:

drawline (maxx div 2 - 25
j : 1 .. 15


You have an opened ended drawline with what appears to be the ending of a for statement.
This will not work in any version of turing that I know of.

Turing:

drawline (50 + i, 100, 0 - 50 + 1, 100, black)

You never declared 'i'
andrew.




PostPosted: Mon Jan 12, 2009 4:27 pm   Post subject: RE:Christmas Scene

Actually, i was declared because it was in a for loop and the counter was called i. When you finish that drawline that wasn't ended, the program works. You should really look into View.Update to get rid of the flickering though.
belarussian




PostPosted: Wed Nov 18, 2009 9:27 pm   Post subject: RE:Christmas Scene

want a good snow scene this is one of my old ones so everybody should know this is mine


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, 260, 2, black)
var picID : int
var x, y : int

picID := Pic.FileNew ("images1.JPG")
for i : 1 .. 50
x := 156 % Random x
y := 210 % Random y
Pic.Draw (picID, x, y, picCopy)
end for

Pic.Free (picID)


%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
flakeX (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  [ 5 Posts ]
Jump to:   


Style:  
Search: