Embedding morphs at specific points in a morph?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Embedding morphs at specific points in a morph?

Dave_Programmer
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@35)]
        ifFalse:[self addMorph:(scoreEllipse at: 72.5@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.

Thank you for your time
--
David Tennant

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding morphs at specific points in a morph?

Dan Norton
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@35)]
>         ifFalse:[self addMorph:(scoreEllipse at: 72.5@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

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding morphs at specific points in a morph?

Phil B
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@35)]
> >         ifFalse:[self addMorph:(scoreEllipse at: 72.5@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
> [hidden email]
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org



_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding morphs at specific points in a morph?

KenDickey
In reply to this post by Dave_Programmer
On Mon, 20 Jul 2015 16:18:13 -0600
David Tennant <[hidden email]> wrote:

> 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).
>         ].

I don't know what "CircleEllipse new" does (e.g. is the radius zero?), but I would note that you are adding the same morph at different positions.

I suspect each position would like its own morph.

--
-KenD

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
-KenD