http://pastebin.com/v4Jd1yTc
hi I am following a tutorial which shows how to create tileMap game in java. But i cant seem to understand some of the methods and variables. main code i post it on pastebin.com take a look.
problem is I cant seem to understand what is method calculateCorner s is doing.
first question is:
i understand that topLeft, are booleans to check if player can move there or not. But why only 4 boolean? dont you need "top, topLeft, topRight, etc" what is player just jump up? than dont you get boolean "top".
2nd question is:
can you guys explain "int leftTile, rightTile .. etc" variables?
also why we are doing (x-width/2)?
also try to explain as much as you can bc i dont understand this.
hi I am following a tutorial which shows how to create tileMap game in java. But i cant seem to understand some of the methods and variables. main code i post it on pastebin.com take a look.
problem is I cant seem to understand what is method calculateCorner s is doing.
Code:
calculateCorners(x, toy);
/*******************************/
/*** calculateCorners method ***/
public void calculateCorners(double x, double y) {
int leftTile = tileMap.getColTile((int) (x - width / 2));
int rightTile = tileMap.getColTile((int) (x + width / 2) - 1);
int topTile = tileMap.getColTile((int) (y - height / 2));
int bottomTile = tileMap.getColTile((int) (y + height / 2) - 1);
// check if player can move to tiles
// 0 = cant move up
topLeft = tileMap.getTile(topTile, leftTile) == 0;
topRight = tileMap.getTile(topTile, rightTile) == 0;
bottomLeft = tileMap.getTile(bottomTile, leftTile) == 0;
bottomRight = tileMap.getTile(bottomTile, rightTile) == 0;
}// End of calculateCorners
first question is:
i understand that topLeft, are booleans to check if player can move there or not. But why only 4 boolean? dont you need "top, topLeft, topRight, etc" what is player just jump up? than dont you get boolean "top".
2nd question is:
can you guys explain "int leftTile, rightTile .. etc" variables?
also why we are doing (x-width/2)?
also try to explain as much as you can bc i dont understand this.
Comment