Example #1
0
        /// <summary>
        /// Dras game
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="spriteBatch"></param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(backgrounds[CurrentBackground], new Vector2(0, 0), null, Color.White, 0f, Vector2.Zero, 4 * (Screen.SIZE / 800f), SpriteEffects.None, 0f);
            spriteBatch.End();

            float playerX = MathHelper.Clamp(Player.Position.X, Screen.SIZE / 2, gameMap.TileMap[0].Length * 48 * (Screen.SIZE / 800f) * Screen.GS - Screen.SIZE / 2);
            float playerY = MathHelper.Clamp(Player.Position.Y, Screen.SIZE / 2, gameMap.TileMap[0].Length * 48 * (Screen.SIZE / 800f) * Screen.GS - Screen.SIZE / 2);

            sight.X = playerX - Screen.SIZE / 2;
            sight.Y = playerY - Screen.SIZE / 2;
            Matrix transform = Matrix.CreateTranslation(-sight.X, -sight.Y, 0);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, transformMatrix: transform);

            gameMap.Draw(gameTime, spriteBatch);
            Player.Draw(gameTime, spriteBatch, -sight.X, -sight.Y);
            if (CurrentBackground == 1)
            {
                Rain.Draw(gameTime, spriteBatch);
            }
            Land.Draw(gameTime, spriteBatch, sight.X, sight.Y);
            //spriteBatch.DrawString(arial, "Time", new Vector2(40, 390), Color.Silver);
            //spriteBatch.DrawString(arial, "Time", new Vector2(41, 392), Color.White);
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            spriteBatch.Draw(greySquare, new Vector2(360, 756) * (Screen.SIZE / 800f), new Rectangle(0, 0, 10, 5), Color.White * 0.95f, 0f, Vector2.Zero, 8 * (Screen.SIZE / 800f), SpriteEffects.None, 0f);
            if (Player.TeleportationCooldown > 0)
            {
                spriteBatch.Draw(greySquare, new Vector2(0, 790) * (Screen.SIZE / 800f), new Rectangle(0, 0, 10, 10), Color.Purple * 0.95f, 0f, Vector2.Zero, 80 * (float)(Player.TeleportationCooldown / Player.MAX_TELEPORTATION_COOLDOWN) * (Screen.SIZE / 800f), SpriteEffects.None, 0f);
            }
            string csecs = (((int)CurrentTime % 60) <= 9) ? "0" + ((int)CurrentTime % 60).ToString() : ((int)CurrentTime % 60).ToString();

            //spriteBatch.DrawString(arial, Math.Floor((int)CurrentTime / 60.0).ToString() + ":" + csecs, new Vector2(40, 435), Color.Black);
            spriteBatch.DrawString(arial, Math.Floor((int)CurrentTime / 60.0).ToString() + ":" + csecs, new Vector2(368, 758) * (Screen.SIZE / 800f), new Color(20, 20, 20), 0, Vector2.Zero, (Screen.SIZE / 1600f), SpriteEffects.None, 0);
        }