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

Username:   Password: 
 RegisterRegister   
 Need help with 'Click to continue' code
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MrC




PostPosted: Tue Mar 30, 2010 4:34 pm   Post subject: Need help with 'Click to continue' code

Hello,

I am writing a game with Turing 4.1. I'm a compsci teacher, and doing this for my own enrichment ...

My program starts by drawing some graphics. Next, I attempt to draw a canvas over the existing graphics. Everything works fine ... Until I tried to create a "click to continue" portion of code.

The program flow gets all messed up. Even though the loop that waits for a mouse click is at the very end of my program, it stops the drawing partway through and only continues after I click. The click is currently the last part of the program, so I can't figure out why this is happening. I can't paste my whole code because it involves importing graphics and maps from files, but I'll post the jist of the problem:

% draw graphics
% create a GUI.Canvas and display it
% Draw some text into the canvas, including "click to continue"
View.Update
loop
Mouse.Where(x, y, b)

exit when b = 1
end loop



When I remove the mouse command everything is drawn perfectly. When I put it back in, it stops drawing part way through and only finishes the drawing after I click. It just doesn't make sense! HELP please!! Smile
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Mar 30, 2010 5:14 pm   Post subject: RE:Need help with \'Click to continue\' code

The code sample doesn't demonstrate the described problem.

Also, we have [ syntax="turing" ] tags to paste code into.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
MrC




PostPosted: Tue Mar 30, 2010 5:18 pm   Post subject: RE:Need help with \'Click to continue\' code

I fixed it. Here is the code that works:

Turing:
    font1 := Font.New ("Times New Roman:14:bold,italic")
    font2 := Font.New ("Times New Roman:10")
    font3 := Font.New ("Arial:10")

    GUI.Show (canvas)
    GUI.FontDraw (canvas, "Welcome to Drakefield Legend", 5, 160, font1, green)
    GUI.FontDraw (canvas, "A Game by Jordan Cohen", 5, 145, font2, black)
    GUI.FontDraw (canvas, "Click to Continue", 75, 35, font3, grey)
    View.Update
    loop
        Mouse.Where (x, y, b)

        exit when b = 1
    end loop


Seems to work well. "canvas" is a pre-defined GUI canvas.
USEC_OFFICER




PostPosted: Tue Mar 30, 2010 6:45 pm   Post subject: RE:Need help with \'Click to continue\' code

I don't see the difference between the two bits of code. (The important bits) However since the problem is solved, I hope your game turns out well.
Euphoracle




PostPosted: Tue Mar 30, 2010 7:14 pm   Post subject: RE:Need help with \'Click to continue\' code

Look into Input.Pause.
MrC




PostPosted: Wed Mar 31, 2010 7:14 pm   Post subject: Re: RE:Need help with \'Click to continue\' code

Euphoracle @ Tue Mar 30, 2010 7:14 pm wrote:
Look into Input.Pause.


I'll check that out, thansk for the tip.

Oh and I realize now that my question was in fact very unclear Neutral I was frustrated ... but it turned out to be a View.Update issue.

I'll post the game when (if ever) it is complete Smile
USEC_OFFICER




PostPosted: Wed Mar 31, 2010 7:41 pm   Post subject: RE:Need help with \'Click to continue\' code

Now I am even more confused. But still looking forward to it.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: