[Cuis] Embedding morphs at specific points in a morph?

Dan Norton dnorton at mindspring.com
Mon Jul 20 18:55:38 CDT 2015


On 20 Jul 2015 at 16:18, David Tennant wrote:

> 
> Hi everyone.
> I have been playing arrowed with cuis for a couple of years, but I
> am extremely horrible at it. Every 
> time I attempt to code a program I don't get too far, but this time
> I want to actually make a 
> program that works. So I am trying to make a program that you can
> play mancala with. Mancala is 
> an abstract board game.
> I decided that I should build the board first. the board should look
> something like this 
> http://ecx.images-amazon.com/images/I/51PD0CemQkL._SY300_.jpg . I
> wanted the circles and 
> ovals to be separate classes so that I have more flexibility later.
> I have 3 classes: Board, 
> BigEllipse, and CircleEllipse. In BigEllipse and CircleEllipse I
> just have initialization stuff, like size 
> and color. in Board I have the initialization stuff too, but I also
> have what I thought would create 
> the board, but It does not work. there are two methods, one I called
> "addMyEllipse" and th other I 
> called "addScoreEllipse". these are the methods
>  
> addMyEllipse
> |n|
> 
>     myEllipse:= CircleEllipse new.
>         n:=1.
>         (1to:12) do:[
>             (n<7)
>             ifTrue: [self addMorph: (myEllipse at:
> 35@(35+(60*n)))]
>             ifFalse: [self addMorph: (myEllipse at:
> 110@(35+(60*n)))].
>             n:= (n+1).
>         ].
> note: myEllipse is an instance variable.
> 
> addScoreEllipse
> | n|
> 
>     scoreEllipse:= BigEllipse new.
>     n:=1.
>     (1to:2) do:[
>         (n=1)
>         ifTrue:[self addMorph:(scoreEllipse at: 72.5 at 35)]
>         ifFalse:[self addMorph:(scoreEllipse at: 72.5 at 455)].
>         n=(n+1).
>     ].
> note: scoreEllipse is an instance variable.
> 
> I don't actually know what is wrong. when I type in the workspace:
> Board new openInWorld. I just 
> get the background of the board, no ellipses. and when I type in the
> workspace: test:= Board new 
> openInWorld. test addMyEllipse. I get an error that says, this block
> accepts 0 arguments, but was 
> called with 1 argument.
> 
>
I had the same problem recently in some code that looked like this:

ifExistsDo: [{italicName. ' OK'} print]

The cure was to "expect" an argument, even tho it would not be used:

ifExistsDo: [:x | {italicName. ' OK'} print]

Thanks to Phil for staightening me out.

 - Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150720/6f694e3a/attachment-0004.html>


More information about the Cuis mailing list