Beispiel #1
0
        public Renderer(ref GraphicsDeviceManager graphics, int frameWidth, int frameHeight)
        {
            graphics.PreferredBackBufferWidth = frameWidth;
            graphics.PreferredBackBufferHeight = frameHeight;
            graphics.ApplyChanges();

            this.spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            this.lightTarget = new RenderTarget2D(graphics.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            this.lightBlockerTarget = new RenderTarget2D(graphics.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            this.debugTarget = new RenderTarget2D(graphics.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            this.SetAmbientLight(graphics, 1);
        }
Beispiel #2
0
        public void SetWindowMode(WindowMode windowMode)
        {
            WindowMode = windowMode;
            GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
            GraphicsDeviceManager.IsFullScreen       = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
            Window.IsBorderless = !GraphicsDeviceManager.HardwareModeSwitch;

            GraphicsDeviceManager.PreferredBackBufferWidth  = GraphicsWidth;
            GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;

            GraphicsDeviceManager.ApplyChanges();

            if (windowMode == WindowMode.BorderlessWindowed)
            {
                GraphicsWidth                   = GraphicsDevice.PresentationParameters.Bounds.Width;
                GraphicsHeight                  = GraphicsDevice.PresentationParameters.Bounds.Height;
                GraphicsDevice.Viewport         = new Viewport(0, 0, GraphicsWidth, GraphicsHeight);
                GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GraphicsWidth, GraphicsHeight);
                GraphicsDeviceManager.PreferredBackBufferWidth  = GraphicsWidth;
                GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;

                GraphicsDeviceManager.ApplyChanges();
            }
        }
Beispiel #3
0
        protected override void Initialize()
        {
            graphics.PreferredBackBufferHeight = height;
            graphics.PreferredBackBufferWidth  = width;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();



            /*========================================*/
            MenuItemComponent menuItems = new MenuItemComponent(this, new Vector2(30, 290), Color.Black, Color.Yellow, 56);

            menuItems.AddItem("START");
            menuItems.AddItem("INSTRUCTIONS");
            menuItems.AddItem("AUTHORS");
            menuItems.AddItem("\nEND");

            MenuComponent  menu  = new MenuComponent(this, menuItems);
            LevelComponent level = new LevelComponent(this);
            HUD            hud   = new HUD(this);

            mainMenu  = new GameWindow(this, menu, menuItems);
            gameLevel = new GameWindow(this, level, hud);

            /*========================================*/

            foreach (GameComponent komponenta in Components)
            {
                SwitchComponent(komponenta, false);
            }

            // switch window to main menu
            SwitchWindow(mainMenu);

            base.Initialize();
        }
Beispiel #4
0
        public Säosim()
        {
            /*---------FRONT END CONSTRUCTION---------*/
            Window.Title             = "Säosim"; //Doesn't work for some bastard reason
            Window.AllowUserResizing = false;

            graphics = new GraphicsDeviceManager(this);

            //graphics.IsFullScreen = true;

            graphics.PreferredBackBufferHeight = 646;
            graphics.PreferredBackBufferWidth  = 1163;
            graphics.ApplyChanges();
            /*-----END OF FRONT END CONSTRUCTION-----*/

            /*---------BACK END CONSTRUCTION---------*/
            Content.RootDirectory = "Content";

            filehandler = new IO();

            interlocking = new Interlocking();
            Debug.WriteLine("[PRG/INFO] Created interlocking");
            /*------END OF BACK END CONSTRUCTION------*/
        }
Beispiel #5
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
            _graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            _graphics.ApplyChanges();

            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Up);
            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Down);
            _trackTiles.Add(TrackTile.Horizontal);
            _trackTiles.Add(TrackTile.Horizontal);

            var counter = 0;

            do
            {
                _cyclists.Add(new Cyclist(RandomFloat(50f, 100f), RandomFloat(50f, 100f), RandomFloat(50f, 100f), "Cyclist " + counter));
                counter++;
            } while (counter < 10);


            _trackTileVisuals = DrawTrack.Track(_trackTiles, GraphicsDevice.DisplayMode.Width / 2);
            _centerX          = GraphicsDevice.DisplayMode.Width / 2;

            foreach (var cyclist in _cyclists)
            {
                cyclist.CyclistPositionX = _centerX;
            }

            base.Initialize();
        }
