Connect Four

krousty_batkrousty_bat Member Posts: 48
edited November -1 in Working with GS (Mac)
He everyone.

I Started to learn this Week the amazing Gamesalad; I am more of an artist than a programmer, but by looking at tutorials, reading "How to's" and Forums, I slowly learning how this is working.

I started a "learning project" to start "simply": making a "Connect Four" game. I am pretty far and everything is working alright for a first try right now, but I'm getting in front of the main problems now: checking the colors of connected pieces to know if 4 colors are placed in a row to display a Player 1 or2 Win message.

I have right now to type of pieces, red or yellow
I was thinking about creating an internal attribute, an integer, for each of them called "Color_type".
Color_type would be = to 1 for all Red pieces
Color_type would be = to 2 for all Yellow pieces.

THe way I thought I would go through this, was that when my last Played Piece is placed (not moving anymore), I wanted to check if a similar Color_type (so same color) would be close vertically then Horizontaly then diagonally, AND if so, check from that one if so again, and increment an Attribute (actual_count) until it reach 4 in the same direction, otherwise, giving the second player a new chip to play.

Well, my problem is that I don't know HOW i can access from my actual played piece to the value of the one close by, so, I don't know how to compare the Color_type of two pieces for it's an "internal" value.

So Do I approach this the wrong way?
should I do this differently ?
Is it possible to do so ?

Thx for any help or ideas you might come with.

Comments

  • krousty_batkrousty_bat Member Posts: 48
    So, I made a test

    Every time a colored piece is touching each other, it increment an internal attribute (counting_to_four).
    so yellow coins start at zero, they will be at 1 both if they touch (same rule, on contact +1 on counting_to_four).

    But then, let's say a third one on top of the two others is coming,
    I will have something like
    1
    2
    1

    and a forth one
    1
    2
    2
    1

    For the increment is only based on contacts, I can never have 4...
    Or maybe, I can say "If 4 consecutive counting_to_four" >=6 then "You win"...
    But how would I Add internal Attributes?

    Or maybe, I can say on contact:
    Change game.AdditionAttribute = Self.Counting_to_four + Game.AdditionAttribute
    Then self.Counting_to_four = game.additionAttribute

    so when the third piece is falling, I can get a
    3
    3
    1

    more complexe than it looks :).
Sign In or Register to comment.