public static ActorPlayer Create(Rectangle bounds) { var player = new ActorPlayer(); player.SrcRectStraight = new Rectangle(396, 79, 99, 75); player.SrcRectLeft = new Rectangle(258, 246, 90, 77); player.SrcRectRight = new Rectangle(258, 167, 90, 77); player.SecondsBetweenShots = 1.2; // player can only move around bottom half of screen bounds.Y = bounds.Height / 2; bounds.Height /= 2; // adjust bounds for player sprite width bounds.Width -= player.SrcRectStraight.Width; bounds.Height -= player.SrcRectStraight.Height; // assign bounds ActorPlayer.Bounds = bounds; // center player player.Location.X = bounds.Center.X - player.SrcRectStraight.Width / 2; return player; }
private static void AddBullet(ActorPlayer player) { if (player != null && player.ShotCoolDown <= 0) { var shot = new ActorBullet(); shot.SrcRect = new Rectangle(497, 37, 9, 33); shot.Location.X = player.Location.X + player.SrcRect.Width / 2 - shot.SrcRect.Width / 2; shot.Location.Y = player.Location.Y; shot.Speed.Y = -200.0f; _bullets.Add(shot); player.ShotCoolDown = player.SecondsBetweenShots; } }