Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Best Approach for Bejeweled like  (Read 2239 times)
0 Members and 2 Guests are viewing this topic.
Offline ReBirth

JGO Wizard
****

Posts: 1271
Medals: 19



« on: 2011-02-12 23:17:13 »

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.

Offline bobjob

JGO Ninja
***

Posts: 646
Medals: 14


David Aaron Muhar


« Reply #1 on: 2011-02-13 00:07:46 »

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

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline IronclawsBt

JGO n00b
*

Posts: 47
Medals: 4



« Reply #2 on: 2011-02-13 09:47:40 »

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.

It's not what you know, it's what other people think you know.
Just hope you don't get quizzed on it.
Game engine design tutorials
Games published by our own members! Go get 'em!
Offline kearnel

JGO n00b
*

Posts: 3



« Reply #3 on: 2011-02-16 10:51:52 »

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. Wink
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #4 on: 2011-02-16 11:22:44 »

The demo game for Slick is a Bejeweled game called Kitipong. Source is here:

https://bob.newdawnsoftware.com/repos/slick/trunk/SlickPuzzle/

Kev

Offline ReBirth

JGO Wizard
****

Posts: 1271
Medals: 19



« Reply #5 on: 2011-02-17 22:36:14 »

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
1  
2  
3  
4  
5  
6  
7  
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();
}

The demo game for Slick is a Bejeweled game called Kitipong. Source is here:

https://bob.newdawnsoftware.com/repos/slick/trunk/SlickPuzzle/

Kev
My browser reports invalid security issue when trying to open that page.

Offline ra4king

JGO Kernel
*****

Posts: 3149
Medals: 196


I'm the King!


« Reply #6 on: 2011-02-17 23:32:36 »

https://bob.newdawnsoftware.com/repos/slick/trunk/SlickPuzzle/src/puzzle/Puzzle.java

just click continue, there is nothing wrong with the website

Offline ReBirth

JGO Wizard
****

Posts: 1271
Medals: 19



« Reply #7 on: 2011-02-19 21:50:22 »

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!  Cool 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  Grin

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.063 seconds with 19 queries.