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

Username:   Password: 
 RegisterRegister   
 cant switch color over to blue from black..
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dani190




PostPosted: Sat Dec 17, 2005 12:17 pm   Post subject: cant switch color over to blue from black..

hey guys i cant switch the color from black to blue it will just stop at the end of the black loop
also how can i copy my whole code again and just do it with blue background.when i tried it, it said variable already in use.
code:

setscreen ("graphics:max,max,offscreenonly")



colorback (black)
cls





var v : int
var u : int
var c : int
var count : int
var g : int
var k : int
var countx, county : int
var x1, y1 : int
var a, b : int
var x2, y2 : int
a := 420
b := 50
c := black
countx := 10
county := 7
x2 := 1300
y2 := 600



loop
    var h : array 1 .. 4 of int := init (150, 400, 270, 10) %Roof
    var d : array 1 .. 4 of int := init (250, 250, 400, 10) %Roof


    g := 1300
    k := 400

    Draw.FillBox (150, 50, 400, 250, brightred)     %house box
    Draw.FillBox (401, 50, 620, 160, brightgreen)   %Garage
    Draw.FillBox (420, 50, 601, 140, brightblue)    %Garage Door

    Draw.FillBox (350, 140, 300, 170, grey)         %house window Right side
    Draw.FillBox (200, 140, 250, 170, grey)         %house window Left side
    Draw.FillBox (1800, 1, 1, 50, green)            %Grass in front
    Draw.FillBox (250, 110, 200, 50, grey)          %Door
    drawfillbox (205, 250, 250, 400, red)           %Chiminy

    Draw.FillBox (a, b, 601, 50, black) %Garage part2
    Draw.FillPolygon (h, d, 3, 1) %Roof of house
    a := a
    b := b + 5

    exit when b > 140
    View.Update
    delay (150)
    delay (150)
    cls
    colorback (c)
    drawfilloval (g, k, 20, 20, yellow)





end loop

loop
    var h : array 1 .. 4 of int := init (150, 400, 270, 10)
    var d : array 1 .. 4 of int := init (250, 250, 400, 10)
    Draw.FillBox (150, 50, 400, 250, brightred)      %house box
    Draw.FillBox (401, 50, 620, 160, brightgreen)   %Garage
    Draw.FillBox (420, 50, 601, 140, brightblue)    %Garage Door

    Draw.FillBox (350, 140, 300, 170, grey)         %house window Right side
    Draw.FillBox (200, 140, 250, 170, grey)         %house window Left side
    Draw.FillBox (1800, 1, 1, 50, green)            %Grass in front
    Draw.FillBox (250, 110, 200, 50, grey)          %Door
    drawfillbox (205, 250, 250, 400, red)           %Chiminy

    Draw.FillBox (a, b, 601, 50, black)             %Garage part2
    Draw.FillPolygon (h, d, 3, 1)                   %Roof of house

    View.Update
    delay (10)       %Controls how fast sun moves!
    colorback (c)

    cls


    drawfilloval (x2, y2, 20, 20, yellow)
    exit when x2 = 0
    x2 := x2 - countx
    y2 := y2 - county
    if y2 > 500 then
        county := 0
        if x2 < 300 then
            county := +10


            if x2 > 1 then
                colourback (brightblue)
            else
                colourback (black)
               
               
            end if
        end if
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Dec 17, 2005 12:24 pm   Post subject: (No subject)

You can't just copy and paste all your code because that will redeclare a bunch of variables that have already been declared. Look at this, for example:
code:

var a : int
a := 5
put a
var a : int
a := 6
put a


More importantly, copying and pasting code is a bad idea. It would be better to use a looping construct. If you want to do something twice, use a for loop.
code:

for i : 1 .. 2

Also, it's generally a bad idea to be declaring variables inside your loop. Declare them outside, modify them inside.
dani190




PostPosted: Sat Dec 17, 2005 12:30 pm   Post subject: (No subject)

Quote:

More importantly, copying and pasting code is a bad idea. It would be better to use a looping construct. If you want to do something twice, use a for loop.
code:

for i : 1 .. 2

Also, it's generally a bad idea to be declaring variables inside your loop. Declare them outside, modify them inside

what you were talking about the for i:1..2 i dont even understand what that means could you please exsplain it
Cervantes




PostPosted: Sat Dec 17, 2005 12:40 pm   Post subject: (No subject)

You've never used for loops, before? We've got a tutorial on them.

[Turing Tutorials] -> Turing Walkthrough -> Loops and For loops
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  [ 4 Posts ]
Jump to:   


Style:  
Search: