<div>Sorry, i&#39;ve sent an unfinished mail  ...</div><div>Second try :</div><div><br></div><div>The problem : synchronizing an instance of a class gameEngine which starts instances of classes which implement transition screen / game levels.</div>
<div>Pseudo-level code : </div><div><br></div><div>Game engine</div>- start introscreen<div>- wait semaphore</div><div>-start level 1</div><div>- wait semaphore</div><div>- start level 2</div><div>-wait semaphore</div><div>
- start finished screen </div><div><br></div><div>See example of code in Squeak with semaphore in my previous mails.</div><div>I wonder why the code is freezing.</div><div><br></div><div>Thanks for any help.</div><div><br>
</div><div>Patrick Dudjalija</div><div><br></div><div><br></div><div><br></div><div><div class="gmail_quote">2012/8/15 patrick dudjalija <span dir="ltr">&lt;<a href="mailto:patrick.dudjalija@gmail.com" target="_blank">patrick.dudjalija@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Chris ! <div><br></div><div>Thank you for the link. Free books of Stephane Ducasse are inderdeed a *MUST*.</div><div>
<a href="http://stephane.ducasse.free.fr/FreeBooks.html" target="_blank">http://stephane.ducasse.free.fr/FreeBooks.html</a></div>
<div>(BTW, everybody should consider a little donation to support him)</div><div><br></div><div>I&#39;m realizing that my question is unclear.</div><div>Let me have a new try in pseudocode.</div><div><br></div><div>The problem : synchronizing an instance of a class gameEngine which starts instances of transition screen / game levels.</div>

<div><br></div><div>Game engine</div><div> </div><div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote">2012/8/15  <span dir="ltr">&lt;<a href="mailto:beginners-request@lists.squeakfoundation.org" target="_blank">beginners-request@lists.squeakfoundation.org</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
        <a href="mailto:beginners@lists.squeakfoundation.org" target="_blank">beginners@lists.squeakfoundation.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:beginners-request@lists.squeakfoundation.org" target="_blank">beginners-request@lists.squeakfoundation.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:beginners-owner@lists.squeakfoundation.org" target="_blank">beginners-owner@lists.squeakfoundation.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Beginners digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Simple semaphore to synchronize instances of different<br>
      classes (patrick dudjalija)<br>
   2. Re: Simple semaphore to synchronize instances of different<br>
      classes (Chris Cunnington)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 14 Aug 2012 21:24:06 +0200<br>
From: patrick dudjalija &lt;<a href="mailto:patrick.dudjalija@gmail.com" target="_blank">patrick.dudjalija@gmail.com</a>&gt;<br>
Subject: [Newbies] Simple semaphore to synchronize instances of<br>
        different       classes<br>
To: beginners &lt;<a href="mailto:beginners@lists.squeakfoundation.org" target="_blank">beginners@lists.squeakfoundation.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAEMqm6GttreSY5i+SA=Hg1=<a href="mailto:C8sAszQOu63miV_R5cfAW5a77Sw@mail.gmail.com" target="_blank">C8sAszQOu63miV_R5cfAW5a77Sw@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<div><div class="h5"><br>
<br>
Hi everybody !<br>
<br>
I&#39;m developing an educative game.<br>
I&#39;ve written a &quot;gameEngine&quot; class which does the logic for the general<br>
progression in the game : switching between instances of morph<br>
subclasses which implement intro screen / mini-games/levels / end<br>
screen etc ...<br>
<br>
Now, i need to synchronize the instance of the gameEngine class with<br>
the instances of the other classes.<br>
Example : once the gameEngine starts the instance of a morph subclass<br>
which implements a mini-game, it must sleep until the mini-game is<br>
finished, and then wake up and does further required switching (next<br>
mini-game or intro screen or end screen ...).<br>
<br>
i thought that a &quot;simple&quot; semaphore would quickly give a solution to<br>
the problem.<br>
But i get a freezed code.<br>
<br>
I&#39;ve modelized/simplified the problem with the following workspace code.<br>
See also fileout of Class TestSynchro as attachment.<br>
TestSynchro has a step method which prints some lines to Transcript,<br>
then calls the method stopStepping and signal to the semaphore.<br>
The workspace code does a wait, before printing to Transcript &#39;Hello World&#39;!<br>
<br>
Problem is that the code freezes , on the line code -&gt; sem wait<br>
I first thought that the code freezed because in the same process. And<br>
added a fork to the block which creates instance of TestSynchro. But<br>
it does&#39;nt help ...<br>
<br>
Any help will be appreciated !<br>
Thanks by advance,<br>
<br>
Patrick Dudjalija<br>
<br>
<br>
<br>
|ts sem|<br>
<br>
sem:=Semaphore new.<br>
<br>
[ts:= TestSynchro new.<br>
ts semaphore:sem.<br>
ts openInWorld.<br>
ts start.] fork.<br>
<br>
sem wait.<br>
Transcript cr; show:&#39;Hello world !&#39;;cr.<br></div></div>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: TestSynchro.st<br>
Type: application/octet-stream<br>
Size: 2201 bytes<br>
Desc: not available<br>
Url : <a href="http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/8d30cdd2/TestSynchro-0001.obj" target="_blank">http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/8d30cdd2/TestSynchro-0001.obj</a><br>


