Esempio n. 1
0
        protected override void Initialize()
        {
            IsMouseVisible = true;
            GDManager.SynchronizeWithVerticalRetrace = true;
            GDManager.PreferredBackBufferWidth       = WINDOW_SIZE_X;
            GDManager.PreferredBackBufferHeight      = WINDOW_SIZE_Y;

            IsFixedTimeStep = true;
            GDManager.ApplyChanges();
            base.Initialize();
        }
Esempio n. 2
0
        protected override void Initialize()
        {
            IsMouseVisible = true;
            GDManager.SynchronizeWithVerticalRetrace = true;
            IsFixedTimeStep = true;

            //GDManager.IsFullScreen = false;
            //ViewPortWidth = GDManager.PreferredBackBufferWidth = GDManager.GraphicsDevice.DisplayMode.Width / 2;
            //ViewPortHeight = GDManager.PreferredBackBufferHeight = GDManager.GraphicsDevice.DisplayMode.Height / 2;

            ViewPortWidth          = GDManager.PreferredBackBufferWidth = GDManager.GraphicsDevice.DisplayMode.Width;
            ViewPortHeight         = GDManager.PreferredBackBufferHeight = GDManager.GraphicsDevice.DisplayMode.Height;
            GDManager.IsFullScreen = true;

            GDManager.ApplyChanges();

            simplexNoiseColors = new Color[ViewPortWidth / DIVISOR * ViewPortHeight / DIVISOR];
            IsMouseVisible     = true;
            circlesYay         = new ThatCoolCircleThing(ViewPortWidth, ViewPortHeight, RNG);
            base.Initialize();
        }
Esempio n. 3
0
        protected override void Update(GameTime gameTime)
        {
            updateTimeStep = gameTime.ElapsedGameTime.TotalMilliseconds / 1000d;
            InputHandler.Update(Mouse.GetState(), Keyboard.GetState());
            InputHandler.GenerateCommands();
            // Call game logic on this.Commands to get input data.

            foreach (KeyboardCommand c in InputHandler.KeyCommands)
            {
                switch (c.Button)
                {
                case Keys.Escape:
                    Exit();
                    return;

                case Keys.F4:
                    if (c.State == InputState.Pressed)
                    {
                        Options.LargeResolution = !Options.LargeResolution;
                    }
                    break;
                }
            }

            if (_isLargeReso != Options.LargeResolution)
            {
                //Determines the maximum usable resolution judged by the GraphicsDevice bounds.
                if (GDManager.GraphicsDevice.DisplayMode.Width < Options.RESOLUTION_LARGE.X ||
                    GDManager.GraphicsDevice.DisplayMode.Height < Options.RESOLUTION_LARGE.Y)
                {
                    Options.CanHandleLargeReso = false;
                }

                //If the resolution setting is higher than the graphics device can handle, change the option to the usable maxReso.
                if (Options.LargeResolution && !Options.CanHandleLargeReso)
                {
                    Options.LargeResolution = false;
                }

                GDManager.PreferredBackBufferWidth  = Options.GetBackBufferWidth();
                GDManager.PreferredBackBufferHeight = Options.GetBackBufferHeight();
                GDManager.IsFullScreen = Options.LargeResolution;
                GDManager.ApplyChanges();
                _isLargeReso = Options.LargeResolution;
            }

            // If the choicemaker is not active, update the stage. Otherwise don't do anything.
            if (!SorryScreen.Update(updateTimeStep))
            {
                if (!ChoiceMaker.Update(updateTimeStep))
                {
                    CurrentStage.Update(updateTimeStep);
#if DEBUG
                    // Preprocessor directive removes this function in Release/AnyCPU Configuration.
                    foreach (MouseCommand c in InputHandler.MouseCommands)
                    {
                        //CurrentStage.Player.ActualCoords.X = c.Position.X + CurrentStage.Camera.Location.X;
                        //CurrentStage.Player.ActualCoords.Y = c.Position.Y + CurrentStage.Camera.Location.Y;
                        //CurrentStage.Player.Position = new Rectangle(c.Position, CurrentStage.Player.Position.Size);
                        //CurrentStage.Player.LastPosition = CurrentStage.Player.Position;
                        //CurrentStage.Player.ActualVelocity.X = 0;
                        //CurrentStage.Player.ActualVelocity.Y = 0;
                        if (!CurrentStage.ChoiceMade && Game.Manager.ChoiceMaker.Initialized)
                        {
                            Game.Manager.ChoiceMaker.Active = true;
                        }
                        else
                        {
                            CurrentStage.LoadNextLevel();
                        }
                    }
#endif
                }
            }

            base.Update(gameTime);
        }
