Beispiel #1
0
        private void draw()
        {
            /**
             * GRAPHIQUES 2D : HUD
             */
            if (hudIsDirty)
            {
                //Mettre à jour le HUD à partir du pattern et des informations stockées sur la classe.
                MainWindow.getInstance().scoreLabel.Content = totalScore.ToString();
                string infos = HUD_INFO;
                infos = infos.Replace("%pc", player.getPlayerCount().ToString());
                infos = infos.Replace("%w", currentWall.ToString());
                infos = infos.Replace("%tw", totalWall.ToString());
                infos = infos.Replace("%ls", lastScore.ToString());
                MainWindow.getInstance().infosLabel.Text = infos;
                MainWindow.getInstance().wallProgress.Value = currentWall - 1;
                MainWindow.getInstance().wallProgress.Maximum = totalWall;

                hudIsDirty = true;

                if (currentWall > totalWall)
                {
                    //Fin du jeu
                    MainWindow.getInstance().Close();
                }
            }


            /**
             * Graphiques 3D
             */
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Quads);
            GL.Color3(Color.LightGray);

            // Côté gauche
            GL.Vertex3(-1000, 1, Wall.wallHeight * 4);
            GL.Vertex3(-Wall.wallWidth, 1, Wall.wallHeight * 4);
            GL.Vertex3(-Wall.wallWidth, 1, 0);
            GL.Vertex3(-1000, 1, 0);

            // Côté face
            GL.Vertex3(-Wall.wallWidth, 1, Wall.wallHeight * 4);
            GL.Vertex3(Wall.wallWidth, 1, Wall.wallHeight * 4);
            GL.Vertex3(Wall.wallWidth, 1, Wall.wallHeight);
            GL.Vertex3(-Wall.wallWidth, 1, Wall.wallHeight);

            // Côté droit
            GL.Vertex3(Wall.wallWidth, 1, Wall.wallHeight * 4);
            GL.Vertex3(1000, 1, Wall.wallHeight * 4);
            GL.Vertex3(1000, 1, 0);
            GL.Vertex3(Wall.wallWidth, 1, 0);

            GL.Color3(Color.White);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Quads);
            GL.Color3(Color.DarkGray);

            // Arrière plan du monde
            GL.Vertex3(-2 * Wall.wallWidth, 100, 2 * Wall.wallHeight);
            GL.Vertex3(2 * Wall.wallWidth, 100, 2 * Wall.wallHeight);
            GL.Vertex3(2 * Wall.wallWidth, 100, 0);
            GL.Vertex3(-2 * Wall.wallWidth, 100, 0);

            GL.Color3(Color.White);
            GL.End();

            // Zone de jeu (la ligne)
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Quads);
            GL.Color3(Color.Red);

            GL.Vertex3(-groundWidth, Wall.initialWallY * (1 - Wall.wallSpeedFix / 1000) + Wall.wallDepth, 0);
            GL.Vertex3(groundWidth, Wall.initialWallY * (1 - Wall.wallSpeedFix / 1000) + Wall.wallDepth, 0);
            GL.Vertex3(groundWidth, Wall.initialWallY * (1 - Wall.wallSpeedFix / 1000), 0);
            GL.Vertex3(-groundWidth, Wall.initialWallY * (1 - Wall.wallSpeedFix / 1000), 0);

            GL.Color3(Color.White);
            GL.End();

            // Zone de jeu (le rail)
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Quads);
            GL.Color3(Color.Yellow);

            GL.Vertex3(-groundWidth, groundMax, 0);
            GL.Vertex3(groundWidth, groundMax, 0);
            GL.Vertex3(groundWidth, groundMin, 0);
            GL.Vertex3(-groundWidth, groundMin, 0);

            GL.Color3(Color.White);
            GL.End();

            // Le sol (le reste)
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Quads);
            GL.Vertex3(-1000, groundMax, 0);
            GL.Vertex3(1000, groundMax, 0);
            GL.Vertex3(1000, groundMin, 0);
            GL.Vertex3(-1000, groundMin, 0);
            GL.End();
        }