Beispiel #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            graphics.PreferredBackBufferWidth  = 1500;
            graphics.PreferredBackBufferHeight = 1000;
            graphics.ApplyChanges();
            mapTiles = new TileLocation[15, 10];
            blocks   = new GrassBlock[15, 10];
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    mapTiles[i, j] = new TileLocation(i * 100, j * 100, 100, 100, false);
                }
            }

            Random rando = new Random();

            int[,] locat = { { 1, 1 }, { 13, 8 }, { 13, 1 } };
            int choice = rando.Next(0, 3);

            winItem = new ItemPickup(this, (int)mapTiles[locat[choice, 0], locat[choice, 1]].position.X, (int)mapTiles[locat[choice, 0], locat[choice, 1]].position.Y, ItemPickup.Type.goalItem);
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (blockChecks[j, i] == 1)
                    {
                        blocks[i, j] = new GrassBlock(this, (int)mapTiles[i, j].position.X, (int)mapTiles[i, j].position.Y);
                    }
                }
            }
            player = new Player(this, (int)mapTiles[8, 4].position.X, (int)mapTiles[8, 4].position.Y, blocks);

            base.Initialize();
        }
Beispiel #7
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ExitWrapper.Init(this);
            mGraphics.GraphicsProfile = GraphicsProfile.HiDef;

            if (Settings.Dict["Fullscreen"] == "on")
            {
                ScreenSize.CurrentSize(mGraphics);
            }
            else
            {
                mGraphics.ApplyChanges();
            }
            IsMouseVisible = false;
            mCamera        = new Camera(mGraphics)
            {
                Position = AMainMenuPage.sCameraPosition
            };
            CameraWrapper.Init(mCamera);
            Globals.GetResolution(mGraphics);
            mInputManager = new InputManager(Content);
            mInputManager.GetCam(mCamera);
            ExitWrapper.LoadInputManager(mInputManager);
            CameraWrapper.LoadInputManager(mInputManager);
            ModelManager.Initialize(mGraphics.GraphicsDevice, Content, mCamera);
            AKi.LoadInputManager(mInputManager);
            ToolBox.Initialize(mGraphics, mCamera);
            SoundManager.Init();
            mMusicManager = new MusicManager(Content, "music/background", "music/win", "music/lose");

            mSoundEffectManager = new SoundEffectManager(Content, "sounds/battering_ram", "sounds/bowman", "sounds/cavalry", "sounds/swordsman", "sounds/hero");
            AAudioMenu.Init(mSoundEffectManager, mMusicManager);
            GameState.Init(mSoundEffectManager);

            base.Initialize();
        }
Beispiel #8
0
        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferredBackBufferWidth  = screenWidth;
            _graphics.PreferredBackBufferHeight = screenHeight;
            _graphics.IsFullScreen = false;
            ScreenRectangle        = new Rectangle(
                0,
                0,
                screenWidth,
                screenHeight);

            _graphics.ApplyChanges();
            Content.RootDirectory = "Content";
            Components.Add(new InputHandler(this));

            _gameStateManager = new GameStateManager(this);
            Components.Add(_gameStateManager);
            TitleScreen = new TitleScreen(this, _gameStateManager);
            //StartMenuScreen = new StartMenuScreen(this, _gameStateManager);
            GridScreen = new GridScreen(this, _gameStateManager);
            _gameStateManager.ChangeState(TitleScreen);
            //_gameStateManager.ChangeState(GridScreen);
        }
