CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 120 users online: 11 members, 80 guests and 29 bots.
Members: ACagliano, HOMER-16, lakshminarayan rajaram, Link, rcfreak0, rfdave, Runer112, Tari.
Bots: Spinn3r (1), MSN/Bing (2), Magpie Crawler (3), VoilaBot (1), Googlebot (21), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
swivelgames


Transient Squash


Joined: 27 Sep 2005
Posts: 2345
Location: On the planet called Earth

Posted: 31 Jan 2012 12:20:52 pm    Post subject: Determining State of Dynamic and Collective Entities

Hey all,

I'm sure if I took the time to think this out on paper and really check all the different possibilities I could come up with the solution, but the problem is time. I just don't have much of it.

Right now I'm writing a 2D JavaScript sandboxing game. I have been itching to build one of these for a very, very long time. I finally had a good idea surrounding it and decided to tackle it.


The big issue with sandboxing games is determining when to call multiple entities one collective entity. What I mean by this is, when I build a square out of the same sprite, those four sprites should now turn into their respective corner sprites.

After a lot of thinking, I decided the easiest way to accomplish this would be to create a sprite sheet for each material in the collective state, and then point to the cell desired when the surrounding entities request it.

Example:
rock.png, where each sprite is 32x32

Code:
[Top Left Corner Sprite]     [Top Center Sprite]            [Top Right Corner Sprite]
[Center Left Sprite]         [Center Center (main) Sprite]  [Center Right Sprite]
[Bottom left Corner Sprite]  [Bottom Center Sprite]         [Bottom Right Corner Sprite]


Making other types of corners (like inset corners) is easily done by combining sprites.


The more complex side we can get to later. The main issue I'm having is writing efficient and optimized code to determine the current (and adjacent) entity's states properly.


Placing a lone entity should use the center center sprite. This is the main ground texture. But if I put two rock entities next to each other, they should utilize Top Left and Top Right Corner Sprites respectively. This is very easy to determine, but it gets more complex depending on the angles, and especially with multiple adjacents. The can of worms it opens up is having to check each adjacents' states, as well as possibly having to check (and change, possibly?) *their* adjacents.


I was hoping someone here could help me out with this at all. In a regular game, its easy to just manually choose all the sprites to be placed on the map. But when the world is constantly changing, it makes it very difficult to determine the state with all the possibilities.
Back to top
swivelgames


Transient Squash


Joined: 27 Sep 2005
Posts: 2345
Location: On the planet called Earth

Posted: 31 Jan 2012 10:36:38 pm    Post subject:

Thanks to Kerm for pointing me in a direction. (Posting on his behalf, for any one curiously browsing this thread).

He mentioned Convergence algorithms as well as the Game of Life.

Upon researching conway's algorithms, as well as others, I found a great match to what I was looking for. A very informative couple of chapters in "Graphics Programmers Black Book."

Check it out here: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/graphics-programming-black-book-r1698

Chapter's 17 and 18 are what you're looking for.


Source: Chris Marasti-Georg, of stackoverflow
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.023386 seconds.