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

Username:   Password: 
 RegisterRegister   
 How can I fork processes who all have loops/for loops in them and get them to run smoothly?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TuringStudent




PostPosted: Thu Jun 09, 2011 5:05 pm   Post subject: How can I fork processes who all have loops/for loops in them and get them to run smoothly?

What is it you are trying to achieve?
I am designing a video game for class in which I have a small blue square moving across a rectangular playing field (an image file that is drawn inside a loop that also deals with the movement of my square using array char of boolean and arrow keys). On my playing field I also have enemies who are circles with drawfilloval commands who move in an alternating up/down fashion. In my code I have a process which draws enemies moving from bottom to top and a process which draws enemies moving from top to bottom, inside of which I fork the first drawing enemies process. On top of this, I have a procedure to run this first level of my game where I call my procedure to move my player as well I fork the latter draw enemies process so that I can be moving across the playing field AND have my eneimes moving up and down.
Premise: How can I fork these processes effectively?

What is the problem you are having?
<Answer Here>
Main Problem: When I try to fork the processes the screen flashes many times as well as my enemies being drawn and the player icon I use (a small square pic file). I have View.Update commands and everything but still get the flashing; can anyone help?
I attached the code to give you an idea of how I fork my processes and all that.


Describe what you have tried to solve this problem
<Answer Here>
I have tried to instead put all the for loops which deal with the up/down movement of my enemies on the playfield inside of my procedure to move my player icon however when I do this, the for loops never terminate and thus I cannot move my player icon nor draw my level (also called inside of the move player procedure). I have also tried having the procedure to run my first level call the processes to draw my enemies (which i then changed to procedures so I could call them) and instead have an if hasch command inside these draw enemy procedures so that I could possibly move my player icon whilst drawing the enemies but this does not work either.

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

Turing:


<Add your code here>



Please specify what version of Turing you are using
Turing 4.1.1



gameportion.t
 Description:

Download
 Filename:  gameportion.t
 Filesize:  6.27 KB
 Downloaded:  72 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jun 09, 2011 5:22 pm   Post subject: Re: How can I fork processes who all have loops/for loops in them and get them to run smoothly?

TuringStudent @ Thu Jun 09, 2011 5:05 pm wrote:
When I try to fork the processes ... I have View.Update commands and everything but still get the flashing; can anyone help?

Processes break View.Update. The only way to avoid flashing is to not use processes.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
TuringStudent




PostPosted: Thu Jun 09, 2011 6:18 pm   Post subject: RE:How can I fork processes who all have loops/for loops in them and get them to run smoothly?

Okay thank you Tony; would be able to suggest any other method to run two loops at the same time but not nested inside each other?
Insectoid




PostPosted: Thu Jun 09, 2011 6:42 pm   Post subject: RE:How can I fork processes who all have loops/for loops in them and get them to run smoothly?

The simple answer is, don't. There's no need. Instead of trying to make things happen at the same, make them look like they're happening at the same time. For example, your program should look like this:

code:

loop
    %move player a tiny bit
    %move enemies a tiny bit
    %everything else
end 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  [ 4 Posts ]
Jump to:   


Style:  
Search: