Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
            currentKeyboardState = Keyboard.GetState();
            // exit game
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // switch to Suvat
            if (previousKeyboardState.IsKeyDown(Keys.D1) && currentKeyboardState.IsKeyUp(Keys.D1))
            {
                current_scrren.onClose();
                screens[0].onLoad();
                current_scrren = screens[0];
            }

            //switch to small planet
            if (previousKeyboardState.IsKeyDown(Keys.D2) && currentKeyboardState.IsKeyUp(Keys.D2))
            {
                current_scrren.onClose();
                screens[1].onLoad();
                current_scrren = screens[1];
            }

            // pause time
            if (previousKeyboardState.IsKeyDown(Keys.Space) && currentKeyboardState.IsKeyUp(Keys.Space))
            {
                time_frozen = !time_frozen;
                if (time_frozen)
                {
                    Console.WriteLine("time frozen");
                }
                else
                {
                    Console.WriteLine("time un frozen");
                }
            }

            // if time is not frozen
            if (!time_frozen)
            {
                current_scrren.phyUpdate();
            }

            previousKeyboardState = currentKeyboardState;
            base.Update(gameTime);
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Suvat a = new Suvat(0, graphics.GraphicsDevice);

            screens[0] = a;
            a.onLoad();
            screens[0].onLoad();
            current_scrren = a;
            screens[1]     = new SmallPlanetSuvat(1, graphics.GraphicsDevice);
            Viewport viewport = graphics.GraphicsDevice.Viewport;

            screenpos.X = viewport.Width / 2;
            screenpos.Y = viewport.Height / 2;
        }