void DrawPlay() { spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(0, game.GameScreenY, game.ScreenSize.X, 1), Color.White); spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(0, game.ScreenSize.Y - 1, game.ScreenSize.X, 1), Color.White); spriteBatch.Draw(CoreGlobals.BlankTexture, game.BallRect, Color.White); spriteBatch.Draw(CoreGlobals.BlankTexture, game.Paddle1Rect, Color.White); spriteBatch.Draw(CoreGlobals.BlankTexture, game.Paddle2Rect, Color.White); }
void DrawAnimatedSprite(EntityType type, Vector2 pos) { if (type != EntityType.PlayerBullet) { var srcRect = animatedSprites[(int)type].SrcRect[0]; spriteBatch.Draw(spriteSheet, pos, srcRect, Color.White, 0, new Vector2(srcRect.Width * 0.5f, srcRect.Height * 0.5f), 1, SpriteEffects.None, 0); } }
void DrawPlay() { //draw paddle spriteBatch.Draw(brickBreaker.texturePack.GetTexureForItem(Item.DiamondPickaxe), brickBreaker.Paddle.Rectangle, brickBreaker.texturePack.ItemSrcRect(Item.DiamondPickaxe), Color.White); //spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle((int)brickBreaker.Paddle.CenterPos.X, (int)brickBreaker.Paddle.CenterPos.Y - brickBreaker.Paddle.HalfHeight / 2, 1, 1), Color.Red); //draw balls for (int i = 0; i < brickBreaker.Balls.Count; i++) { spriteBatch.Draw(SpriteSheet, brickBreaker.Balls[i].Rectangle, ballSprite, brickBreaker.Balls[i].Color); // spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle((int)brickBreaker.Balls[i].CenterPos.X, (int)brickBreaker.Balls[i].CenterPos.Y, 1, 1), Color.Red); } if (brickBreaker.useRandomLayout) { DrawBricksWithTexture(); } else { DrawBricksNonTextured(); } DrawPowerUps(); DrawBullets(); if (brickBreaker.messageToPlayer != string.Empty) { spriteBatch.DrawStringCentered(font, brickBreaker.messageToPlayer, 20 * drawScale, Color.Green, 0.4f); } //var rect = brickBreaker.Paddle.Rectangle; //rect.Width = (int)(brickBreaker.Paddle.Rectangle.Width * 0.2f); //spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.White); //rect.X += rect.Width; //rect.Width = (int)(brickBreaker.Paddle.Rectangle.Width * 0.2f); //spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Red); //rect.X += rect.Width; //rect.Width = (int)(brickBreaker.Paddle.Rectangle.Width * 0.2f); //spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Green); //rect.X += rect.Width; //rect.Width = (int)(brickBreaker.Paddle.Rectangle.Width * 0.2f); //spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Blue); //rect.X += rect.Width; //rect.Width = (int)(brickBreaker.Paddle.Rectangle.Width * 0.2f); //spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Yellow); if (brickBreaker.State == BrickbreakerGame.GameState.GameOverTransition) { FlashScreen(Color.Black, new Color(15, 0, 0), 10); spriteBatch.DrawStringCentered(font, "GAME OVER ", 175, Color.Red, 1f); spriteBatch.DrawStringCentered(font, brickBreaker.ScoreText1, 225, Color.Green, 1f); if (brickBreaker.BeatHighScore()) { spriteBatch.DrawStringCentered(font, "Congrats New High Score", 255, Color.Green, 1f); } } if (brickBreaker.pauseGame) { spriteBatch.DrawStringCentered(font, "PAUSE", 200, Color.Green, 2f); } if (!brickBreaker.playerAlive) { FlashScreen(Color.Black, new Color(15, 0, 0), 10); spriteBatch.DrawStringCentered(font, "Remaining " + brickBreaker.LivesText, 200, Color.Green, 1f); } if (brickBreaker.loadingNewLevel) { FlashScreen(Color.Black, new Color(0, 15, 0), 10); spriteBatch.DrawStringCentered(font, "Level complete.", 175, Color.AntiqueWhite, 1f); if (!brickBreaker.useRandomLayout) { spriteBatch.DrawStringCentered(font, "Loading: " + brickBreaker.levelItem.ToString(), 225, Color.AntiqueWhite, 1f); } } }
void DrawPlay() { if (game.PlanetExplodeCounter > 30 && game.Random.Next(6) == 0) { var color = new Color(game.Random.Next(0, 255), game.Random.Next(0, 255), game.Random.Next(0, 255)); spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(0, 0, game.ScreenSize.X, game.ScreenSize.Y), color); } int y = game.HUDHeight + 1; var origin = new Vector2(0.5f, 0.5f); int i; if (!game.SpaceMode) { Vector2 m2 = Vector2.Zero; for (i = 0; i < game.Mountains.Count; ++i) { var m1 = game.Mountains[i]; m1.X = game.GetScreenX(m1.X); m1.Y += y; m2 = game.Mountains[i + 1 == game.Mountains.Count ? 0 : i + 1]; m2.X = game.GetScreenX(m2.X); m2.Y += y; //if (i + 1 == game.Mountains.Count) // spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle((int)m2.X, y, 1, game.ScreenSize.Y), Color.Red); if (m2.X > 0 && m1.X < game.ScreenSize.X) { spriteBatch.DrawLine(CoreGlobals.BlankTexture, 1, Color.RosyBrown, m1, m2); } } } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, null); var p = new Particle(); Vector2 pos; int particleCount = game.PlayerSpawnTimer <= 0 ? game.Particles.Length : game.StarCount; for (i = 0; i < particleCount; ++i) { if (game.Particles[i].Age > 0) { p = game.Particles[i]; if (p.Position.Y - p.Size * 0.5f >= 2) { pos.X = game.GetScreenX(p.Position.X); pos.Y = p.Position.Y + y; Color c = p.Color; if (p.Age < 0.3f) { c.A = (byte)(MathHelper.Lerp(c.A / 255.0f, 0, (0.3f - p.Age) * 3.333f) * 255f); } spriteBatch.Draw(CoreGlobals.BlankTexture, pos, null, c, 0, origin, p.Size, SpriteEffects.None, 0); } } } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, DepthStencilState.None, null); Entity entity; int entityCount = game.PlayerSpawnTimer <= 0 ? game.Entities.Length : game.HumanoidCount; for (i = 0; i < entityCount; ++i) { entity = game.Entities[i]; if (entity.Type != EntityType.None && entity.Type != EntityType.Player && entity.State != EntityState.Spawning) { pos.X = game.GetScreenX(entity.Position.X); pos.Y = entity.Position.Y + y; if (entity.Type != EntityType.EnemyBullet) { if (entity.Type == EntityType.Mutant && game.State == GameState.Play) { pos.X += (float)(game.Random.NextDouble() * 2.0 - 1.0); pos.Y += (float)(game.Random.NextDouble() * 2.0 - 1.0); } DrawAnimatedSprite(pos, entity.Rotation, entity.Type); } else { spriteBatch.Draw(CoreGlobals.BlankTexture, pos, null, Color.White, 0, origin, 2, SpriteEffects.None, 0); } } } Vector4 bullet; var rect = new Rectangle(); rect.Height = 1; for (i = 0; i < game.BulletsAlive.Length; ++i) { if (game.BulletsAlive[i]) { bullet = game.Bullets[i]; rect.X = (int)bullet.X; rect.Y = (int)bullet.Y + y; rect.Width = (int)bullet.Z; if (bullet.W < 1) { rect.X -= rect.Width; } spriteBatch.Draw(CoreGlobals.BlankTexture, rect, Color.Green); } } var player = game.Entities[game.PlayerIndex]; if (player.State == EntityState.Default) { SpriteAnimations[(int)EntityType.Player].Effects = game.PlayerDir > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; DrawAnimatedSprite(game.PlayerScreenPos + new Vector2(0, y), 0, EntityType.Player); } else if (player.State == EntityState.PlayerDeath) { Color color = ((game.PlayerDeathTimer / 10) % 2) == 0 ? Color.Red : Color.White; origin = new Vector2(playerDeathRect.Width * 0.5f, playerDeathRect.Height * 0.5f); spriteBatch.Draw(SpriteSheet, game.PlayerScreenPos + new Vector2(0, y), playerDeathRect, color, 0, origin, 1, game.PlayerDir > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); } var sprite = new TimedSprite(); for (i = 0; i < game.TimedSprites.Length; ++i) { if (game.TimedSprites[i].Frame > 0) { sprite = game.TimedSprites[i]; var srcRect = sprite.SrcRects[sprite.Frame - 1]; var destRect = new Rectangle((int)sprite.Position.X, (int)sprite.Position.Y, srcRect.Width, srcRect.Height); spriteBatch.Draw(SpriteSheet, destRect, srcRect, Color.White); } } }