This site requires JavaScript, please enable it in your browser!
Greenfoot back
Zzimon
Zzimon wrote ...

2014/5/1

Selecting characters and switching them with others

4
5
6
7
8
9
10
danpost danpost

2014/5/3

#
To clarify, it will NOT make the move selected UNLESS a matching set is created by the move.
Zzimon Zzimon

2014/5/3

#
Ok, I think I understand how this thing works. If I match 3 it will make it impossible to un-match those 3 unless I match a new set right? Though as I'm seeing it now it seems like there is some loopholes through this. EDIT: ok that's not really what it does hmm.
danpost danpost

2014/5/3

#
Zzimon wrote...
Though as I'm seeing it now it seems like there is some loopholes through this.
There is a flaw in the logic. The loops were not being told to stop when a non-matching tile was found. I will post corrected code shortly.
Zzimon Zzimon

2014/5/3

#
Ok, now I've got it and I think it works exactly as it should according to your clarification :) so that a tile can only move if it somehow creates another set, now we just need the sets that get created by moving them around to be 'deleted' and then replace the tile set with other tiles that won't make up a set
danpost danpost

2014/5/3

#
Change the match counting method to the following:
private int getHorizontalMatchCount(int x, int y, Class cls)
{
    int count = 0;
    for (int n=1; n<3 && x-n >= 0; n++)
    {
        if (getObjectsAt(x-n, y, Tile.class).get(0).getClass() == cls) count++;
        else break;
    }
    for (int n=1; n<3 && x+n < getWidth(); n++)
    {
        if (getObjectsAt(x+n, y, Tile.class).get(0).getClass() == cls) count++;
        else break;
    }
    return count;
}

private int getVerticalMatchCount(int x, int y, Class cls)
{
    int count = 0;
    for (int n=1; n<3 && y-n >= 0; n++)
    {
        if (getObjectsAt(x, y-n, Tile.class).get(0).getClass() == cls) count++;
        else break;
    }
    for (int n=1; n<3 && y+n < getHeight(); n++)
    {
        if (getObjectsAt(x, y+n, Tile.class).get(0).getClass() == cls) count++;
        else break;
    }
    return count;
}
Zzimon Zzimon

2014/5/3

#
Ok, well now it's just for the removing the sets and replacing them with non-matching tiles right? :)
danpost danpost

2014/5/3

#
Well, what are we going to need for that. Two more methods (one for horizontal and one for vertical) to remove and replace the matching tile set(s) (I am noting that the tiles that were used in the swap could both create matching sets and the tiles could each create both a horizontal and a vertical set). I am just hoping and praying that there will not be a situation where no tile type can be placed without creating a matching set during the replacing stage (that would make it so much more difficult to code). Unfortunately, I believe that is a strong possibility and must be dealt with when replacing the tiles. And I reallllllly hope that the following possibility has zero chance of occurring: that it would be impossible to replace the removed tiles without creating a matching set somewhere. I feel that would just ruin your morning.
danpost danpost

2014/5/3

#
The thing is you have 3 tile types and if after a swap and three tiles are removed, it would be possible, since the outer two tile positions have three possible routes to it and the middle one has two, that 2 of the three types cannot go in those three location and there must all be the third type, which would be a match in itself. Ergo, your morning is ruined.
Zzimon Zzimon

2014/5/3

#
Yeah that would be quite the bummer, though if it is just possible to make one with a low risk of it happening and if that in some way could be easier I would be more than fine with that ^^
danpost danpost

2014/5/3

#
Example:
//  ABCACBA
//  BACACAB
//  AA   CC
//  CBACABC
//  BCACACB
Let us say the three inside ones were 'BAB' and a 'B' was above the 'A' and those two were swapped. We cannot put an 'A' or a 'C' in any position, so all position must be replaced with a 'B' which makes 'BBB' in the middle.
Zzimon Zzimon

2014/5/3

#
would a fourth tile type fix it? The amount of different tiles isn't a problem, as long as the board isn't so crowded that it would be impossible to make any matches at all
danpost danpost

2014/5/3

#
A fourth tile type would do the trick (it was exactly what I was thinking).
Zzimon Zzimon

2014/5/3

#
Awesome :) that can't be super-hard to implement
danpost danpost

2014/5/3

#
It should be quite simple to duplicate a subclass of Tile. Not including the image itself, you could probably type out the class in maybe five seconds or so. Then adjusting the 'prepare' method in your Bejeweled_World class should take maybe another 5 seconds or so.
Zzimon Zzimon

2014/5/3

#
yeah the class would be quite easy but the rest of the code still has to be altered to use the last actor
There are more replies on the next page.
4
5
6
7
8
9
10