Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void moveTowardsObject(Point p, World world, Entity entity)
- {
- // Temp values for target position
- int n_x = entity.getT_X();
- int n_y = entity.getT_Y();
- // Decide what the desired movement is
- if (p.x < n_x)
- --n_x;
- else if (p.x > n_x)
- ++n_x;
- else if (p.y < n_y)
- --n_y;
- else if (p.y > n_y)
- ++n_y;
- // Get any objects at destination tile
- if (world.getObjValue(n_x, n_y) == GlobalStaticVars.WORLD_VALUE.HUMAN_1)
- {
- // Get out of the way
- moveRandom(world, entity);
- return;
- }
- // Check if tree exists at target location. If it does, try to move around it
- if (world.getObjValue(n_x, n_y) == GlobalStaticVars.WORLD_VALUE.TREE_1
- || world.getObjValue(n_x + 1, n_y - 1) == GlobalStaticVars.WORLD_VALUE.TREE_1)
- {
- }
- // If all tests passed, update current position
- entity.setT_X(n_x);
- entity.setT_Y(n_y);
- }
Advertisement
Add Comment
Please, Sign In to add comment