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

Phil (list) pbpublist at gmail.com
Mon Jul 20 20:34:16 CDT 2015


Welcome David!

On Mon, 2015-07-20 at 19:55 -0400, Dan Norton wrote:
> 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]
> 
Dan has it exactly right. The (1 to: 12) do: is trying to pass your
block the current value which *is* your n so you should get rid of the
outer n declaration and change the block to accept the parameter like
this:

(1 to: 12) do: [:n| Transcript show: n asString]

Just replace the Transcript statement with your code and you should be
good to go...

> 
> Thanks to Phil for staightening me out.
> 

Glad I could help... while the debugger is always precise as to what is
wrong, it isn't always clear :-)
> 
>  - Dan
> _______________________________________________
> Cuis mailing list
> Cuis at jvuletich.org
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org






More information about the Cuis mailing list