Exemple #1
0
        private static void DrawPlayer()
        {
            GL.Begin(PrimitiveType.Lines);

            #region drawBasis

            /*
             * GL.Color3(Color.Yellow);
             *
             * GL.Vertex2(Game.player.pos.x - QMath.Cos(Game.player.viewAngle) * viewLength - Game.window.Width / 2,
             *          Game.player.pos.y - QMath.Sin(Game.player.viewAngle) * viewLength);
             * GL.Vertex2(Game.player.pos.x + QMath.Cos(Game.player.viewAngle) * viewLength - Game.window.Width / 2,
             *          Game.player.pos.y + QMath.Sin(Game.player.viewAngle) * viewLength);
             *
             * GL.Vertex2(Game.player.pos.x + QMath.Sin(Game.player.viewAngle) * viewLength - Game.window.Width / 2,
             *          Game.player.pos.y - QMath.Cos(Game.player.viewAngle) * viewLength);
             * GL.Vertex2(Game.player.pos.x - QMath.Sin(Game.player.viewAngle) * viewLength - Game.window.Width / 2,
             *          Game.player.pos.y + QMath.Cos(Game.player.viewAngle) * viewLength);
             */
            #endregion
            #region drawFOV
            GL.Color3(Color.Gold);

            GL.Vertex2(mapScale * Game.player.pos.x + Game.window.Width / 4,
                       mapScale * Game.player.pos.y + Game.window.Height / 4);
            GL.Vertex2(mapScale * Game.player.pos.x + QMath.Cos(Game.player.viewAngle + Player.FOV / 2) * viewLength + Game.window.Width / 4,
                       mapScale * Game.player.pos.y + QMath.Sin(Game.player.viewAngle + Player.FOV / 2) * viewLength + Game.window.Height / 4);

            GL.Vertex2(mapScale * Game.player.pos.x + Game.window.Width / 4,
                       mapScale * Game.player.pos.y + Game.window.Height / 4);
            GL.Vertex2(mapScale * Game.player.pos.x + QMath.Cos(Game.player.viewAngle - Player.FOV / 2) * viewLength + Game.window.Width / 4,
                       mapScale * Game.player.pos.y + QMath.Sin(Game.player.viewAngle - Player.FOV / 2) * viewLength + Game.window.Height / 4);

            GL.End();
            #endregion
            #region drawPosition
            GL.Begin(PrimitiveType.Quads);
            GL.Color3(Color.Thistle);

            int[] a = { -1, 1 };

            for (int i = 0; i < 4; i++)
            {
                GL.Vertex2(mapScale * Game.player.pos.x + a[0] * Player.width + Game.window.Width / 4,
                           mapScale * Game.player.pos.y + a[1] * Player.width + Game.window.Height / 4);

                a[i % 2] *= -1;
            }

            GL.End();
            #endregion
        }
Exemple #2
0
        private static void GetKeyboardInput()
        {
            if (Game.window.Keyboard[Key.Escape])
            {
                Game.window.Exit();
            }

            if (Game.window.Keyboard[Key.W] || Game.window.Keyboard[Key.Up])
            {
                Game.player.pos.x += Player.speed * QMath.Cos(Game.player.viewAngle);
                Game.player.pos.y += Player.speed * QMath.Sin(Game.player.viewAngle);
            }
            if (Game.window.Keyboard[Key.S] || Game.window.Keyboard[Key.Down])
            {
                Game.player.pos.x -= Player.speed * QMath.Cos(Game.player.viewAngle);
                Game.player.pos.y -= Player.speed * QMath.Sin(Game.player.viewAngle);
            }
            if (Game.window.Keyboard[Key.A])
            {
                Game.player.pos.x += Player.speed * QMath.Cos(Game.player.viewAngle + (float)Math.PI / 2);
                Game.player.pos.y += Player.speed * QMath.Sin(Game.player.viewAngle + (float)Math.PI / 2);
            }
            if (Game.window.Keyboard[Key.D])
            {
                Game.player.pos.x += Player.speed * QMath.Cos(Game.player.viewAngle - (float)Math.PI / 2);
                Game.player.pos.y += Player.speed * QMath.Sin(Game.player.viewAngle - (float)Math.PI / 2);
            }
            if (Game.window.Keyboard[Key.Left])
            {
                Game.player.viewAngle += keyboardSensitivity;
            }
            if (Game.window.Keyboard[Key.Right])
            {
                Game.player.viewAngle -= keyboardSensitivity;
            }
        }