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

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




PostPosted: Wed Apr 27, 2016 8:00 pm   Post subject: Shooting Star

What is it you are trying to achieve?
I'm trying to make a shooting star fly across the screen while the stars are blinking at the same time.

What is the problem you are having?
Whenever I put in the shooting star, the stars, trees, etc. disappear.

Describe what you have tried to solve this problem
I have tried putting the shooting star loop before, after and even inside the blinking stars loop. Same results

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

Turing:


setscreen ("graphics:640;480")
var continue : string       %Variable declared (so it can shift to next step)
var continue1 : string
var continue2 : string
var num : int
var num1 : real
var answer : string
var x : int := 320
var y : int := 300
var xchange : int := 5
var x2 : int := 340
var y2 : int := 320
var x3 : int := 200
var y3 : int := 340
var x4 : int := 220
var y4 : int := 360
var x5 : int := 240
var y5 : int := 400
var x6 : int := 260
var y6 : int := 420
var x7 : int := 160
var y7 : int := 420
var x8 : int := 180
var y8 : int := 440
var x9 : int := 320
var y9 : int := 380
var x10 : int := 340
var y10 : int := 400
var x11 : int := 120
var y11 : int := 380
var x12 : int := 140
var y12 : int := 400
var x13 : int := 400
var y13 : int := 380
var x14 : int := 420
var y14 : int := 400
var x15 : int := 280
var y15 : int := 440
var x16 : int := 300
var y16 : int := 460
var xc : int := 100
var yc : int := 400
var xstar : int := 70
var ystar : int := 350
var radiusx : int := 5
var radiusy : int := 5
var xvariable : int := 50
var yvariable : int := 70
var xchange1 := 1
var ychange1 := 1



colourback (11)             %Background colour for the startup screen
for row : 1 .. 25
    for column : 1 .. 80
        locate (row, column)
        put " "
    end for
end for


locate (1, 13)              %Locates where the text should be
colour (9)                  %Font colour
put "Hello! Type in any key to see something nice!"  %Text
drawbox (13, 1, 50, 1, 15)
locate (3, 15)      %Locates where the input area should be
get continue


loop
    put "Enter a number from 1-15."
    put "If a number above 15 is entered, it will move to the next scene."
    get num


    exit when num > 15

end loop

loop
    put "Do you want to continue? Please enter yes or no."
    get answer


    if answer = "yes"
            or answer = "Yes"

            then
        put "Good choice!"

        exit when answer = "yes"
        exit when answer = "Yes"
    elsif answer = "no"
            or answer = "No"
            then
        put "Please say yes to continue."

        delay (1000)
    end if
end loop

put "Please wait..."

cls                        %Clears screen for next scene

colourback (14)
for row : 1 .. 25
    for column : 1 .. 80
        locate (row, column)  %Makes the background yellow
        put " "
    end for
end for


colour (1)
for count : 1 .. 10      %"Welcome! You are almost there to something cool." will be outputted 10 times
    put "Welcome! You are almost there to see something cool."
end for
put "Enter a character to continue"
get continue2

cls

setscreen ("graphics:640;480")     %Sets screen (640 by 480 pixels) for shapes
colourback (9)          %Background colour
for row : 1 .. 25
    for column : 1 .. 80
        locate (row, column)
        put " "
    end for
end for

%///This is the landscape of the portrait///

%Land
drawfillbox (1, 100, 700, 1, 2)      %Command #1 (horizontal landscape, makes house)
drawbox (2, 101, 701, 2, 247)        %Command #11 (traced box)
drawbox (3, 102, 702, 3, 247)
drawbox (4, 103, 703, 4, 247)
drawline (580, 220, 580, 120, 14)    %Command #2 (draws a line from x1 y1 to x2 y2)
drawdot (500, 400, 1)                %Command #3 (dots, represents grass patches)
drawdot (400, 40, 45)
drawdot (340, 20, 45)
drawdot (180, 80, 45)
drawdot (140, 60, 45)
drawdot (260, 80, 45)
drawdot (220, 0, 45)
drawdot (500, 40, 45)
drawdot (140, 40, 45)
drawdot (300, 20, 45)
drawdot (160, 80, 45)
drawdot (200, 80, 45)
drawdot (400, 40, 45)


