Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //from class Entity
- //position is an XYCoord in Entity
- public XYCoords nextCoord(int direction){
- int nextX = position.x();
- int nextY = position.y();
- if (direction == 0 || direction == 1 || direction == 7){
- nextX += 2;
- }
- if (direction == 3 || direction == 4 || direction == 5){
- nextX -= 2;
- }
- if (direction == 1 || direction == 2 || direction == 3){
- nextY -= 2;
- }
- if (direction == 5 || direction == 6 || direction == 7){
- nextY += 2;
- }
- return new XYCoords(nextX, nextY);
- }
- //from enemy pathing logic (simplified version)
- if (lineOfSight(game.knight.position)){
- if (validMove(nextCoord(directionToTile(game.knight.position)))){
- direction = directionToTile(game.knight.position);
- }
- }
- position = nextCoord(direction);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement