I have been tasked for my project with creating a grid. The grid will cover only the playable area. It will be used to place specific items and environmental objects. the issue i am trying to figure out is how to script it so that the player will be inside the square instead of the corner.
What are you saying? I know the how to ask section says to keep your questions short, but we need some sort of information as to what you're exactly trying to do, no?
the project is a recreation of bomberman. The idea is to use a grid system for accurate placement of the player blocks(both destroyable and non-destroyable) and power ups. Most info i have found in reference to square tile based grids has image placement ending up at the vertex. placement needs to be in the center of the square. The main issue is identifying the grid position.
I have a better idea - don't. Just because the data represents a 2 dimensional object doesn't mean you have to store it 2 dimensionally.
You could for example use a map:
map<pair<int,int>,Object> gridData;
That way you ensure that no grid position is taken twice.
you could also make the position a property of the object
1 2 3 4 5 6 7 8 9 10
class Object
{
private;
int x, y;
public:
Object(int,int);
int getX();
int getY();
int setPos(int, int);
};
Then you'd have to have some other mechanism in place for making sure that no space is taken twice of course. it all depends on the requirements of your system and what is more compatible with what you already have.
(as to displaying, just define an origin and move that around).