public new void move(ControlHandler.Directions dir)
        {
            switch (dir)
            {
                case KeyHandler.Directions.NORTH: move(0, -this.Speed); break; // Go up
                case KeyHandler.Directions.NORTH_WEST: move(-this.Speed, -this.Speed); break;
                case KeyHandler.Directions.WEST: move(this.Speed, 0); break; // Go Left
                case KeyHandler.Directions.NORTH_EAST: move(this.Speed, -this.Speed); break;
                case KeyHandler.Directions.EAST: move(this.Speed, 0); break; // Go Right
                case KeyHandler.Directions.SOUTH_EAST: move(this.Speed, this.Speed); break;
                case KeyHandler.Directions.SOUTH: move(0, this.Speed); break; // Go Down
                case KeyHandler.Directions.SOUTH_WEST: move(-this.Speed, this.Speed); break;
            }

            stepCounter++;

            if (stepCounter % ADD_STEP_EVERY_X_MOVES == 0)
            {
                addToLastPositions(new Enemies.Position(Position.X, Position.Y));
                stepCounter = 0;
            }

            // Reflect to other side?
            if (Position.X < 0)
                Position.X = 400;
            if (Position.Y < 0)
                Position.Y = 600;
            if (Position.X > 400)
                Position.X = 0;
            if (Position.Y > 600)
                Position.Y = 0;
        } 
Exemple #2
0
        public void move(ControlHandler.Directions direction)
        {

            switch (direction)
            {
                case KeyHandler.Directions.NORTH: move(0, -1); break; // Go up
                case KeyHandler.Directions.NORTH_WEST: move(-1, -1); break;
                case KeyHandler.Directions.WEST: move(-1, 0); break; // Go Left
                case KeyHandler.Directions.NORTH_EAST: move(1, -1); break;
                case KeyHandler.Directions.EAST: move(1, 0); break; // Go Right
                case KeyHandler.Directions.SOUTH_EAST: move(1, 1); break;
                case KeyHandler.Directions.SOUTH: move(0, 1); break; // Go Down
                case KeyHandler.Directions.SOUTH_WEST: move(-1, 1); break;
            }

        }