コード例 #1
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

            base.Initialize();
            cf = new ControlForm(this);
            cf.Show();
        }
コード例 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            camera.update(gameTime.ElapsedGameTime.Milliseconds);

            elapsedTime += gameTime.ElapsedGameTime;

            if (elapsedTime > TimeSpan.FromSeconds(1))
            {
                elapsedTime -= TimeSpan.FromSeconds(1);
                frameRate    = frameCounter;
                Window.Title = "sanddunes at " + frameRate.ToString() + " fps";
                frameCounter = 0;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !enter)
            {
                enter = true;
                try
                {
                    cf.Show();
                }
                catch (Exception ex)
                {
                    cf = new ControlForm(this);
                    cf.Show();
                }
            }
            if (Keyboard.GetState().IsKeyUp(Keys.Enter))
            {
                enter = false;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                spaceDown = true;
            }
            else if (spaceDown)
            {
                spaceDown = false;
                map.SaveAsPng(new FileStream("outmap.png", FileMode.Create), map.Width, map.Height);
                animator.translateTarget.SaveAsPng(new FileStream("outmaptrans.png", FileMode.Create), map.Width, map.Height);
                animator.endTarget.SaveAsPng(new FileStream("outmapend.png", FileMode.Create), map.Width, map.Height);
                animator.shadowTexture.SaveAsPng(new FileStream("outshadow.png", FileMode.Create), animator.shadowTexture.Width, animator.shadowTexture.Height);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.E))
            {
                eDown = true;
            }
            else if (eDown)
            {
                eDown = false;
                start = !start;
            }

            base.Update(gameTime);
        }