コード例 #1
0
        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;
            }
        }
コード例 #2
0
ファイル: Character.cs プロジェクト: BilelAvans/BallDrive
        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;
            }
        }
コード例 #3
0
        public int randomDegrees()
        {
            Random random = new Random();

            ControlHandler.Directions direct = bounds.getSpawnArea();
            if (direct == ControlHandler.Directions.NORTH_WEST)
            {
                return(90 + random.Next(90));
            }
            else if (direct == ControlHandler.Directions.NORTH_EAST)
            {
                return(180 + random.Next(90));
            }
            else if (direct == ControlHandler.Directions.SOUTH_EAST)
            {
                return(270 + random.Next(90));
            }
            else /*if (direct == ControlHandler.Directions.SOUTH_WEST)*/
            {
                return(0 + random.Next(90));
            }
        }