コード例 #1
0
ファイル: Game.cs プロジェクト: MagistrAVSH/voxelgame
        //gm: from the OpenTK source code (Graphics\GraphicsMode.cs), here is GraphicsMode.Default, it does seem to select sensible choices -> default display bpp, 16 bit depth buffer, 0 bit stencil buffer, 2 buffers
        public Game()
            : base(Constants.DEFAULT_GAME_WIDTH, Constants.DEFAULT_GAME_HEIGHT, GraphicsMode.Default, string.Format("Voxel Game {0}: {1}", Settings.VersionDisplay, Config.UserName))
        {
            //note: cant easily thread these loading tasks because they all need to run on the thread that creates the GL context
            Settings.Game = this;
            Diagnostics.LoadDiagnosticProperties();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            Sounds.Audio.LoadSounds(); //ensure sounds are loaded before they are needed
            Debug.WriteLine("Sounds load time: {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();
            Textures.TextureLoader.Load(); //ensure textures are loaded before they are needed
            Debug.WriteLine("Textures load time: {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();
            DisplayList.LoadDisplayLists(); //ensure display lists are loaded before they are needed
            Debug.WriteLine("Display Lists load time: {0}ms", stopwatch.ElapsedMilliseconds);

            VSync = Config.VSync ? VSyncMode.On : VSyncMode.Off;

            if (Config.IsSinglePlayer)
            {
                var playerCoords = new Coords(WorldData.SizeInBlocksX / 2f, 0, WorldData.SizeInBlocksZ / 2f); //start player in center of world
                playerCoords.Yf = WorldData.Chunks[playerCoords].HeightMap[playerCoords.Xblock % Chunk.CHUNK_SIZE, playerCoords.Zblock % Chunk.CHUNK_SIZE] + 1; //start player on block above the surface
                Player = new Player(0, Config.UserName, playerCoords);
                NetworkClient.Players.TryAdd(Player.Id, Player); //note: it is not possible for the add to fail on ConcurrentDictionary, see: http://www.albahari.com/threading/part5.aspx#_Concurrent_Collections
            }
        }
コード例 #2
0
 private static void AddSlashResult(Player player)
 {
     AddSlashResult(string.Format("{0} ({1}) {2}", player.UserName, player.Id, player.Coords));
 }