Storing world/map data

Started by Jonathan, January 01, 2006, 19:49:41

Previous topic - Next topic

Jonathan

Hi.  I've been a beginning game devloper for about 5 years.. :)  I've played around with OpenGL a bunch, using C/C++, creating small quick demos here and there.  I've never actually made a playable game.

I'm going to try to make a hybrid soccer game as a simple game to get some game dev. experience with.

Here is a shrunken down version of a simple map:


There's two goals, one for each team, represented by blue rectangles.  There's one soccerball (red) and two players (green).  So it's basically going to be a 2D game with 2D physics (keeping it simple for my first project).

I made the image small for simplicity, but let's say the map was much larger (it might take the player 2-3 minutes to go from one side to the other).  In addition, there can be walls in the middle of the arena.  All walls in the map are solid -- the players cannot pass through them, and the soccer ball will bounce off of them.  The game may be expanded to allow multiple soccer balls on the map at once.

1)  How should I store the world data?

This is probably a complete newbie question, but if you can point me to an article that is more than adequate.

I guess I can simply store the map as a 2D array:
map
  • [y].  Would this be sufficient for my small game?

    2)  I made a breakout/arkanoid type demo, and one issue I ran across was collision detection.  Every frame step, I was testing the collission of the ball with every block in the game.  While this did not hurt performance because of the small number of blocks all on one screen, the new game I'm making will have a much larger map.  Are there common techniques to dealing with this issue?

    Eventually, I'm going to turn this into a networked multiplayer game.  I'm not sure if that will effect your answers.

    Thanks!

Fool Running

The best way to do what you are doing (because the game is 2D) is to create a 2D array that represents the playing field. Usually it is an int array. Every location
  • [y] will tell you what is at that location on the field so you can do collision detection. (this is best for static data).
    For non-static data (balls, players, etc.) you will probably have to loop through all of them to see if they collided.

    Other people can chime in here as my last 2D tile game was in QBasic  :oops:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

elias4444

I'd recommend you check out "Developing Games in Java" by David Brackeen. He goes over quite a bit of game theory that would help you out (all about collision detection and world maps). Basically, he mentions that you should segment your map, and then only check for collisions where you have to (usually just around the player). As for storing your map data, you could basically do that however you like, so long as you know how to read it back in and generate your map from it.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Jonathan

I have it :) lol.  I've only read the multiplayer section though.  Somehow all my free time disappears into this black hole.  I'll put those chapters next on my todo list :) thanks.