Question on how to proceed(Game programming, kinda long).

This is a discussion on Question on how to proceed(Game programming, kinda long). within the C++ Programming forums, part of the General Programming Boards category; Hi all,
I'm fairly new to programming in C++, though I've been programming for a while in Java, and am ...

Question on how to proceed(Game programming, kinda long).

Hi all,

I'm fairly new to programming in C++, though I've been programming for a while in Java, and am going to begin work on a game(I'm sure you've all heard that quite often). I have a question I'm not certain how to proceed with, and could use some advice.

The game is going to be a 4x TB strategy game set in space, ala Master's of Orion. My problem is this...

I need to have a 2d map upon which I will randomly place Stars and other objects like Nebulas throughout. But I'm not sure how to create the map so that I can place these items. I need to have the method flexible enough so that stars can be placed in a way that does not appear like it's just a regular old grid with every star at the exact center of a block.

The only way I have thought of that I can do this, is by using a 2 dimensional array as the Map. Then designating that a set of 9 entries in the array constitutes another "Block on the grid", so that Items can be placed in varying portions of the "Block on the grid". I.e. the entries on the array corresponding to the numbers below would be one block.

222
111
012

Giving me a center, and "Compass" points in which to place an object, so that it doesn't appear each star is in the exact center of each "Block" it appears in.

My question is this.

Is there an easier way to define a "Grid" based map so that these items could be placed in terms of X,Y coordinates rather than placed in a 2d Array? If so, could someone give me a brief overview on how to do it? I'll also need to be able to save these coordinates to a file.

Not asking for anyone to code it for me, just give me a brief explanation on how it could be done and I'll work it out for myself, as I believe that doing is the better part of learning

Thank you all in advance, and thank you for putting up with what's probably the umpteenth "I'm going to make a game" question you've seen this week!

Is there an easier way to define a "Grid" based map so that these items could be placed in terms of X,Y coordinates rather than placed in a 2d Array?

It seems to me that a 2d array is an x,y coordinate system. If your universe is modeled with a 100 x 100 array, then you can place stars at any spot in the array based on their x,y coordinates. I don't know if that means you'll be placing stars at the center of a block because I don't understand what that means.

Maybe what you want to do is have each grid square store the offset of the object it contains then when you display the grid you draw the object it contains by adding the offsets to x/y co-ordinates of that square.

Maybe what you want to do is have each grid square store the offset of the object it contains then when you display the grid you draw the object it contains by adding the offsets to x/y co-ordinates of that square.

The x,y coordinate is an offset from 0,0. Why create an offset from an offset? Why not just list the total offset from 0,0?