#define MAP_SIZE 300
#define BLOCK_SIZE 50
int map[MAP_SIZE][MAP_SIZE]; // grid of blocks BLOCK_SIZE by BLOCK_SIZE each
class Ship {
public:
int x; // between 0 and MAP_SIZE
int y;
short subx; // between 0 and BLOCK_SIZE
short suby;
Ship( int xc, int yc, int sx, int sy ) : x(xc), y(yc), subx(sx), suby(sy) {};
int move( int xc, int yc ) { x = xc; y = yc; };
int blockmove( int sx, int sy ) { subx = sx; suby = sy; };
};
Ship ship( 0, 0, 0, 0 ); // ship is now on block 0,0, positioned in block at 0,0
ship.move( 20, 30 ); // ship is now on block 20,30
ship.blockmove( 30, 22 ); // ship is still at block 20, 30, but is positioned in the block at 30,22
Disregarding the current codebase, and looking at it from a pure design viewpoint:
* In general design what are the best methods for creating a large grid system?
* What should it include?
* What should I avoid?
* Any coded examples to look at? (codebase and language doesn't matter)
I look forward to any thoughts from you fine folks.