public void Update(GameManager game) { player = game.getPlayer(); playerDestRect = player.getDestRect(); isInLine = inLine(); if (isInLine) { movementState = TrapMovement.isMoving; Move(); } }
/* * TODO: Finish moveRoutine, possible bug in inLine or other line of sight detection * THIS IS STILL BROKEN IDK WHY * * Direction Guide: * 1: Up * 2: Down * 3: Left * 4: Right */ public void moveRoutine(int direction) { // Leaving the starting position if (movementState == TrapMovement.isMoving) { if (direction == 1) { Y -= enemyVel; if (Y <= maxY) { Y = maxY; movementState = TrapMovement.isReturning; } } if (direction == 2) { Y += enemyVel; } if (direction == 3) { X -= enemyVel; } if (direction == 4) { X += enemyVel; } } // Returning to starting position else if (movementState == TrapMovement.isReturning) { if (direction == 1) { Y += enemyVel; if (Y >= startY) { Y = startY; movementState = TrapMovement.isStill; } } } }