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

Username:   Password: 
 RegisterRegister   
 clear screen procedure in Turing for a game?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
neuro.akn




PostPosted: Fri Dec 21, 2012 9:33 pm   Post subject: clear screen procedure in Turing for a game?

Hello, I have a question regarding the cls procedure in Turing. How does one call a cls procedure so that at a random point (during a game) the screen will clear for a certain amount of time and display something else, and then return back to the game being played prior?? This would help a lot for my final.
Sponsor
Sponsor
Sponsor
sponsor
Metaxu




PostPosted: Sat Dec 22, 2012 12:34 pm   Post subject: RE:clear screen procedure in Turing for a game?

i assume you could make a procedure that you could call that would generate a random number. If this number = whatever then cls? After a delay of whatever you choose i guess you could just re implement what you had before. re draw everything and such.
Raknarg




PostPosted: Sat Dec 22, 2012 9:35 pm   Post subject: RE:clear screen procedure in Turing for a game?

Are you trying to make a menu screen or something?
neuro.akn




PostPosted: Fri Jan 04, 2013 8:51 pm   Post subject: RE:clear screen procedure in Turing for a game?

Well, I'm trying to call a procedure to clear the screen at a random point during the game. I have the menu, I have the game functionality, I just need to call a procedure to clear screen at random points (more than once) throughout the game... Any ideas?
neuro.akn




PostPosted: Fri Jan 04, 2013 8:53 pm   Post subject: RE:clear screen procedure in Turing for a game?

The game is similar to the game "Copter" in which one must control a helicopter using the mouse to pass obstacles.
Tony




PostPosted: Sat Jan 05, 2013 12:41 am   Post subject: RE:clear screen procedure in Turing for a game?

so your game loop should look something like
code:

loop
   % get input
   % do stuff with input
   % draw current world state
end loop


In the "draw world" step, you decide what should appear on the screen. cls could be that something.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
neuro.akn




PostPosted: Sat Jan 05, 2013 5:34 pm   Post subject: RE:clear screen procedure in Turing for a game?

I don't quite understand what you mean by this loop... I have the game and everything, and it works but what exactly do you mean with the "draw current world state" step? What would I write?
Raknarg




PostPosted: Sat Jan 05, 2013 6:01 pm   Post subject: RE:clear screen procedure in Turing for a game?

Just draw everything out. You draw the map, any enemies out, the player, projectiles, obstacles, etc. Basically any drawing you have to do, you should do at the end.
Sponsor
Sponsor
Sponsor
sponsor
neuro.akn




PostPosted: Sat Jan 05, 2013 6:46 pm   Post subject: RE:clear screen procedure in Turing for a game?

I have everything drawn out and such, I just need to figure out how to call a cls procedure for clearing the screen at random points during gameplay
evildaddy911




PostPosted: Sat Jan 05, 2013 9:05 pm   Post subject: RE:clear screen procedure in Turing for a game?

What he means is during the "do stuff" part is determine if the cls command will be called, then using a conditional during the "draw" stage:
Turing:
% do stuff section
if Rand.Real <= 0.2 then % 20% chance to clear
    clear := true
else
    clear := false
end if
DoStuff()
% draw stuff section
if clear = true then
    cls
else
    DrawGame()
end if
neuro.akn




PostPosted: Sun Jan 06, 2013 12:14 am   Post subject: RE:clear screen procedure in Turing for a game?

Okay, thank you!! But must I declare "clear, DoStuff, and DrawGame?" or are they predefined? And to clarify, this will randomly clear the screen at a random point? Lastly, say I want to clear the screen and then a question will pop up on the new cleared screen for the user to answer... If the user answers correctly, they get to return to the game. How would I do that?
evildaddy911




PostPosted: Sun Jan 06, 2013 10:31 am   Post subject: Re: clear screen procedure in Turing for a game?

this is not actual code for a game. this is simply just an explanation of what Tony and Raknarg were suggesting.
"clear," "DoStuff," and "DrawGame" are not predefined, you would have to define them yourself.
The question popup would similarly be included in the do/draw stuff sections:
Turing:

if Rand.Real <= 0.2 then % 20% chance to clear
    clear := true
    GetInput()  %  gets user's answer to the question
else
    clear := false
end if
DoStuff()
% draw stuff section
if clear = true then
    % removed "cls" as that should be included in "DrawPopUp()"
    DrawPopUp()  % draws the question box onscreen
else
    DrawGame()
end if

remember: these are basic guidelines for how to solve this type of problem, some models may be better for this situation. do not copy and paste the code
neuro.akn




PostPosted: Mon Jan 07, 2013 12:01 pm   Post subject: RE:clear screen procedure in Turing for a game?

Ok, great. This should help a lot. Thank you!
neuro.akn




PostPosted: Fri Jan 11, 2013 1:46 pm   Post subject: RE:clear screen procedure in Turing for a game?

Given my code, these guidelines for "DoStuff," "DrawGame," etc. will not work. I tried calling them and there was a lot of errors, Upon correcting these errors, the game did not run properly, and it basically messed up the entire program. However, I rearranged everything and got my original code in order. Is there any other way that I can create a procedure to clear the screen after a certain amount of time (using a timer)?
Tony




PostPosted: Fri Jan 11, 2013 4:02 pm   Post subject: Re: RE:clear screen procedure in Turing for a game?

If you don't have a single spot in the code where you can say "for this turn of the game, I have not yet drawn anything, but I'm about to start" and another single spot where you can say "I have finished drawing everything for this turn and am ready to push it to screen", then you are working with a very complicated design.
neuro.akn @ Fri Jan 11, 2013 1:46 pm wrote:
Is there any other way that I can create a procedure to clear the screen after a certain amount of time (using a timer)?

In short, no. You could have a timer run some code, but what will end up happening is that as your timer is clearing the screen, the game is still drawing to the screen. The net effect will be that only parts of the game will appear. Your next question will be "my game is flashing like crazy, how do I fix it?" and the response will be just what we said above -- go with a simple game-loop design.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: