예제 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            MouseState ms = Mouse.GetState();

            // update gamestate
            gameState.GameTime = gameTime;

            // draw world
            spriteBatch.Begin(transformMatrix: gameState.CameraMatrix, sortMode: SpriteSortMode.FrontToBack);
            world.Draw(gameState, isDeleting, mouseTilePos);
            spriteBatch.End();

            spriteBatch.Begin(transformMatrix: gameState.CameraMatrix);
            if (rail != null && world.GetRail((int)mouseTilePos.X, (int)mouseTilePos.Y) == null)
            {
                //spriteBatch.Draw(rail.GetRailTexture(), mouseTilePos * World.TileSize, null, Color.White, rail.Orientation.GetAngle(), new Vector2(32, 32), 1, SpriteEffects.None, 0);
                rail.Draw(gameState, mouseTilePos.X * World.TileSize, mouseTilePos.Y * World.TileSize, PlaceColor);
            }
            spriteBatch.End();

            railParticles.Draw(gameState.CameraMatrix);

            // draw UI stuff
            spriteBatch.Begin();
            //spriteBatch.DrawString(font, "Mouse pos: (" + mousePos.X + ", " + mousePos.Y + ")", new Vector2(20, 20), Color.White);
            //spriteBatch.DrawString(font, "Absolute mouse pos: (" + absMousePos.X + ", " + absMousePos.Y + ")", new Vector2(20, 40), Color.White);
            //spriteBatch.DrawString(font, "Mouse tile pos: (" + mouseTilePos.X + ", " + mouseTilePos.Y + ")", new Vector2(20, 60), Color.White);

            if (showHelp)
            {
                spriteBatch.DrawString(font, "Welcome to RailPuzzle! The goal of the game is to link each wagon\non the left with its corresponding end position on the right.\n\nControls:\nMove camera:         W, A, S, D\nPlace straight rail: Numpad 1\nPlace curved rail:   Numpad 2\nPlace buffer rail:   Numpad 3\nPlace cross rail:    Numpad 4\nRotate active rail:  R\nDelete mode:         Q\nDeselect rail:       Esc\nRun level:           Space\nGenerate new level:  N\nToggle this message: H", new Vector2(20, 20), Color.White);
            }

            if (world.HasWon())
            {
                spriteBatch.DrawString(winfont, "You Win!", new Vector2(550, 350), Color.Red);
            }

            spriteBatch.End();



            base.Draw(gameTime);
        }