Hey guys, i’m working on a pacman clone as we speak and i’ve got a couple simple questions. I’ve set the map up as a 2d array as board[][]. Right now, i’m just looping the array and drawing the block for the tile. I’m going to make a class for drawing the objects/sprites and I realized, I don’t have any way to check collision of the tiles the way I have it as there is no rectangle…it just draws the tile. Should I make a new object for each tile so I can set a rectangle or bounding box for it?
Also, should this class be the same class I use to draw the pacman sprite? I don’t think that would cause any issues, I just don’t know if it would be a good idea to have a separate object for each and every tile. Is there an easier/better way?
Also, when I draw the tiles, they were rotated to the left it seems. I had to play with the values of the x and y and this is what I came up with which draws it correctly, but doesn’t seem correct.
public void draw(SpriteBatch batch) {
for (int y = 0; y < intHeight;y++) {
for (int x = 0; x < intWidth;x++) {
if (Board[x][y]==0) {
batch.draw(blackTile, x*32, -y*32 + 576);
System.out.println("Black");
}
if (Board[x][y]==1) {
batch.draw(blueTile, x*32, -y*32 + 576);
System.out.println("Blue");
}
}
}
}
}
I had to make the y value negative, i’m sure this is because of the reversed Y axis, but then had to add the screensize to the Y value…