public void Update(Camera cam, bool speed) { SPEED = 10; if (speed) SPEED *= 2; GamePadState pad = GamePad.GetState(PlayerIndex.One); if (pad.IsConnected) { if (pad.ThumbSticks.Left.X != 0 || pad.ThumbSticks.Left.Y != 0) { Position.X += pad.ThumbSticks.Left.X * SPEED; Position.Y -= pad.ThumbSticks.Left.Y * SPEED; Position.X = MathHelper.Clamp(Position.X, -24000, 24000); Position.Y = MathHelper.Clamp(Position.Y, -24000, 24000); cam.Rotation = (float)Math.Atan2(pad.ThumbSticks.Left.X, pad.ThumbSticks.Left.Y); } } if (Motion != Vector2.Zero) { Motion.Y = Motion.Y - MathHelper.ToRadians(cam.Rotation); } Bounds.X = (int)Position.X; Bounds.Y = (int)Position.Y; Rotation = cam.Rotation; }
public static Bullet LookForBullet(Camera cam, Player player, ContentManager Content, bool powerup, GameTime gameTime) { LastBullet += (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (powerup) { if (LastBullet >= ShootLimit / 2) { GamePadState pad = GamePad.GetState(PlayerIndex.One); if (pad.ThumbSticks.Right.X != 0 || pad.ThumbSticks.Right.Y != 0) { Vector2 offset = new Vector2(21, 51); Matrix m = Matrix.CreateRotationZ(cam.Rotation); offset = Vector2.Transform(offset, m); Vector2 Velocity = pad.ThumbSticks.Right; Velocity.Y *= -1; Velocity.Normalize(); LastBullet = 0; GameConfig.StartVibrate(); SoundManager.PlayRandomShootingSound(); return new Bullet(player.Position + offset, player.Position + offset + Velocity, false, Content, true); } } } else { if (LastBullet >= ShootLimit) { GamePadState pad = GamePad.GetState(PlayerIndex.One); if (pad.ThumbSticks.Right.X != 0 || pad.ThumbSticks.Right.Y != 0) { Vector2 offset = new Vector2(21, 51); Matrix m = Matrix.CreateRotationZ(cam.Rotation); offset = Vector2.Transform(offset, m); Vector2 Velocity = pad.ThumbSticks.Right; Velocity.Y *= -1; Velocity.Normalize(); LastBullet = 0; GameConfig.StartVibrate(); SoundManager.PlayRandomShootingSound(); return new Bullet(player.Position + offset, player.Position + offset + Velocity, false, Content, true); } } } return null; }
public void Draw(SpriteBatch batch, Camera cam) { //batch.Draw(Texture, Bounds, null, Color.White, cam.Rotation, Vector2.Zero, SpriteEffects.None, 0f); batch.Draw(Texture, Bounds, null, Color.White, angletoPointRightWay, Vector2.Zero, SpriteEffects.None, 0); for (int i = 0; i < enemyFiredBulletList.Count; i++) { enemyFiredBulletList[i].Draw(batch); } }