loop

    drawfilloval (xstar, ystar, 5, 5, yellow)         % Draw oval
    %This is a shooting star
    delay (50)                                  % Delay
    drawfilloval (xstar, ystar, 5, 5, 9)         % Draw oval in white
    xstar := xstar + xchange1                     % Increase x
    ystar := ystar + ychange1

    exit when xstar > 640                    % Exits
end loop

%House
setscreen ("graphics:640;480")
%House
drawfillbox (380, 100, 640, 250, 160) %Shows house
drawfillbox (450, 220, 480, 190, 11)  %Window created
drawbox (451, 221, 481, 191, 247)
drawbox (452, 222, 482, 192, 247)
drawbox (449, 219, 479, 189, 247)
drawbox (381, 101, 641, 251, 247)
drawbox (382, 102, 642, 252, 247)     %Outlines house with black, outer box
drawbox (383, 103, 643, 253, 247)
drawline (381, 251, 451, 341, 247)
drawline (382, 252, 452, 342, 247)    %Outlines the diagonal slope and thickens with black line segments
drawline (383, 253, 453, 343, 247)

drawline (380, 250, 460, 350, black) %First diagonal slope

drawline (380, 250, 520, 250, black) %Bottom part of triangle
drawline (460, 350, 520, 250, black) %Second diagonal slope
drawfill (450, 300, red, black) %Fills triangle


drawline (519, 250, 519, 100, black)
var m : array 1 .. 4 of int := init (450, 640, 640, 520)
var n : array 1 .. 4 of int := init (348, 348, 253, 253)
Draw.FillPolygon (m, n, 4, red)
Draw.Polygon (m, n, 4, black)



%Top part of roof
drawline (460, 350, 640, 350, 247)
drawline (461, 351, 641, 351, 247)
drawline (462, 352, 642, 352, 247)
drawline (640, 350, 640, 250, black)

%Door
drawfillbox (420, 105, 450, 160, 15)
drawbox (419, 104, 449, 159, 247)
drawbox (418, 103, 448, 158, 247)

drawbox (422, 102, 447, 157, 247)
drawfilloval (440, 132, 5, 5, 1)    %Command #7 (door handle)


%Tree #1
drawfillbox (40, 100, 100, 250, 6)
drawarc (50, 150, 40, 50, 60, 90, 247)
drawarc (55, 140, 40, 50, 60, 90, 247) %Command #10 (Tree details)
drawarc (60, 130, 40, 50, 60, 90, 247)
drawarc (65, 120, 40, 50, 60, 90, 247)
drawbox (41, 101, 101, 251, 247)
drawbox (42, 102, 102, 252, 247)
drawbox (43, 103, 103, 253, 247)
drawfillmapleleaf (20, 240, 120, 340, 4) %Command #6 (Represents the "leaves" of tree)
drawmapleleaf (21, 241, 121, 341, 247)
drawmapleleaf (22, 242, 122, 342, 247)   %Command #9 (Outlined the maple leaf with black)

%Tree #2
drawfillbox (120, 100, 180, 250, 6)    %Makes 2nd tree
drawarc (130, 150, 40, 50, 60, 90, 247)
drawarc (140, 140, 40, 50, 60, 90, 247)
drawarc (130, 130, 40, 50, 60, 90, 247)
drawbox (121, 101, 181, 251, 247)
drawbox (122, 102, 182, 252, 247)      %Outlines 2nd tree with black
drawbox (123, 103, 183, 253, 247)
drawfillbox (120, 255, 180, 315, 2)    %Represents the "leaves"
drawbox (121, 256, 181, 316, 247)
drawbox (122, 257, 182, 317, 247)      %Outlined leaves with black
drawbox (123, 257, 183, 318, 247)