Beispiel #9
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            this.IsMouseVisible = true;
            this.Window.Title   = "Mars Image Classification";

            graphics.PreferredBackBufferWidth = 1006;//855
            graphics.ApplyChanges();


            SpectralDataLensFiltersFile = Path.GetTempPath() + "SpectralData.CHSMars";

            if (!File.Exists(SpectralDataLensFiltersFile))
            {
                using (StreamWriter SWT = new StreamWriter(SpectralDataLensFiltersFile))
                {
                    SWT.WriteLine("^739^753^673^601^535^482^432^440^");
                    SWT.WriteLine("^436^754^803^864^904^934^1009^880^");
                    SWT.Close();
                }
            }

            base.Initialize();
        }
Beispiel #10
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth  = 1080;
            graphics.PreferredBackBufferHeight = 600;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = "Riemer's XNA Tutorials -- Series 1";

            base.Initialize();
        }
 protected override void Initialize()
 {
     base.Initialize();
     Services.AddService(_graphics);
     Services.AddService(_spriteBatch);
     if (IsActive)
     {
         OnActivated(this, EventArgs.Empty);
     }
     else
     {
         OnDeactivated(this, EventArgs.Empty);
     }
     IsMouseVisible = true;
     //IsFixedTimeStep = false;
     _graphics.PreferredBackBufferWidth  = 1920;
     _graphics.PreferredBackBufferHeight = 1080;
     _graphics.HardwareModeSwitch        = false;
     _graphics.IsFullScreen = true;
     _graphics.ApplyChanges();
     SetVirtualResolution(1920, 1080);
     PixelOrigin  = new Vector2(.5f);
     Random       = new Random();
     ForeTileData = new Dictionary <Tile.Fores, ForeTileData>()
     {
         { Tile.Fores.Dirt, new ForeTileData(Content.Load <Texture2D>("Textures\\Tiles_0"), Terraria_World.ForeTileData.UVTypes.tile1, new[] { Tile.Fores.Dirt, Tile.Fores.Grass }) },
         { Tile.Fores.Stone, new ForeTileData(Content.Load <Texture2D>("Textures\\Tiles_1"), Terraria_World.ForeTileData.UVTypes.tile1, new[] { Tile.Fores.Stone }) },
         { Tile.Fores.Grass, new ForeTileData(Content.Load <Texture2D>("Textures\\Tiles_2"), Terraria_World.ForeTileData.UVTypes.tile2, new[] { Tile.Fores.Grass, Tile.Fores.Dirt }) }
     };
     BackTileData = new Dictionary <Tile.Backs, BackTileData>()
     {
         { Tile.Backs.Stone, new BackTileData(Content.Load <Texture2D>("Textures\\Wall_1")) },
         { Tile.Backs.Dirt, new BackTileData(Content.Load <Texture2D>("Textures\\Wall_2")) },
     };
     _scene = new Scenes.Game(256);
 }
Beispiel #12
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            graphics.PreferredBackBufferWidth  = SCREEN_WIDTH;
            graphics.PreferredBackBufferHeight = SCREEN_HEIGHT;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            //AllocConsole();
            CreatePlayerBulleT     = CreatePlayerBullet;
            CreateEnemyBulleT      = CreateEnemyBullet;
            SpawnPlayer            = SpawnPlayerBiplane;
            SpawnEnemy             = SpawnEnemyBiplane;
            CreateExp              = CreateExplosion;
            CreateSm               = CreateSmoke;
            DestroySm              = DestroySmoke;
            CreateFi               = CreateFire;
            DestroyFi              = DestroyFire;
            IncreasePlayerSc       = IncreasePlayerScore;
            IncreaseEnemySc        = IncreaseEnemyScore;
            FGetPlayerCenterCoords = GetPlayerCenterCoords;
            gameMode               = GameModes.PlayerVersusAI;
            base.Initialize();
        }
