I’m trying to create clone of Bejeweled game where you must swap two piece to get combo. When designing the game board, I stuck on how can I update the list of the pieces after a combo appeared (when the rest above it collapse and new pieces come from sky to fill). I tried to use ArrayList and two dimensional array but stucked because the combo can come in horizontal or vertical. It’s hard to arrange index of the pieces. What do you think the best approach for this?
Thanks for reply.
Sorry never really worked on that style of game, so not sure of the best way to approach it, but I found this applet interesting. Hopefully you can track down the source
GemGame
Since your board has a fixed size, you could probably just use a two dimensional array. Otherwise, you could put a an array of array lists in another class. Then program convenience methods such as get(int row, int col) and remove(row, col) which would be pretty strait forward.
The way I would do it would be to use a two dimensional array to store the gems. I would also make my own “Gem” object. Then when the user makes three in a row I would delete the Gems that made that three-in-a-row. Next I would momentarily stop receiving user input while I play the falling gem animation.
I hope this is what your looking for.
The demo game for Slick is a Bejeweled game called Kitipong. Source is here:
https://bob.newdawnsoftware.com/repos/slick/trunk/SlickPuzzle/
Kev
Thanks for replies everyone.
Seems two dimensional array is the best choice. The reason why I stucked on ArrayList is caused by its ability to arrange the index so no null value on middle of two value. I’m thinking to try something like
public Gem[] arrange(Gem[] combodArray){
ArrayList a = new ArrayList();
for (i=0;i<combodArray.length;i++)
if (Gem[comboRow][i] != null)
a.add(Gem[comboRow][i])
return a.toArray();
}
My browser reports invalid security issue when trying to open that page.
https://bob.newdawnsoftware.com/repos/slick/trunk/SlickPuzzle/src/puzzle/Puzzle.java
just click continue, there is nothing wrong with the website
Firefox doesnt let me go futher so I try Chrome and get it. Hope can implement it on java2d because I dont use slick2d.
update:
I have read it and that’s cool for using 3d array! 8) however I can’t see method where you
-check for combo on all showed kitty?
-make new kitties falling from the top?
the rest is fine ;D