[Newbie] Project design problem

stéphane ducasse ducasse at iam.unibe.ch
Sun Oct 2 07:42:45 UTC 2005


Hi charles


may you want to have a look at the BreakOut I wrote a while back,  
because teaming Morphic is sometimes not trivial.


> Please, any advice or suggestions would be appreciated.
>
> I thought that as my first "major" Squeak project, I'd translate a  
> game that I had written in Ruby...but the concept seems wrong.
>
> In the original game a tile (gtk: label) with a series of letters  
> would display at the top of the screen, and below it there would be  
> four pictures (xpm, gif, whatever was convenient) on "buttons".   
> Clicking the button that matched the tile would advance to a new  
> scenario with a different label and different pictures.   (In this  
> particular game it was music note names and images of the note on  
> either a bass or a treble staff.)
>
> In the original, the images were left on the disk, and only read in  
> as needed (to conserve memory).

I would suggest you to load them and save them as class method. Have  
a look at MenuIcon to get an idea

importIconNamed: aString
     "self importIconNamed: 'Icons16:appearanceIcon'"


     | writer image stream |
     writer := GIFReadWriter on: (FileStream fileNamed: aString,  
'.gif').
     [ image := writer nextImage]
         ensure: [writer close].
     stream := ReadWriteStream on: (String new).
     stream nextPutAll: aString ; cr.
     stream nextPutAll: (self methodStart: aString).
     image storeOn: stream.
     stream nextPutAll: self methodEnd.
     MenuIcons class compile: stream contents classified: 'accessing  
- icons' notifying: nil.
     ^ stream contents


> In Squeak...well, in the first place I can't figure out how to read  
> a note and place it on a button (which is only then "opened in the  
> world").  Squeak appears to want the images to be read in ahead of  
> time, one by one, and placed by hand, but I suspect that this is my  
> inexperience. Also, when the image is read in, it seems to be  
> assigned an arbitrary ID (reasonable), but what I would want to do  
> is to store them in an ordered collection, and access them by ????  
> name? index? octave?
>
> If I could read in an image and place it into a button, then I  
> could do a straight translation.  But would this be the proper  
> approach?  I thought I might find the proper approach by studying  
> the code for the FreeCell game, as in many ways it appears to be a  
> similar problem, but the approach they take appears to be drawing  
> the images on the fly, and the thought of trying to program the  
> drawing of bass and treble signs fills me with such trepidation  
> that I feel this MUST be the wrong approach.

Stef




More information about the Squeak-dev mailing list