Beispiel #13
0
        protected override void Initialize()
        {
            Window.Title = "MI-83 Fantasy Game Console";

            _graphics.PreferredBackBufferWidth  = 1024;
            _graphics.PreferredBackBufferHeight = 576;
            _graphics.ApplyChanges();

            base.Initialize();

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _renderData   = new Color[(_maxSupportedWidth * 3) * (_maxSupportedHeight * 3)];
            _renderTarget = new Texture2D(
                GraphicsDevice,
                _maxSupportedWidth * 3,
                _maxSupportedHeight * 3);

            Window.TextInput += _computer.InputBuffer.Window_TextInput;
            Window.KeyDown   += _computer.InputBuffer.Window_KeyDown;
            Window.KeyUp     += _computer.InputBuffer.Window_KeyUp;

            _computer.Boot();
        }
Beispiel #14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            OpenFileDialog FD = new OpenFileDialog();

            FD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\BattleOfElements\";

            if (FD.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(FD.FileName))
                {
                    FILEPATH = FD.FileName;
                }
            }

            PixelTexture     = new Texture2D(GraphicsDevice, 1, 1);
            CircleTexture    = Content.Load <Texture2D>("Circle");
            RectangleTexture = Content.Load <Texture2D>("Rectangle");
            font             = Content.Load <SpriteFont>("SpriteFont");

            colors[0]       = Color.Red;
            colors[1]       = Color.Orange;
            colors[2]       = Color.Blue;
            colors[3]       = Color.LightBlue;
            Camera          = new Camera2D();
            Camera.Position = new Vector2(690, 340);

            graphics.PreferredBackBufferHeight = SCREENHEIGHT;
            graphics.PreferredBackBufferWidth  = SCREENWIDTH;
            graphics.ApplyChanges();

            LoadData();

            lineDrawer = new Linedrawer(GraphicsDevice, positions, colors, SCALE);

            base.Initialize();
        }
            public override void OnClicked()
            {
                switch (graphics.PreferredBackBufferWidth)
                {
                case 480:
                    graphics.PreferredBackBufferWidth  = 360;
                    graphics.PreferredBackBufferHeight = 600;
                    break;

                case 360:
                    graphics.PreferredBackBufferWidth  = 240;
                    graphics.PreferredBackBufferHeight = 400;
                    break;

                case 240:
                    graphics.PreferredBackBufferWidth  = 480;
                    graphics.PreferredBackBufferHeight = 800;
                    break;
                }

                graphics.ApplyChanges();

                base.OnClicked();
            }
Beispiel #16
0
        /// <summary>
        /// MapSimulator Constructor
        /// </summary>
        /// <param name="mapBoard"></param>
        /// <param name="titleName"></param>
        public MapSimulator(Board mapBoard, string titleName)
        {
            this.mapBoard = mapBoard;

            this.mapRenderResolution = UserSettings.SimulateResolution;
            InitialiseMapWidthHeight();

            //RenderHeight += System.Windows.Forms.SystemInformation.CaptionHeight; // window title height

            //double dpi = ScreenDPIUtil.GetScreenScaleFactor();

            // set Form window height & width
            //this.Width = (int)(RenderWidth * dpi);
            //this.Height = (int)(RenderHeight * dpi);

            //Window.IsBorderless = true;
            //Window.Position = new Point(0, 0);
            Window.Title    = titleName;
            IsFixedTimeStep = false; // dont cap fps
            IsMouseVisible  = false; // draws our own custom cursor here..

            _DxDeviceManager = new GraphicsDeviceManager(this)
            {
                SynchronizeWithVerticalRetrace = true,
                HardwareModeSwitch             = true,
                GraphicsProfile             = GraphicsProfile.HiDef,
                IsFullScreen                = false,
                PreferMultiSampling         = true,
                SupportedOrientations       = DisplayOrientation.Default,
                PreferredBackBufferWidth    = Math.Max(RenderWidth, 1),
                PreferredBackBufferHeight   = Math.Max(RenderHeight, 1),
                PreferredBackBufferFormat   = SurfaceFormat.Color,
                PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8,
            };
            _DxDeviceManager.ApplyChanges();
        }
