• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
zamiel

Bejeweled - How make it possible to remove gem when it fall.

10 posts in this topic

<Language: ActionScript3>

 

Hi I would like to know if anyone know, the algo for removing gems when it fall on a grid. (Like bejeweled style)

With a 2D array of element it seems to be not stable.

 

 

Thanx

0

Share this post


Link to post
Share on other sites

I do not know your language, although your problem should have an simple solution.

 

I also do not know the rules of your game. If getting an (x) number of the same type of jewel is in a row or column then do an element comparison.

 

set up a double For...Next  Loop with the number of elements in your 2D array -1

 then compare 1 element to the next and if they are the same then increment a counter also set a starter element.

  When when reach to elements that do not equal each other exit your loop,  Check your counter.  If the counter is => the minimum number then goto a sub-routine to delete those elements and fill them in with the elements from above.

 

  If I sat down for 30 minutes I could provide you with the algorithym,  But where is the fun in that. 

 

  If you get stuck. Contact me and I will see what I can do.

 

Good Luck.

1

Share this post


Link to post
Share on other sites

I dont see why you think a 2D array would be unstable.  2D arrays are exactly how grids are represented in games.  If you prefer some additional encapsulation. you could use a managed container like a dynamic array.  Additionally, each element in the 2D array could be some kind of "GridCell" class, which contains information about the grid.    You should also create a wrapper class around your 2D grid array which will manage it for you, which has operations such as "dropRow", "dropColumn", "checkForMatches", ect.  Best of luck.

Edited by metsfan
0

Share this post


Link to post
Share on other sites
metsfan

<I dont see why you think a 2D array would be unstable.  2D arrays are exactly how grids are represented in games.>

 

It's because when I destroy a gems the space inside become null but other gems when they fall and goes in that case,

 

 

Poigahn

 

For now I coded all the games. All the Gems are unable to click while they fall. But I want a system more dynamic.

 

0

Share this post


Link to post
Share on other sites

metsfan

<I dont see why you think a 2D array would be unstable.  2D arrays are exactly how grids are represented in games.>

 

It's because when I destroy a gems the space inside become null but other gems when they fall and goes in that case,

 

The 2D array would represent the relative location of the gems in terms of gameplay, but it shouldn't be tied to the actual screen location of the gems. This separation is necessary so that you can do animations while the array is updating.

 

Suppose you clear 3 gems in a column. Your array will now have three zero values (empty areas) in one column, and the algorithm to update the array would be, for every zero value that is in a row below a non-zero value (gems), trade their places. To do this in one pass, you start from the 2nd to bottom row going up and horizontally. Afterwards all your empty spots will be on the top. Then you simply fill these zero spots with random values for new gems.

0

Share this post


Link to post
Share on other sites

I also have never really used action script either, but I have done something similar to a bejeweled clone.  It took me a while to get the blocks to fall properly, but I did manage with a 1D array treated as a 2D array to keep things simple.  Unfortunately, the fine tuned source code was on my old macbook which was stolen about 6 months ago, so I have to redo the changes I made on it.  Fortunately, I remember what I was doing wrong.

 

I'll have to dig up the source on my Notebook PC if you'd like to see.

 

Shogun.

0

Share this post


Link to post
Share on other sites

use a 2D array(or 1D treated as 2D with an stride).  anyway, what i'd do for bejewed is:

 

when a gem is destroyed, instantly update the tile(or gem) list so that internally everything is represented correctly, and you have no null spaces.

 

now then, each tile should also contain a draw position, do not change this value when you are updating the list, just make sure it's retained when you swap tiles around.

 

so, now, even though a gem is destroyed, internally the grid looks correct, however when drawn, the gem should appear as if it's in it's old position, now, on each update tick, move that draw position where it's suppose to be on the grid, this should create the illusion of the gem falling. 

 

in theory this system can be used for anything, if you want new gems to drop from above the camera, when adding a new gem to the array, simply set the draw position above the camera.  when you swap gems around, you could either instantly set the correct position, or you can just let the gem move to where it's suppose to.

Edited by slicer4ever
0

Share this post


Link to post
Share on other sites

You don't need to "destroy" the gem per-se. Just make some state that represents if there is a gem or not. Like an enum of "Empty" "BlueGem" "GreenGem" etc.

 

Removing a gem would set the 2D array at that position to "Empty" state.

 

If you draw it you check the 2D array and say, if BlueGem -> draw(BlueGemTile) and such. You don't need to tie in your representation of the state of the game (grid of gems) to your visual representation of it (tiles, board, score number, etc). That means that you don't need to represent the "falling" on your grid of gems, just represent it on the visual side (the "falling" tiles), and when it stops "falling", update the actual jewel position on your data grid.

0

Share this post


Link to post
Share on other sites

For the falling movement, determine a "target position" for each of the gems, which are just keyframes for the screen position where the animation ends. Here is where you can use your updated 2D array to find target positions. For example if each gem is 50x50 pixels you would want a gem that's stored at [2, 3] in the array to be 100, 150 when it's in play.

 

Draw the new gems somewhere off the screen or outside the grid, just in the same horizontal position as the row they will fall in. Then keep moving them down until they reach or are past the vertical position. After all gems are in place, the game continues as normal. Then you can re-check for more matches, which is how you would handle combos, cascades, etc.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0