<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Tue, 14 Aug 2012 16:07:36 -0400<br>
From: Chris Cunnington &lt;<a href="mailto:smalltalktelevision@gmail.com" target="_blank">smalltalktelevision@gmail.com</a>&gt;<br>
Subject: Re: [Newbies] Simple semaphore to synchronize instances of<br>
        different       classes<br>
To: <a href="mailto:beginners@lists.squeakfoundation.org" target="_blank">beginners@lists.squeakfoundation.org</a><br>
Message-ID: &lt;<a href="mailto:502AB008.3030104@gmail.com" target="_blank">502AB008.3030104@gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<div><div class="h5"><br>
<br>
On 12-08-14 3:24 PM, patrick dudjalija wrote:<br>
&gt; Hi everybody !<br>
&gt;<br>
&gt; I&#39;m developing an educative game.<br>
&gt; I&#39;ve written a &quot;gameEngine&quot; class which does the logic for the general<br>
&gt; progression in the game : switching between instances of morph<br>
&gt; subclasses which implement intro screen / mini-games/levels / end<br>
&gt; screen etc ...<br>
&gt;<br>
&gt; Now, i need to synchronize the instance of the gameEngine class with<br>
&gt; the instances of the other classes.<br>
&gt; Example : once the gameEngine starts the instance of a morph subclass<br>
&gt; which implements a mini-game, it must sleep until the mini-game is<br>
&gt; finished, and then wake up and does further required switching (next<br>
&gt; mini-game or intro screen or end screen ...).<br>
&gt;<br>
&gt; i thought that a &quot;simple&quot; semaphore would quickly give a solution to<br>
&gt; the problem.<br>
&gt; But i get a freezed code.<br>
&gt;<br>
&gt; I&#39;ve modelized/simplified the problem with the following workspace code.<br>
&gt; See also fileout of Class TestSynchro as attachment.<br>
&gt; TestSynchro has a step method which prints some lines to Transcript,<br>
&gt; then calls the method stopStepping and signal to the semaphore.<br>
&gt; The workspace code does a wait, before printing to Transcript &#39;Hello World&#39;!<br>
&gt;<br>
&gt; Problem is that the code freezes , on the line code -&gt; sem wait<br>
&gt; I first thought that the code freezed because in the same process. And<br>
&gt; added a fork to the block which creates instance of TestSynchro. But<br>
&gt; it does&#39;nt help ...<br>
&gt;<br>
&gt; Any help will be appreciated !<br></div></div>
&gt; Thanks by ad2vance,<div class="im"><br>
&gt;<br>
&gt; Patrick Dudjalija<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; |ts sem|<br>
&gt;<br>
&gt; sem:=Semaphore new.<br>
&gt;<br>
&gt; [ts:= TestSynchro new.<br>
&gt; ts semaphore:sem.<br>
&gt; ts openInWorld.<br>
&gt; ts start.] fork.<br>
&gt;<br>
&gt; sem wait.<br>
&gt; Transcript cr; show:&#39;Hello world !&#39;;cr.<br>
&gt;<br>
&gt;<br></div>
&gt; _______________________________________________<br>
&gt; Beginners mailing list<br>
&gt; <a href="mailto:Beginners@lists.squeakfoundation.org" target="_blank">Beginners@lists.squeakfoundation.org</a><br>
&gt; <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br>
<a href="http://stephane.ducasse.free.fr/FreeBooks/GuzdialBookDrafts/BuildUI-ch5.pdf" target="_blank">http://stephane.ducasse.free.fr/FreeBooks/GuzdialBookDrafts/BuildUI-ch5.pdf</a><br>
<br>
I don&#39;t know much about this stuff, but using Semaphore for animations<br>
seems too low level. Pg. 53 of this pdf describes how step and stepTime<br>
work.<br>
<br>
HTH,<br>
Chris<br>
<br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/b2a5039f/attachment-0001.htm" target="_blank">http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/b2a5039f/attachment-0001.htm</a><br>


<br>
------------------------------<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org" target="_blank">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br>
<br>
End of Beginners Digest, Vol 76, Issue 5<br>
****************************************<br>
</blockquote></div><br></div>
</blockquote></div><br></div>