I have a game grid represented by an array of 50x50 dimension. I want to draw walls on the grid, so each wall segment will be between 2 sets of (X,Y) coordinates. for example, a wall segment may be in between grid square (25,25) and (25,26). So I want to store those values as a pair of pairs, for each wall segment.
[(25,25),(25,26)] should be one object,
[(26,25),(26,26)] would be another, and so on.
I want to store these, and I want to be able to look up this collection, each time a player is moving to another grid square, to see if there is a wall in between the squares.
another possible issue is that the player may be moving from (26,26) to (26,25) or vice versa, either way there will be a wall segment there... so I may have to check both values, or store 2 values ovjects for each wall segment, like so:
[(26,25),(26,26)] [(26,26),(26,25)]
both representing the same wall segment, but easier to look up?
Anyone got ideas? because it seems there must be a simpler way...
An example of how I'm trying... unsure how to store these segments, and parse them:
@implementation gridSeg
-(id)initWithX:(int)X withY:(int)Y{
self = [super init];
self.Xcoord = X;
self.Ycoord = Y;
...
@implementation wallSegPair
-(id)initWithSeg:(gridSeg)g1 seg2:(int)g2 withVertical:(bool)vertical{
self = [super init];
self.gridSeg1 = g1;
self.gridSeg2 = g2;
self.vertical = vertical; //maybe not needed
...