Esempio n. 4
0
        protected override void Update(GameTime gameTime)
        {
            zOff += zOffsetInc;

            _prevMousePos = _currMousePos;
            _currMousePos = Mouse.GetState().Position.ToVector2();
            xOff          = 0;

            //for (int i = 0; i < (ViewPortWidth / DIVISOR); i++) {
            //	xOff += xIncrement;
            //	double yOff = 0;
            //	for (int j = 0; j < (ViewPortHeight / DIVISOR); j++) {
            //		yOff += yIncrement;
            //		double value = Noise.Evaluate(xOff, yOff, zOff);

            //		int val = ValueMapper.Map(value, -0.7, 1, 0, 360);
            //		int index = j * (ViewPortWidth / DIVISOR) + i;
            //		simplexNoiseColors[index] = HSV.ColorFromHue(val);
            //	}
            //}

            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                if (_prevMousePos == null)
                {
                    return;
                }

                //_components.Add(new LineSegment() {
                //	StartPos = _currMousePos,
                //	EndPos = _prevMousePos,
                //	Color = HSV.ColorFromHue(RNG.Next(0, 360))
                //});

                //_components.Add(new Circle() {
                //	Radius = 20,
                //	Position = _currMousePos,
                //	Color = HSV.ColorFromHue(RNG.Next(0, 360))
                //});
            }

            KeyboardState state = Keyboard.GetState();

            if (state.IsKeyDown(Keys.Up))
            {
                yIncrement += 0.001;
            }
            if (state.IsKeyDown(Keys.Down))
            {
                yIncrement -= 0.001;
            }
            if (state.IsKeyDown(Keys.Left))
            {
                xIncrement -= 0.001;
            }
            if (state.IsKeyDown(Keys.Right))
            {
                xIncrement += 0.001;
            }
            if (state.IsKeyDown(Keys.NumPad8))
            {
                zOffsetInc += 0.001;
            }
            if (state.IsKeyDown(Keys.NumPad2))
            {
                zOffsetInc -= 0.001;
            }


            foreach (Component item in _components)
            {
                item.Update(gameTime);
            }

            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                _components.Clear();
                circlesYay.Clear();
            }

            if ((state.IsKeyDown(Keys.LeftAlt) || state.IsKeyDown(Keys.RightAlt)) && state.IsKeyDown(Keys.Enter))
            {
                if (GDManager.IsFullScreen)
                {
                    GDManager.IsFullScreen = false;
                    ViewPortWidth          = GDManager.PreferredBackBufferWidth = GDManager.GraphicsDevice.DisplayMode.Width / 2;
                    ViewPortHeight         = GDManager.PreferredBackBufferHeight = GDManager.GraphicsDevice.DisplayMode.Height / 2;
                    GDManager.ApplyChanges();
                }
                else
                {
                    ViewPortWidth          = GDManager.PreferredBackBufferWidth = GDManager.GraphicsDevice.DisplayMode.Width;
                    ViewPortHeight         = GDManager.PreferredBackBufferHeight = GDManager.GraphicsDevice.DisplayMode.Height;
                    GDManager.IsFullScreen = true;
                    GDManager.ApplyChanges();
                }
            }

            circlesYay.Update(gameTime);

            base.Update(gameTime);
        }