Beispiel #17
0
        /// <summary>
        ///     Kör kod som ska köras när spelet startas
        /// </summary>
        protected override void Initialize()
        {
            IsMouseVisible   = true;
            highscoreManager =
                new HighscoreManager(
                    $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\.World of Wealth\\");
            // Sätter upplösningen till 1280x720
            graphics.PreferredBackBufferWidth  = 1366;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();
            //graphics.ToggleFullScreen();
            //Kör Komponenterna till klasserna för spelaren och fienden
            Components.Add(enemyManager);
            Components.Add(playerManager);
            // Components.Add(skybox);

            highscoreManager.Initilize();
            highscoreManager.Load();

            Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled;

            menuManager = new MenuManager(this, GraphicsDevice);
            base.Initialize();
        }
Beispiel #18
0
        public Q19Game()
        {
            StartTime                = DateTime.Now;
            Instance                 = this;
            Graphics                 = new GraphicsDeviceManager(this);
            Content.RootDirectory    = "Data";
            Window.AllowUserResizing = true;
            IsMouseVisible           = DebugMode;
            Lighting                 = new Lighting2D(GD, GameWidth, GameHeight)
            {
                EnableDebugLight = false
            };
            Camera2D     = Matrix.CreateTranslation(new Vector3(GameWidth / 2, GameHeight / 2, 0));
            Window.Title = "Q19";

            Graphics.PreferredBackBufferWidth  = GameWidth;
            Graphics.PreferredBackBufferHeight = GameHeight;
            Graphics.ApplyChanges();

            _cameraPosition = Vector3.Down * 0.5f + Vector3.Forward * 2;

            //Scene = new Scene();
            //Highscore = new Highscore("Q19", 1);
        }
Beispiel #19
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

#if !XENKO
            GraphicsDevice.Clear(Color.Black);

            if (_graphics.PreferredBackBufferWidth != Window.ClientBounds.Width ||
                _graphics.PreferredBackBufferHeight != Window.ClientBounds.Height)
            {
                _graphics.PreferredBackBufferWidth  = Window.ClientBounds.Width;
                _graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
                _graphics.ApplyChanges();
            }
#else
            // Clear screen
            GraphicsContext.CommandList.Clear(GraphicsDevice.Presenter.BackBuffer, Color.Black);
            GraphicsContext.CommandList.Clear(GraphicsDevice.Presenter.DepthStencilBuffer, DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil);

            // Set render target
            GraphicsContext.CommandList.SetRenderTargetAndViewport(GraphicsDevice.Presenter.DepthStencilBuffer, GraphicsDevice.Presenter.BackBuffer);
#endif
            _desktop.Render();
        }
Beispiel #20
0
        public ChangeGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Set the overall scale of the game.
            graphics.PreferredBackBufferWidth  = WINDOW_WIDTH * SCALE;
            graphics.PreferredBackBufferHeight = WINDOW_HEIGHT * SCALE;
            graphics.ApplyChanges();

            IsMouseVisible = true;

            IsFixedTimeStep = false;

            // Automatically centre the game window.
            var screenWidth  = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
            var screenHeight = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;

            Window.Position = new Point(
                (screenWidth - graphics.PreferredBackBufferWidth) / 2,
                (screenHeight - graphics.PreferredBackBufferHeight) / 2 - 100);

            Window.Title = "CHANGE";
        }
