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

Username:   Password: 
 RegisterRegister   
 Almost Done!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ghostblade




PostPosted: Mon May 27, 2013 12:42 pm   Post subject: Almost Done!!!

What is it you are trying to achieve?
My summative is almost done but i just need to make the boat and hand not have a trail at the end. My program does reset and the trails disappear but id rather not have to do that in the first place.


What is the problem you are having?
Hand and Boat have trails

Describe what you have tried to solve this problem
Everything, cls, view.update, offscreenonly


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###%
setscreen ("graphics:max;max")

%#######VARS#######%
var posy1 : int := 300
var posx2 : int := 800
var motorboat : int := Pic.FileNew ("motor boat.bmp")
var handwavex : int := maxx - 270
var handwavey : int := 265
var handwave : int := 5
var newcolour : int := 205
var X, Y : int := 700
var R1, R2 : int := 1
var DX, DY : int := -1
var A, B : int := 700
var C1, C2 : int := 1
var DA, DB : int := -1

%################ MOON ###############
process music
    loop
        Music.PlayFile ("WhatTimeIsIt.mp3")
    end loop
end music
fork music


process moon
    loop
       
        drawfillbox (0, 800, maxx, -400, 66)
        drawfillbox (0, 425, maxx, 220, 9)
        drawfillbox (0, 800, maxx, 400, 104)

        RGB.SetColor (newcolour, 0, 0, 53)

        for T : 44 .. 68

            Draw.FillOval (110, 550, 100, 100, T)
            Draw.FillOval (140, 550, 80, 80, 104)


            newcolour -= RGB.AddColor (0, 0, 2)


           
            delay (100)


        end for
    end loop
end moon

%####BOAT#####%
process boat
    loop
        Pic.Draw (motorboat, posx2, posy1, picMerge)
        posx2 := posx2 - 1

        delay (200)
    end loop
end boat



%#######PERSON#########%
process person
    loop

        drawfillbox (maxx - 200, 100, maxx - 250, 225, 2) %Top
        drawfilloval (maxx - 225, 225, 50, 50, 90) %Head
        Draw.ThickLine (maxx - 200, 170, maxx - 185, 125, 5, 7) %Left Arm
        drawfilloval (maxx - 245, 225, 5, 5, 7) %Left Eye
        drawfilloval (maxx - 205, 225, 5, 5, 7) %Right Eye
        drawarc (maxx - 225, 205, 5, 5, 180, 360, 7) %Smile
        drawarc (maxx - 220, 210, 5, 5, 180, 360, 7)
        drawarc (maxx - 230, 210, 5, 5, 180, 360, 7)
        Draw.ThickLine (maxx - 200, 100, maxx - 190, 50, 5, 7) %Left Leg
        Draw.ThickLine (maxx - 250, 100, maxx - 260, 50, 5, 7) %Right Leg

        delay (100)

        %######################Waving Arm####################%

        Draw.ThickLine (maxx - 250, 170, handwavex, handwavey, 5, 7)

        handwavex := handwavex - handwave

        handwavey := handwavey - handwave

        if handwavex < maxx - 300 then
            handwave := -handwave

        elsif handwavex > maxx - 260 then
            handwave := -handwave

        end if


    end loop
end person

%####SHOOTINGSTAR####%
process shootingstar
    loop

        drawfilloval (X, Y, R1, R2, 31)
        delay (3)
        drawfilloval (X, Y, R1, R2, 31)
        X := X + DX
        Y := Y + DY
        exit when X = 400
    end loop
    delay (200)
    loop
        drawfilloval (A, B, C1, C2, 127)
        delay (3)
        drawfilloval (A, B, C1, C2, 127)
        A := A + DA
        B := B + DB
        exit when A = 400
    end loop
end shootingstar

fork person
fork boat
fork moon
fork shootingstar

process stars
    %Stars variables
    var colour1 : int := 1
    var colour2 : int := 32


    %screen size
    loop
       
        delay (100)
       
        %Draw flashing stars
        Draw.FillStar (810, 450, 830, 470, colour1)
        Draw.FillStar (300, 400, 330, 430, colour1)
        Draw.FillStar (740, 500, 760, 520, colour1)
        Draw.FillStar (500, 500, 530, 530, colour1)

        colour1 := colour1 + 13
        if colour1 > 14 then
            colour1 := 1
        end if

        %Draw stars that change colours
        Draw.FillStar (610, 450, 630, 470, colour2)
        Draw.FillStar (410, 430, 430, 450, colour2)
        Draw.FillStar (310, 550, 330, 570, colour2)
        Draw.FillStar (800, 550, 820, 570, colour2)

        colour2 := colour2 + 1
        if colour2 > 104 then
            colour2 := 32
        end if
    end loop
end stars
fork stars




Please specify what version of Turing you are using
Latest I believe

and btw, i dont know fancy computer language, just tell me "oh add a cls after a certain line" and i can follow that
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon May 27, 2013 12:54 pm   Post subject: RE:Almost Done!!!

Quote:
i dont know fancy computer language, just tell me "oh add a cls after a certain line" and i can follow that


I'm afraid your problem is too big for such a simple fix.

You need to get rid of all of your processes and put everything into the same game loop. This will take a lot of work, but it's the only way to fix the bug.

Processes execute pseudo-simultaneously. One process runs for a bit, then another process runs for a bit, and this repeats until the program terminates. No matter where you put your cls, it's going to flicker and/or leave trails behinds.


Instead of putting everything in its own loop, put everything into one big loop. Move your boat one frame forward, then move your star one frame forward, then move your person one frame forward, etc. It should look something like this:

code:
%variable declaraions
loop
    %move thing 1
    %move thing 2
    %move thing 3
    %move thing 4
    %draw everything