%Tree #3
drawfillbox (200, 100, 260, 250, 6)    %Makes 3rd tree
drawarc (210, 150, 40, 50, 60, 90, 247)
drawarc (220, 140, 40, 50, 60, 90, 247)
drawarc (230, 130, 40, 50, 60, 90, 247)
drawarc (240, 120, 40, 50, 60, 90, 247)
drawbox (200, 100, 260, 250, 247)
drawbox (201, 101, 261, 251, 247)      %Outlines 3rd tree with black
drawbox (202, 102, 262, 252, 247)
drawfilloval (230, 285, 35, 35, 5)     %Command #7 (Represents leaves)
drawoval (231, 286, 35, 35, 247)
drawoval (232, 287, 35, 35, 247)
drawoval (230, 285, 28, 28, 247)       %Command #8 (Design for leaves)
drawoval (230, 285, 25, 25, 247)
drawoval (230, 285, 22, 22, 247)
drawoval (230, 285, 19, 19, 247)
drawoval (230, 285, 16, 16, 247)

%///This is the sky of the portrait///


drawfillstar (x3, y3, x4, y4, 14)    %Command #5 (Makes star)
drawfillstar (x3, y3, x4, y4, 14)

drawstar (199, 339, 219, 359, 247)       %Command #4 (Outlines star)


%drawfillstar (160, 420, 180, 440, 14)
%drawfillstar (280, 440, 300, 460, 14)
%drawfillstar (320, 380, 340, 400, 14)
%drawfillstar (120, 380, 140, 400, 14)
%drawfillstar (400, 380, 420, 400, 14)


drawfilloval (500, 420, 60, 50, 14)
drawfilloval (460, 430, 60, 50, 9)

process playstuff
    loop
        Music.PlayFile ("Smiling.mp3")         %Plays music for picture. Song name within the brackets. This is an mp3 file.
    end loop
end playstuff

fork playstuff

loop

    drawfillstar (x, y, x2, y2, blue)
    delay (100)
    drawfillstar (x, y, x2, y2, yellow)
    delay (20)


    drawfillstar (x5, y5, x6, y6, blue)
    delay (100)
    drawfillstar (x5, y5, x6, y6, yellow)
    delay (30)

    drawfillstar (x3, y3, x4, y4, blue)
    delay (100)
    drawfillstar (x3, y3, x4, y4, yellow)                 %Animations

    delay (10)

    drawfillstar (x7, y7, x8, y8, blue)
    delay (100)
    drawfillstar (x7, y7, x8, y8, yellow)
    delay (40)

    drawfillstar (x9, y9, x10, y10, blue)
    delay (100)
    drawfillstar (x9, y9, x10, y10, yellow)
    delay (20)

    drawfillstar (x11, y11, x12, y12, blue)
    delay (100)
    drawfillstar (x11, y11, x12, y12, yellow)
    delay (60)

    drawfillstar (x13, y13, x14, y14, blue)
    delay (100)
    drawfillstar (x13, y13, x14, y14, yellow)
    delay (60)

    drawfillstar (x15, y15, x16, y16, blue)
    delay (100)
    drawfillstar (x15, y15, x16, y16, yellow)
    delay (60)



            drawfilloval (xstar, ystar, 5, 5, yellow) % Draw oval %SHOOTING STAR
            delay (50)                          % Delay
            drawfilloval (xstar, ystar, 5, 5, black) % Draw oval in white
            xstar := xstar + xchange1             % increase x by a set value
            ystar := ystar + ychange1

            exit when xstar > 640            % exit when x >= 640

        end loop



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Apr 28, 2016 4:59 am   Post subject: RE:Shooting Star

As long as one loop is running, no other code can run. Can you think of a way to restructure your code so there is only one 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: