예제 #1
0
        public TankGame(TankLevel level)
            : base(800, 600, GraphicsMode.Default, "Tank")
        {
            cameraSpinRotation            = 0;
            cameraSpinRotationControl     = new TrinaryFloatControl(Key.Left, Key.Right, 1f, -45, 45);
            cameraOverheadRotation        = 0;
            cameraOverheadRotationControl = new TrinaryFloatControl(Key.Down, Key.Up, 1f, 0, 80);

            //
            // Render Components
            //
            ArenaUtils.windowWidth  = ClientRectangle.Width;
            ArenaUtils.windowHeight = ClientRectangle.Height;
            ArenaUtils.arenaWidth   = level.width;
            ArenaUtils.arenaHeight  = level.height;

            ArenaUtils.glOrthoHalfWidth  = (float)ArenaUtils.windowWidth / 2f;
            ArenaUtils.glOrthoHalfHeight = (float)ArenaUtils.windowHeight / 2f;
            ArenaUtils.glOrthoWidth      = ArenaUtils.windowWidth;
            ArenaUtils.glOrthoHeight     = ArenaUtils.windowHeight;
            ArenaUtils.glArenaHalfWidth  = ArenaUtils.glOrthoWidth * .45f;
            ArenaUtils.glArenaHalfHeight = ArenaUtils.glOrthoHeight * .45f;
            ArenaUtils.glArenaWidth      = ArenaUtils.glOrthoWidth * .9f;
            ArenaUtils.glArenaHeight     = ArenaUtils.glOrthoHeight * .9f;

            arenaRenderer = new ArenaGLRenderer(this);
        }
예제 #2
0
        static void Main()
        {
            /*
             * try
             * {
             */
            SystemInformation info = new SystemInformation();


            //
            // Load Game Settings
            //



            /*
             * // The 'using' idiom guarantees proper resource cleanup.
             * // We request 30 UpdateFrame events per second, and unlimited
             * // RenderFrame events (as fast as the computer can handle).
             *
             * AudioContext audioContext = null;
             * StreamWriter statsFileWriter = null;
             * TankGame game = null;
             *
             *
             * try
             * {
             *
             *  try
             *  {
             *      audioContext = new AudioContext();
             *
             *
             *
             *      //
             *      // Load Audio
             *      //
             *      int audioBufferHandle = AL.GenBuffer();
             *      int audioSourceHandle = AL.GenSource();
             *      //int state;
             *
             *      WaveFormat soundFileFormat;
             *      Byte[] soundData = Wave.LoadWaveFile("CitadelKDrew.wav", out soundFileFormat);
             *      Console.WriteLine(soundFileFormat);
             *      AL.BufferData(audioBufferHandle, GetSoundFormat(soundFileFormat), soundData, soundData.Length, (int)soundFileFormat.samplesPerSecond);
             *
             *      AL.Source(audioSourceHandle, ALSourcei.Buffer, audioBufferHandle);
             *      //AL.Source(audioSourceHandle, ALSourcei.ByteOffset, 0);
             *      AL.SourcePlay(audioSourceHandle);
             *
             *      // Query the source to find out when it stops playing.
             *      do
             *      {
             *          Thread.Sleep(250);
             *          Trace.Write(".");
             *          AL.GetSource(source, ALGetSourcei.SourceState, out state);
             *      }
             *      while ((ALSourceState)state == ALSourceState.Playing);
             *
             *      Trace.WriteLine("");
             *
             *      AL.SourceStop(source);
             *      AL.DeleteSource(source);
             *      AL.DeleteBuffer(buffer);
             *  }
             *  catch (Exception e)
             *  {
             *      Console.WriteLine("Sound failed: " + e.ToString());
             *  }
             *
             *  String statisticsFileName = @"C:\temp\hexagon.stats";
             *  try
             *  {
             *      statsFileWriter = new StreamWriter(new FileStream(statisticsFileName, FileMode.Create));
             *  }
             *  catch (Exception e)
             *  {
             *      Console.WriteLine("Failed to open statistics file '{0}'", statisticsFileName);
             *  }
             *
             *  game = new TankGame();
             *  //game.CustomGameLoop(statsFileWriter);
             *  game.CustomGameLoop(null);
             *
             * }
             * finally
             * {
             *  if (game != null) game.Dispose();
             *  if (statsFileWriter != null) statsFileWriter.Dispose();
             *  if (audioContext != null) audioContext.Dispose();
             * }
             *
             *
             */

            TankLevel level = new TankLevel();

            level.width  = 800;
            level.height = 800;


            TankGame game = new TankGame(level);

            game.CustomGameLoop(null);

            /*
             * }
             * catch (Exception e)
             * {
             * throw;
             * }
             */
        }