Beispiel #21
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _graphics.PreferredBackBufferWidth  = screenWidth;
            _graphics.PreferredBackBufferHeight = screenHeight;
            _graphics.ApplyChanges();

            paddle = new Texture2D(_graphics.GraphicsDevice, paddleThickness, paddleLength);

            Color[] data = new Color[paddleThickness * paddleLength];
            for (int i = 0; i < data.Length; ++i)
            {
                data[i] = Color.White;
            }
            paddle.SetData(data);

            ball = new Texture2D(_graphics.GraphicsDevice, 10, 10);

            Color[] datab = new Color[10 * 10];
            for (int i = 0; i < datab.Length; ++i)
            {
                datab[i] = Color.White;
            }
            ball.SetData(datab);

            line = new Texture2D(_graphics.GraphicsDevice, 2, 576);

            Color[] dataL = new Color[2 * 576];
            for (int i = 0; i < dataL.Length; ++i)
            {
                dataL[i] = Color.White;
            }
            line.SetData(dataL);

            base.Initialize();
        }
        protected override void Initialize()
        {
            IsMouseVisible = false;
            _graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
            _graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            _graphics.IsFullScreen = true;
            _graphics.ApplyChanges();

            base.Initialize();

            var spawn = Level.Markers.First(marker => marker.CellType == CellType.Spawn).Position;

            Camera = new Camera(0.4f, new Vector3(spawn.X, 0.5f, spawn.Y), AxeTexture);
            Camera.Transform.Rotation = 180;

            GameObjects.Add(Camera);

            foreach (var line in Level.Walls)
            {
                GameObjects.Add(new Wall(line, WallTexture, 1f));
            }

            GameObjects.Add(new Floor(1000f, FloorTexture));
        }
Beispiel #23
0
        public void DeviceDisposingInvokedAfterDeviceDisposed()
        {
            var game = new TestGameBase();
            var gdm  = new GraphicsDeviceManager(game);

            var invoked = false;

            gdm.DeviceDisposing += (sender, args) =>
            {
                invoked = true;
                Assert.IsTrue(gdm.GraphicsDevice.IsDisposed);
            };

            game.InitializeOnly();

            Assert.IsFalse(gdm.GraphicsDevice.IsDisposed);
            Assert.IsFalse(invoked);
            // change the graphics profile so the current device needs to be disposed
            gdm.GraphicsProfile = GraphicsProfile.HiDef;
            gdm.ApplyChanges();
            Assert.IsTrue(invoked);

            game.Dispose();
        }
Beispiel #24
0
        protected override void Initialize()
        {
            VertexPositions.Initialize();
            EventInput.Initialize(Window);
            Blocks.InitialzizeBlocks();

            _graphics.PreferredBackBufferWidth  = Config.Width;
            _graphics.PreferredBackBufferHeight = Config.Height;

            if (!Config.VSync)
            {
                IsFixedTimeStep = false;
                _graphics.SynchronizeWithVerticalRetrace = false;
            }
            _graphics.ApplyChanges();

            _camera      = new Camera(0.3f, 0.002f, GraphicsDevice); //move speed, rotate speed, ...
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _statistics = new StatisticOverlay(Content.Load <SpriteFont>("NormalFont"), new Vector2(48, 48)); //debug
            _mainMenu   = new MainMenu(Content);

            base.Initialize();
        }
Beispiel #25
0
        protected override void LoadContent()
        {
            Globals.content     = this.Content;
            Globals.spriteBatch = new SpriteBatch(GraphicsDevice);


            _graphics.PreferredBackBufferWidth  = 1600;
            _graphics.PreferredBackBufferHeight = 900;
            _graphics.ApplyChanges();

            Globals.sceneWidth  = _graphics.PreferredBackBufferWidth;
            Globals.sceneHeight = _graphics.PreferredBackBufferHeight;

            // TODO: use this.Content to load your game content here

            bgm = Globals.content.Load <Song>("BGM_trimmed");

            _world = new World();
            camera = new Camera();

            MediaPlayer.Play(bgm);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = 0.1f;
        }
Beispiel #26
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     graphics.PreferredBackBufferHeight = 288;
     graphics.PreferredBackBufferWidth  = 320;
     graphics.ApplyChanges();
     scale = MathHelper.Min(scaleX, scaleY);
     #region Levels
     allNPCS    = npcs.AllNPCS;
     allObjects = objects.AllObjects;
     Levels     = new Dictionary <string, Level>();
     area1      = new Level("area1", true, allNPCS["area1"]);
     area2      = new Level("area2", true, allNPCS["area2"]);
     area3      = new CollectionQuest("area3", false, allNPCS["area3"], allObjects["testQuestObjects"]);
     area4      = new ShootingQuest("area1", true, new Dictionary <string, NPC>(), allObjects["testShootingObjects"]);
     area5      = new Level("area4", true, allNPCS["area5"]);
     Levels.Add("area1", area1);
     Levels.Add("area2", area2);
     Levels.Add("area3", area3);
     Levels.Add("area4", area4);
     Levels.Add("area5", area5);
     #endregion
     player = new Player(new Vector2(41, 108));
     base.Initialize();
 }
