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

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




PostPosted: Mon May 11, 2009 8:50 am   Post subject: Help With Turing!!!!!!

What is it you are trying to achieve?
<to make the slides (between star logo slide and baseball slide) appear>


What is the problem you are having?
<the program runs (no errors) but the slides will not show. (it will only show when I click pause) Also, if I type the program of this particular part in another Turing file, it works. >


Describe what you have tried to solve this problem
<typed in cls and colorback (white)>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<
% The "Music.PlayFile Example" program.
setscreen ("graphics:vga")
colorback (89)
const STAR_SIZE : int := 80
var pic, x, y, dx, dy : int
var finished : boolean := false
% Play sound effect once.
process Boing
Music.PlayFile ("boing.wav")
end Boing
% Loop playing background music until 'finished' is true.
process BackgroundMusic
loop
exit when finished
Music.PlayFile ("background.mid")
end loop
end BackgroundMusic
% Get the original picture
var mypic : int := Pic.FileNew ("H:/Computers/star2.bmp")
x := Rand.Int (0, maxx - STAR_SIZE)
y := Rand.Int (0, maxy - STAR_SIZE)
dx := 1
dy := 1
Pic.Draw (mypic, x, y, picMerge)
pic := Pic.New (0, 0, mypic, mypic)
cls

fork BackgroundMusic % Start background music playing
for o:1..4500
if x + dx < 0 or x + dx > maxx - STAR_SIZE then
dx := -dx
fork Boing
end if
if y + dy < 0 or y + dy > maxy - STAR_SIZE then
dy := -dy
fork Boing
end if
x += dx
y += dy
Pic.Draw (mypic, x, y, picCopy)
exit when hasch

setscreen ("offscreenonly")

cls
Pic.Draw (mypic, x, y, picMerge)
View.Update
cls
end for
% Stop the background music
finished := true
Music.PlayFileStop
delay (200)
cls

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

setscreen ("graphics:vga")
colorback (89)
var font: int
colorback (89)
for i: 1..5
delay (200)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if i=1 then
colorback (88)
font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elsif i=2 then
colorback (77)
font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elsif i=3 then
colorback (51)
font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elsif i=4 then
colorback (66)
font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elsif i=5 then
colorback (3)
font :=Font.New ("broadway:22")
Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
Font.Free (font)

font :=Font.New ("broadway:22")
Font.Draw ("Baseball Game!", 200, 200, font, 4)
Font.Free (font)
delay (200)
cls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
exit when font=5
delay (500)
end if
end for
Sponsor
Sponsor
Sponsor
sponsor
milkislife




PostPosted: Mon May 11, 2009 1:08 pm   Post subject: RE:Help With Turing!!!!!!

You're missing a View.Update in your program. Thus only updating when you pause.
Don't forget to change your view to OffScreenOnly.
Dusk Eagle




PostPosted: Mon May 11, 2009 2:23 pm   Post subject: Re: Help With Turing!!!!!!

First, please use syntax tags: [syntax="turing"] %code here [/syntax]. They're given to you by default when you write up a new thread, so use them!

Second of all, you should avoid using processes. Use procedures instead.

Turing:

for o : 1 .. 4500
    if x + dx < 0 or x + dx > maxx - STAR_SIZE then
        dx := -dx
        fork Boing
    end if
    if y + dy < 0 or y + dy > maxy - STAR_SIZE then
        dy := -dy
        fork Boing
    end if
    x += dx
    y += dy
    Pic.Draw (mypic, x, y, picCopy)
    exit when hasch

    setscreen ("offscreenonly")

    cls
    Pic.Draw (mypic, x, y, picMerge)
    View.Update
    cls
end for

You shouldn't be using setscreen in a loop when you're not changing anything. Neither should you be declaring a font only to free it in a loop either:
Turing:

for i : 1 .. 5
    delay (200)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%

    font := Font.New ("broadway:22")
    Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
    Font.Free (font)

    font := Font.New ("broadway:22")
    Font.Draw ("Baseball Game!", 200, 200, font, 4)
    Font.Free (font)
    delay (200)
    cls
end for

Instead, you should declare the font outside of a loop and not free it until you are absolutely done with it.
Turing:

     if i = 1 then
        colorback (88)
        font := Font.New ("broadway:22")
        Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
        Font.Free (font)

        font := Font.New ("broadway:22")
        Font.Draw ("Baseball Game!", 200, 200, font, 4)
        Font.Free (font)
        delay (200)
        cls

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    elsif i = 2 then
        colorback (77)
        font := Font.New ("broadway:22")
        Font.Draw ("Capella presents the Blue Jay", 119, 230, font, 4)
        Font.Free (font)

        font := Font.New ("broadway:22")
        Font.Draw ("Baseball Game!", 200, 200, font, 4)
        Font.Free (font)
        delay (200)
        cls

I only showed two of the five times you did this. Again, use procedures properly, and you can eliminate all this repetitive code. Programmers have an acronym that we call DRY: it stands for Don't Repeat Yourself. If you find yourself copy-pasting code, you're probably doing something a function or procedure could do instead.

As for your main question, I'm afraid I don't what this "slide" is you're talking about, so I can't help you there. But follow my advice above and your code will be a lot better off.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: