Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

(I cross-posted this from StackOverflow as this seems to be a more appropriate f̶o̶r̶u̶m̶ community. I've looked around a little here and I did not find an answer, so I hope this is not a recurring question.)

This is a question dealing with 2D world design.

I am playing around by creating a 2D bird's eye view shooter game, and I am looking to make the game sleek and advanced. I hope to be able to write physics so projectiles have momentum and knock-down properties.

I am immediately running into the problem of world design.

I need a way to have level files that store everything there is about a game. This is easiest by just having a grid of objects. But there are thin-walls and other objects that don't seem to fit into a traditional cell of a grid. I want to be able to fit all these together so I can streamline level design; so I don't have to put in the exact pixel-specific start and end of a wall.

There doesn't seem to be an obvious translation from level file to game without forcing myself into a pacman-life scenario, meaning a scenario where the game feels boxy and discrete. There is a contrast between the smoothly (relatively) moving characters and finite jumps in a grid.

I would appreciate an answer that would describe implementation options or point me to resources that do. I would also appreciate references to sites that teach game design.

The language I am using is Java (although I would love to use C or C++, but I can never find convenient resources in those languages).

Thank you for any answers. Please leave any questions in the space below; I will be able to answer them later tonight (28th Nov).

Answering Questions:

I will definitely consider using a game engine; I wanted to write a lot of it myself, but I am rethinking gradually.

Perhaps there is no answer to this question that I will "like", and the process is just inherently a bit tedious.

I meant to find a way to easily specify things like "wall goes here" without saying "add wall at 293, 195 with width 123 and height 5". This of course, is easy by dividing the game world into a grid. But dividing a gameworld into a grid is not ideal, because it has to deal with things like objects taking up more than one grid, objects being irregularly shaped and taking up only part of the grid, etc..

I've had more time to think about this, and I think that there is no way to "gridify" my world without losing some major functionality, and so I think I will have to create a world editor, where I can more easily create levels.

I still foresee problems though, specifically with AI. I need to have pathfinding capabilities, and so the algorithms naturally have some sort of search-space reduction, which is essentially making a grid. I will have to read more about this.

Until then I would still appreciate answers and suggestions on this design choice. I hope this clarifies my question - if it does not, please direct a question and I can try to answer it.

(Storing object locations is the only practical way to do any of this, I now realize).

share|improve this question
1  
Pedantic mode: this isn't a forum. It's a Q&A site. I really mean this as a good-hearted nudge in the ribs. :) –  Almo Nov 28 '12 at 22:24
8  
What's wrong with storing positions of objects? Also, if you're making a game, I strongly suggest you use a professional, pre-built physics engine. It's hard to concentrate on solving many problems, and you could easily lose motivation. –  jco Nov 28 '12 at 22:30
2  
Can you clarify your actual question? I don't understand what you mean by "simplify a 2D game grid while keeping its by-pixel features". Maybe a diagram would help? –  Nathan Reed Nov 28 '12 at 22:36
1  
@Bane You are definitely right. I am still warming up to the idea of a game engine; for me, it is almost always about the process and not the result (being a hobbyist). –  Eric Thoma Nov 29 '12 at 3:55
1  
"Until then I would still appreciate answers and suggestions on this design choice. I hope this clarifies my question - if it does not, please direct a question and I can try to answer it." Okay, here it is: What is your question? –  Marton Nov 29 '12 at 8:21
show 4 more comments

1 Answer 1

up vote 1 down vote accepted

(Storing object locations is the only practical way to do any of this, I now realize).

That says everything. Store your objects location by-pixel or using floats in your level file.

Now if you need a grid layout for something else (for instance pathfinding), you'll have to use some kind of approximation. E.g. consider a square occupied if there's at least one object inside. Or if some kind of object is inside.

You could also forget completely the idea of using a discrete grid, and go for another technique, e.g. waypoints or a navmesh for pathfinding.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.