Beispiel #27
0
        public Game1()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible        = true;
            Window.IsBorderless   = true;
            IntPtr hWnd = Window.Handle;

            _ctrl = System.Windows.Forms.Control.FromHandle(hWnd);
            _form = _ctrl.FindForm();
            _form.TransparencyKey = System.Drawing.Color.Beige;
            _form.TopMost         = true;

            uint initialStyle = GetWindowLong(hWnd, -20);

            SetWindowLong(hWnd, -20, initialStyle | 0x80000 | 0x20);

            SetScreenBounds();

            _graphics.PreferredBackBufferWidth  = 500;
            _graphics.PreferredBackBufferHeight = 500;
            Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 2) - (_graphics.PreferredBackBufferWidth / 2), (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 2) - (_graphics.PreferredBackBufferHeight / 2));
            _graphics.ApplyChanges();
        }
 protected override void Initialize()
 {
     base.Initialize();
     Services.AddService(_graphics);
     Services.AddService(_spriteBatch);
     if (IsActive)
     {
         OnActivated(this, EventArgs.Empty);
     }
     else
     {
         OnDeactivated(this, EventArgs.Empty);
     }
     IsMouseVisible = true;
     //IsFixedTimeStep = false;
     _graphics.PreferredBackBufferWidth  = 1920;
     _graphics.PreferredBackBufferHeight = 1080;
     _graphics.HardwareModeSwitch        = false;
     _graphics.IsFullScreen = true;
     _graphics.ApplyChanges();
     SetVirtualResolution(1920, 1080);
     PixelOrigin = new Vector2(.5f);
     _scene      = new Scenes.Game(256);
 }
Beispiel #29
0
        //private Effect cShader, cShipShader;

        public AsteroidShooter()
        {
            cGraphDevMgr = new GraphicsDeviceManager(this)
            {
                PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8,

                PreferredBackBufferWidth  = 1024,               //Set the window size
                PreferredBackBufferHeight = 768
            };
            cGraphDevMgr.ApplyChanges();

            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            cTextureDict = new Dictionary <Textures, Texture2D>();

            cRandom = new Random(DateTime.Now.Millisecond);

            cEnemyKills = 0;
            cAliveSince = 0;
            cSpawnNum   = 0;

            cHeadlightMode = false;
        }
Beispiel #30
0
        private void ChangeDisplayMode()
        {
            switch (this.displayMode)
            {
            case 0:
                graphics.PreferredBackBufferWidth  = 800;
                graphics.PreferredBackBufferHeight = 600;
                break;

            case 1:
                graphics.PreferredBackBufferWidth  = 1024;
                graphics.PreferredBackBufferHeight = 768;
                break;

            case 2:
                graphics.PreferredBackBufferWidth  = graphics.GraphicsDevice.DisplayMode.Width;
                graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;
                break;

            default:
                goto case 0;
            }
            graphics.ApplyChanges();
        }
Beispiel #31
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            manager     = new Manager(this, spriteBatch);
            world       = manager.newWorld();

            ScreenWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            ScreenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            int scaleX = ScreenWidth / baseWidth;
            int scaleY = ScreenWidth / baseHeight;

            gameWidth  = baseWidth * scaleX;
            gameHeight = baseHeight * scaleY;

            //resize window
            graphics.PreferredBackBufferWidth  = gameWidth;
            graphics.PreferredBackBufferHeight = gameHeight;
            graphics.ApplyChanges();

            //IsFixedTimeStep = true;

            base.Initialize();
        }