end loop
jr5000pwp




PostPosted: Tue May 28, 2013 9:48 am   Post subject: Re: Almost Done!!!

Processes in turing have very little use. By the time you know how to use them correctly, you probably won't be using turing. To fix your code you will need to do a fun little thing called refactoring. You will probably want to pull out your drawing, and updating code of each of your processes into individual PROCEDURES so that you can arrange them easily into a loop. Once done this loop will look something like this:
Turing:
loop
     %Here is where you call your procedures to update game logic such as updating positions etc.
     UpdateStars
     UpdateShootingStars
     UpdateMoon
     UpdateBoat
     UpdatePerson
     %We clear the screen before we draw, this line can be placed directly after the View.Update call, but I like to put it here because if the game closes or crashes you can see the last frame instead of a white screen.
     cls
     %Draw your game items
     DrawStars
     DrawShootingStars
     DrawMoon
     DrawBoat
     DrawPerson
     %Update the screen to show what we've drawn
     View.Update
     %This caps the frame rate at 62.5 so that the game runs at a consistent speed (Unless it dips below the cap, in which case you may need to look into that)
     Time.DelaySinceLast(16)
end loop
Ghostblade




PostPosted: Tue May 28, 2013 1:00 pm   Post subject: RE:Almost Done!!!

I tried doing this: but it flashes...


%####SETSCREEN###%
setscreen ("graphics:max;max")

%#######VARS#######%
var posy1 : int := 300
var posx2 : int := 800
var motorboat : int := Pic.FileNew ("motor boat.bmp")
var handwavex : int := maxx - 270
var handwavey : int := 265
var handwave : int := 5
var newcolour : int := 205
var X, Y : int := 700
var R1, R2 : int := 1
var DX, DY : int := -1
var A, B : int := 700
var C1, C2 : int := 1
var DA, DB : int := -1

%################ MOON ###############
process music
loop
Music.PlayFile ("WhatTimeIsIt.mp3")
end loop
end music
fork music


loop
View.Update
cls

drawfillbox (0, 800, maxx, -400, 66)
drawfillbox (0, 425, maxx, 220, 9)
drawfillbox (0, 800, maxx, 400, 104)

RGB.SetColor (newcolour, 0, 0, 53)

for T : 44 .. 68

Draw.FillOval (110, 550, 100, 100, T)
Draw.FillOval (140, 550, 80, 80, 104)


newcolour -= RGB.AddColor (0, 0, 2)



delay (100)


end for

%####BOAT#####%

Pic.Draw (motorboat, posx2, posy1, picMerge)
posx2 := posx2 - 1

delay (200)



%#######PERSON#########%


drawfillbox (maxx - 200, 100, maxx - 250, 225, 2) %Top
drawfilloval (maxx - 225, 225, 50, 50, 90) %Head
Draw.ThickLine (maxx - 200, 170, maxx - 185, 125, 5, 7) %Left Arm
drawfilloval (maxx - 245, 225, 5, 5, 7) %Left Eye
drawfilloval (maxx - 205, 225, 5, 5, 7) %Right Eye
drawarc (maxx - 225, 205, 5, 5, 180, 360, 7) %Smile
drawarc (maxx - 220, 210, 5, 5, 180, 360, 7)
drawarc (maxx - 230, 210, 5, 5, 180, 360, 7)
Draw.ThickLine (maxx - 200, 100, maxx - 190, 50, 5, 7) %Left Leg
Draw.ThickLine (maxx - 250, 100, maxx - 260, 50, 5, 7) %Right Leg

delay (100)

%######################Waving Arm####################%

Draw.ThickLine (maxx - 250, 170, handwavex, handwavey, 5, 7)

handwavex := handwavex - handwave

handwavey := handwavey - handwave

if handwavex < maxx - 300 then
handwave := -handwave

elsif handwavex > maxx - 260 then
handwave := -handwave

end if




%####SHOOTINGSTAR####%

drawfilloval (X, Y, R1, R2, 31)
delay (3)
drawfilloval (X, Y, R1, R2, 31)
X := X + DX
Y := Y + DY
exit when X = 400
end loop
delay (200)
loop
drawfilloval (A, B, C1, C2, 127)
delay (3)
drawfilloval (A, B, C1, C2, 127)
A := A + DA
B := B + DB
exit when A = 400



%Stars variables
var colour1 : int := 1
var colour2 : int := 32


%screen size


delay (100)

%Draw flashing stars
Draw.FillStar (810, 450, 830, 470, colour1)
Draw.FillStar (300, 400, 330, 430, colour1)
Draw.FillStar (740, 500, 760, 520, colour1)
Draw.FillStar (500, 500, 530, 530, colour1)

colour1 := colour1 + 13
if colour1 > 14 then
colour1 := 1
end if

%Draw stars that change colours
Draw.FillStar (610, 450, 630, 470, colour2)
Draw.FillStar (410, 430, 430, 450, colour2)
Draw.FillStar (310, 550, 330, 570, colour2)
Draw.FillStar (800, 550, 820, 570, colour2)

colour2 := colour2 + 1
if colour2 > 104 then
colour2 := 32
end if
View.Update
Time.DelaySinceLast(16)

end loop
Nathan4102




PostPosted: Tue May 28, 2013 1:32 pm   Post subject: RE:Almost Done!!!

You need to add View.Set("offscreenonly") if you're using View.Update, and you should only be calling View.Update once, at the end of your loop.
jr5000pwp




PostPosted: Wed May 29, 2013 7:22 am   Post subject: Re: Almost Done!!!

Or just add
code:
,offscreenonly
to his setscreen call.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: