public EnterBill(EventHandler callback) : base(callback) { // initialize Stats.Clear(); startTime = DateTime.Now; Game1.Game.Window.Title = ""; bill = new BaseObject(new Rectangle(0, 0, BILLWIDTH, BILLHEIGHT), new Vector2(0, 0)); bill.CenterPoint = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); skipButton = new BaseObject(new Rectangle(GraphicsDevice.Viewport.Width - SKIPWIDTH, GraphicsDevice.Viewport.Height - SKIPHEIGHT, SKIPWIDTH, SKIPHEIGHT), new Vector2(0, 0)); // load content if (!contentLoaded) { billTexture = Content.Load<Texture2D>("billtransparent"); bill2Texture = Content.Load<Texture2D>("bill2transparent"); button1Texture = Content.Load<Texture2D>("titlebutton1"); button2Texture = Content.Load<Texture2D>("titlebutton2"); enterBillFont1 = Content.Load<SpriteFont>("EnterBillFont1"); titleFont2 = Content.Load<SpriteFont>("TitleFont2"); actTitleFont = Content.Load<SpriteFont>("ActTitleFont"); enterBill = Content.Load<Song>("enterbill"); } // play music MediaPlayer.Play(enterBill); MediaPlayer.Volume = 1; }
public Laser(Vector2 position, Vector2 speed, int size, int length) { this.position = position; firstBit = new BaseObject(new Rectangle((int)position.X, (int)position.Y, size, size)); Speed = speed; this.size = size; this.length = length; angle = (float)Math.Atan2(speed.Y, speed.X); timeSinceLastShot = shootDelay; Lasers.Add(this); }
public TitleScreen(EventHandler callback, bool startMusic) : base(callback) { // initialize startTime = DateTime.Now; Game1.Game.Window.Title = "Welcome to Bill's lair."; Game1.Game.IsMouseVisible = true; isaac = new BaseObject(new Rectangle(0, 0, 100, 100), new Vector2(0, 0)); isaac.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height / 2); startButton = new SimpleButton(new Rectangle(0, 0, STARTBUTTONWIDTH, STARTBUTTONHEIGHT), button1Texture, button1Texture, button2Texture); startButton.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, isaac.Y - 40); SimpleButton.AddButton(startButton); physicsButton = new BaseObject(new Rectangle(0, 0, INSTRUCTIONSBUTTONWIDTH, INSTRUCTIONSBUTTONHEIGHT), new Vector2(0, 0)); physicsButton.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, isaac.Y + isaac.Height + 40); exitButton = new BaseObject(new Rectangle(0, 0, EXITBUTTONWIDTH, EXITBUTTONHEIGHT), new Vector2(0, 0)); exitButton.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, physicsButton.Y + physicsButton.Height + 40); // load content if (!contentLoaded) { button1Texture = Content.Load<Texture2D>("titlebutton1"); button2Texture = Content.Load<Texture2D>("titlebutton2"); isaacTexture = Content.Load<Texture2D>("isaac"); isaac1 = Content.Load<Texture2D>("isaacswirl1"); isaac2 = Content.Load<Texture2D>("isaacswirl2"); isaac3 = Content.Load<Texture2D>("isaacswirl3"); isaac4 = Content.Load<Texture2D>("isaacswirl4"); isaac5 = Content.Load<Texture2D>("isaacswirl5"); titleFont1 = Content.Load<SpriteFont>("TitleFont1"); titleFont2 = Content.Load<SpriteFont>("TitleFont2"); titleTheme = Content.Load<Song>("titletheme"); contentLoaded = true; } isaacAnimation = new Animation(1.5f, 6f, isaac1 , isaac2, isaac3, isaac4, isaac5, isaac4, isaac3, isaac2, isaac1); //isaacAnimation.Start(); // play music if (startMusic) { MediaPlayer.Play(titleTheme); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = .25f; } }
public CrystalGun(Rectangle rectangle, Rectangle boardRectangle, int wheelSize, Texture2D gunTexture, Texture2D boardTexture, Texture2D wheelTexture) : base(rectangle) { Texture = gunTexture; board = new BaseObject(boardRectangle); board.CenterPoint = Position; board.Texture = boardTexture; wheel1 = new BaseObject(new Rectangle(0, 0, wheelSize, wheelSize)); wheel1.PrecisePosition = board.CenterPoint - new Vector2(26, 0); wheel2 = new BaseObject(new Rectangle(0, 0, wheelSize, wheelSize)); wheel2.PrecisePosition = board.CenterPoint + new Vector2(26, 0); wheel1.Texture = wheel2.Texture = wheelTexture; wheelCircumference = wheelSize / 2 * (float)Math.PI; }
public EndBattle1(EventHandler callback) : base(callback, false) { if (!contentLoaded) { endBattle1Font1 = Content.Load<SpriteFont>("EndBattle1Font1"); actTitleFont = Content.Load<SpriteFont>("ActTitleFont"); keysTexture = Content.Load<Texture2D>("carkeys"); rollerBladesTexture = Content.Load<Texture2D>("rollerblades"); wizardTexture = Content.Load<Texture2D>("mikewizard"); mikeTheme = Content.Load<Song>("miketheme"); } MediaPlayer.Stop(); bill.speed = new Vector2(4500, 4500); bill.Width *= 2; bill.Height *= 2; billHealthBar.Width *= 2; bill.HP = 0; Bullet.Cans.Clear(); PowerUp.RemoveAlivePowerUps(); string status = "BAHUHUHUHUHUHUHUH"; currentBillMessage = LOWHPMESSAGE; Game1.Game.Window.Title = status; soundEffectManager.Play(billDeath, 1f); keys = new BaseObject(new Rectangle(0, 0, 50, 50)); keys.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height / 2); keys.Texture = keysTexture; wizard = new BaseObject(new Rectangle(0, 0, WIZARDWIDTH, WIZARDHEIGHT)); wizard.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height * .48f); wizard.Texture = wizardTexture; rollerBlades = new BaseObject(new Rectangle(0, 0, ROLLERBLADESWIDTH, ROLLERBLADESHEIGHT)); rollerBlades.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height * .9f); rollerBlades.Texture = rollerBladesTexture; }
public Battle1(EventHandler callback, bool startMusic) : base(callback) { // initialize Game1.Game.IsMouseVisible = false; bill = new Character(new Rectangle(0, 0, BILLWIDTH, BILLHEIGHT), new Vector2(GameSettings.BillSpeed, GameSettings.BillSpeed)); isaac = new Character(new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - ISAACWIDTH / 2, 0, ISAACWIDTH, ISAACHEIGHT), new Vector2(GameSettings.IsaacSpeed, GameSettings.IsaacSpeed)); billHealthBar = new HealthBar(new Rectangle(0, 0, bill.Width, bill.Height / 12)); billTarget = new Vector2(rand.Next(BILLWIDTH / 2, Graphics.GraphicsDevice.Viewport.Width - BILLWIDTH / 2), rand.Next(BILLHEIGHT / 2, Graphics.GraphicsDevice.Viewport.Height - BILLHEIGHT / 2)); Bullet.Peanuts.Clear(); Bullet.Cans.Clear(); PowerUp.RemoveAlivePowerUps(); startTime = timeOfLastDeath = DateTime.Now; bill.HP = bill.MaxHP = GameSettings.BillHP; bill.ShootDelay = (int)(1000 / GameSettings.BillShootSpeed); isaac.ShootDelay = (int)(250 / GameSettings.IsaacShootSpeed); isaac.TimeSinceLastShot = isaac.ShootDelay; isaac.Y = Graphics.GraphicsDevice.Viewport.Height - ISAACHEIGHT; billMessages = new string[] { "MUH", "MEH", "R U DUMB"}; billHPString = ""; billStatusString = ""; sledgeHammer = new BaseObject(new Rectangle(0, 0, SLEDGEHAMMERWIDTH, SLEDGEHAMMERHEIGHT), 0f); sledgeHammerOrigin = new BaseObject(new Rectangle(0, 0, 1, SLEDGEHAMMERHEIGHT), 0f); allowPause = true; cleanupCounter = 0; generateIsaacSpawnPoints(); // load content if (!contentLoaded) { deathSound = Content.Load<SoundEffect>("death"); billHit = Content.Load<SoundEffect>("billhit"); billDeath = Content.Load<SoundEffect>("billdeath"); getPowerUp = Content.Load<SoundEffect>("getpowerup"); canDeath = Content.Load<SoundEffect>("candeath"); useHammer = Content.Load<SoundEffect>("usehammersound"); music = Content.Load<Song>("battlemusic"); billTexture = Content.Load<Texture2D>("bill"); //billTexture = Content.Load<Texture2D>("billtransparent"); //billTexture2 = Content.Load<Texture2D>("bill2transparent"); isaacTexture = Content.Load<Texture2D>("isaac"); isaacUsingHammerTexture = Content.Load<Texture2D>("isaacusinghammer"); font1 = Content.Load<SpriteFont>("Battle1Font1"); powerUpFont = Content.Load<SpriteFont>("Battle1PowerUpFont"); billStatusFont = Content.Load<SpriteFont>("Battle1BillStatusFont"); shieldTexture = Content.Load<Texture2D>("shield"); powerUpBarTexture = Content.Load<Texture2D>("poweruptimebar"); sledgeHammerTexture = Content.Load<Texture2D>("sledgehammer"); contentLoaded = true; } bill.Texture = billTexture; isaac.Texture = isaacTexture; sledgeHammer.Texture = sledgeHammerTexture; if (startMusic) { MediaPlayer.Play(music); MediaPlayer.Volume = .25f; MediaPlayer.IsRepeating = true; } }
public Rts(EventHandler callback) : base(callback) { Game1.Game.DebugMonitor.Position = Direction.NorthEast; //Game1.Game.IsMouseVisible = false; //Game1.Game.Graphics.SynchronizeWithVerticalRetrace = false; //Game1.Game.IsFixedTimeStep = false; //Game1.Game.Graphics.ApplyChanges(); map = new Map(@"Content/map1.txt"); Unit.Map = map; actualMapWidth = map.Width * map.TileSize; actualMapHeight = map.Height * map.TileSize; Unit.UnitCollisionSweeper.Thread.Suspend(); Unit.UnitCollisionSweeper.Thread.Resume(); Unit.PathFinder.ResumeThread(); uiViewport = GraphicsDevice.Viewport; worldViewport = GraphicsDevice.Viewport; worldViewport.Height -= (minimapSize + minimapBorderSize * 2); GraphicsDevice.Viewport = worldViewport; camera = new Camera(); camera.Pos = new Vector2(worldViewport.Width / 2, worldViewport.Height / 2); button1 = new BaseObject(new Rectangle(10, 25, 25, 25)); button2 = new BaseObject(new Rectangle(10, 52, 25, 25)); button3 = new BaseObject(new Rectangle(10, 79, 25, 25)); if (!contentLoaded) { pauseFont = Content.Load<SpriteFont>("Battle1BillStatusFont"); fpsFont = Content.Load<SpriteFont>("TitleFont1"); brownGuyTexture = Content.Load<Texture2D>("browncircleguy"); brownGuySelectingTexture = Content.Load<Texture2D>("browncircleguyselected2"); brownGuySelectedTexture = Content.Load<Texture2D>("browncircleguyselecting2"); buttonTexture = Content.Load<Texture2D>("titlebutton1"); moveCommandTexture = Content.Load<Texture2D>("greencircle2"); //normalCursorTexture = Content.Load<Texture2D>("greencursor2"); //attackCommandCursorTexture = Content.Load<Texture2D>("crosshair"); normalCursor = Util.LoadCustomCursor(@"Content/SC2-cursor.cur"); attackCursor = Util.LoadCustomCursor(@"Content/SC2-target-none.cur"); boulder1Texture = Content.Load<Texture2D>("boulder1"); tree1Texture = Content.Load<Texture2D>("tree2"); redCircleTexture = Content.Load<Texture2D>("redcircle"); transparentTexture = Content.Load<Texture2D>("transparent"); rtsMusic = Content.Load<Song>("rtsmusic"); Unit.BulletTexture = Content.Load<Texture2D>("bullet"); Unit.Explosion1Textures = Util.SplitTexture(Content.Load<Texture2D>("explosionsheet1"), 45, 45); contentLoaded = true; } winForm = (Form)Form.FromHandle(Game1.Game.Window.Handle); winForm.Cursor = normalCursor; initializeMinimap(); SelectBox.InitializeSelectBoxLine(GraphicsDevice, Color.Green); InitializeSelectionRingLine(GraphicsDevice, Color.Yellow); minimapScreenIndicatorBoxLine = new PrimitiveLine(GraphicsDevice, 1); minimapScreenIndicatorBoxLine.Colour = Color.White; for (int i = 0; i < HotkeyGroups.Length; i++) HotkeyGroups[i] = new List<Unit>(); MediaPlayer.Play(rtsMusic); MediaPlayer.Volume = .25f; MediaPlayer.IsRepeating = true; }
void initializeMinimap() { // set minimap fields and create rectangle object minimapPosX = minimapBorderSize; minimapPosY = uiViewport.Height - minimapSize - minimapBorderSize; minimapToMapRatioX = (float)minimapSize / (map.Width * map.TileSize); minimapToMapRatioY = (float)minimapSize / (map.Height * map.TileSize); minimapToScreenRatioX = (float)minimapSize / worldViewport.Width; minimapToScreenRatioY = (float)minimapSize / worldViewport.Height; minimap = new Rectangle(minimapPosX, minimapPosY, minimapSize, minimapSize); minimapScreenIndicatorBox = new BaseObject(new Rectangle(0, 0, (int)(worldViewport.Width * minimapToMapRatioX), (int)(worldViewport.Height * minimapToMapRatioY))); //minimapTexture = new Texture2D(GraphicsDevice, map.Width * Map.TILESIZE, map.Height * Map.TILESIZE); //minimapTexture = new RenderTarget2D(GraphicsDevice, map.Width * Map.TILESIZE, map.Height * Map.TILESIZE); // create minimap texture from map tiles RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, map.Width * map.TileSize, map.Height * map.TileSize); GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.Gray); SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); spriteBatch.Begin(); for (int x = 0; x < map.Width; x++) { for (int y = 0; y < map.Height; y++) { MapTile tile = map.Tiles[y, x]; if (tile.Type == 0) spriteBatch.Draw(ColorTexture.Gray, tile.Rectangle, Color.White); else if (tile.Type == 1) spriteBatch.Draw(boulder1Texture, tile.Rectangle, Color.White); else if (tile.Type == 2) spriteBatch.Draw(tree1Texture, tile.Rectangle, Color.White); } } spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); //minimapTexture = (Texture2D)renderTarget; minimapTexture = new Texture2D(GraphicsDevice, map.Width * map.TileSize, map.Height * map.TileSize); Color[] textureData = new Color[(map.Width * map.TileSize) * (map.Height * map.TileSize)]; renderTarget.GetData<Color>(textureData); minimapTexture.SetData<Color>(textureData); renderTarget = null; GC.Collect(); }
public virtual void Seek(GameTime gameTime) { if (target != null) { targetAngle = MathHelper.WrapAngle((float)Math.Atan2(target.CenterPoint.Y - CenterPoint.Y, target.CenterPoint.X - CenterPoint.X)); targetX = (float)Math.Cos(targetAngle); targetY = (float)Math.Sin(targetAngle); Vector3 oldAngleVector = new Vector3(LastMove.X, LastMove.Y, 0); Vector3 newAngleVector = new Vector3(targetX, targetY, 0); Vector3 crossProduct = Vector3.Cross(oldAngleVector, newAngleVector); if (crossProduct.Z > 0) Rotation += Util.ScaleWithGameTime(rotationSpeed, gameTime); else if (crossProduct.Z < 0) Rotation -= Util.ScaleWithGameTime(rotationSpeed, gameTime); if (seekOnce && Util.AngleDifference(Rotation, targetAngle) < Util.ScaleWithGameTime(rotationSpeed, gameTime)) target = null; } movePrecise(Rotation, gameTime, false); }
public override bool Intersects(BaseObject o) { float angle = (float)Math.Atan2(o.CenterPoint.Y - centerPoint.Y, o.CenterPoint.X - centerPoint.X); Vector2 point = centerPoint + new Vector2(radius * (float)Math.Cos(angle), radius * (float)Math.Sin(angle)); return o.Touches(point); }
public PhysicsScreen(EventHandler callback) : base(callback) { // initialize //Game1.Game.Window.Title = "The Physics"; startTime = DateTime.Now; Game1.Game.IsMouseVisible = true; returnButton = new BaseObject(new Rectangle(0, 0, RETURNBUTTONWIDTH, RETURNBUTTONHEIGHT), new Vector2(0, 0)); returnButton.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height - returnButton.Height/2 - 1); // load content if (!contentLoaded) { physicsFont1 = Content.Load<SpriteFont>("PhysicsFont1"); titleFont2 = Content.Load<SpriteFont>("TitleFont2"); titleTheme = Content.Load<Song>("titletheme"); button1Texture = Content.Load<Texture2D>("titlebutton1"); button2Texture = Content.Load<Texture2D>("titlebutton2"); upButtonTexture = Content.Load<Texture2D>("physicsupbutton"); downButtonTexture = Content.Load<Texture2D>("physicsdownbutton"); multiplierButtonTexture = Content.Load<Texture2D>("physicsmultiplier"); toggleOnTexture = Content.Load<Texture2D>("togglebuttonon"); redRingTexture = Content.Load<Texture2D>("redring"); einsteinTexture = Content.Load<Texture2D>("einstein"); } int x = Graphics.GraphicsDevice.Viewport.Width / 4; einstein = new Rectangle(x / 2 - EINSTEINWIDTH / 2 - 2 + shiftX / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - EINSTEINHEIGHT / 2, EINSTEINWIDTH, EINSTEINHEIGHT); // create button rectangles spacing = (int)physicsFont1.MeasureString(" ").Y; int offsetY = startPosY; x = Graphics.GraphicsDevice.Viewport.Width / 2 + 100; int size = (int)(spacing * .9f); multiplierButton = new Rectangle(x + spacing / 3, offsetY - (int)(size * 1.5f), (int)(size * 1.4f), (int)(size * 1.35f)); isaacSpeedButtonDown = new Rectangle(x, offsetY, size, size); isaacSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; speedBoostButtonDown = new Rectangle(x, offsetY, size, size); speedBoostButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; isaacShootSpeedButtonDown = new Rectangle(x, offsetY, size, size); isaacShootSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; peanutDamageButtonDown = new Rectangle(x, offsetY, size, size); peanutDamageButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; peanutSpeedButtonDown = new Rectangle(x, offsetY, size, size); peanutSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billHPButtonDown = new Rectangle(x, offsetY, size, size); billHPButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billLifeStealButtonDown = new Rectangle(x, offsetY, size, size); billLifeStealButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billSpeedButtonDown = new Rectangle(x, offsetY, size, size); billSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billShootSpeedButtonDown = new Rectangle(x, offsetY, size, size); billShootSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billSprayFireSpeedButtonDown = new Rectangle(x, offsetY, size, size); billSprayFireSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; canSpeedButtonDown = new Rectangle(x, offsetY, size, size); canSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpSpawnDelayButtonDown = new Rectangle(x, offsetY, size, size); powerUpSpawnDelayButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpAliveButtonDown = new Rectangle(x, offsetY, size, size); powerUpAliveButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpActiveButtonDown = new Rectangle(x, offsetY, size, size); powerUpActiveButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; canShieldChargesButtonDown = new Rectangle(x, offsetY, size, size); canShieldChargesButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; spawnSafetyButtonDown = new Rectangle(x, offsetY, size, size); spawnSafetyButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; // create preset buttons x += spacing * 2; presetEasy = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, startPosY, PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); presetNormal = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, presetEasy.Y + PRESETBUTTONHEIGHT + (int)(spacing * .1), PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); presetHard = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, presetNormal.Y + PRESETBUTTONHEIGHT + (int)(spacing * .1), PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); // create toggle buttons offsetY = Graphics.GraphicsDevice.Viewport.Height / 2 + size * 3; cansBlockPeanutsToggleButton = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 + ((int)physicsFont1.MeasureString("Cans block peanuts: ").X) / 2 - size / 2, offsetY, size, size); offsetY += spacing; projectileRotationCollisionToggleButton = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 + ((int)physicsFont1.MeasureString("Cans block peanuts: ").X) / 2 - size / 2, offsetY, size, size); offsetY += spacing; }
public Magnet(Vector2 position, int size, BaseObject target, float speed, float rotationSpeed) : base(position, size, target, speed, rotationSpeed) { }
public virtual bool Intersects(BaseObject theRectangle) { List<Vector2> aRectangleAxis = new List<Vector2>(); aRectangleAxis.Add(UpperRightCorner - UpperLeftCorner); aRectangleAxis.Add(UpperRightCorner - LowerRightCorner); aRectangleAxis.Add(theRectangle.UpperLeftCorner - theRectangle.LowerLeftCorner); aRectangleAxis.Add(theRectangle.UpperLeftCorner - theRectangle.UpperRightCorner); foreach (Vector2 aAxis in aRectangleAxis) { if (!IsAxisCollision(theRectangle, aAxis)) { return false; } } return true; }
void Shoot() { BaseObject bit = new BaseObject(new Rectangle((int)position.X, (int)position.Y, size, size), Speed); bit.Texture = Texture; bit.Rotation = angle;// +(float)Math.PI / 2; Bits.Add(bit); if (Bits.Count == 1) firstBit = bit; }
void shootMice(Character isaac) { Vector2 mousePoint = MagicStaffPoint + new Vector2(magicStaff.Width * (float)Math.Cos(magicStaff.Rotation), magicStaff.Width * (float)Math.Sin(magicStaff.Rotation)); BaseObject target = new BaseObject(new Rectangle((int)isaac.CenterPoint.X, (int)isaac.CenterPoint.Y, 1, 1)); float beginAngle = magicStaff.Rotation - (float)Math.PI / 2; float endAngle = magicStaff.Rotation + (float)Math.PI / 2; int numberOfMice = 10; //float rotation = (float)Math.PI / numberOfMice; float rotation = MathHelper.TwoPi / numberOfMice; for (int i = 0; i < numberOfMice; i++, beginAngle += rotation) { //MouseSeeker m = new MouseSeeker(mousePoint, 300, 15, 2, 25, isaac, 2); MouseSeeker m = new MouseSeeker(mousePoint, miceSpeed, miceSize, cordSize, miceLength, magicStaff.Rotation, 5); m.Angle = beginAngle; } }
public AlexEnchanter(Rectangle rectangle) : base(rectangle) { speed = new Vector2(500, 500); warpOutAnimation = new Animation(warpAnimationDuration, WarpTextures); warpInAnimation = new Animation(warpAnimationDuration, WarpTextures[9], WarpTextures[8], WarpTextures[7], WarpTextures[6], WarpTextures[5], WarpTextures[4], WarpTextures[3], WarpTextures[2], WarpTextures[1], WarpTextures[0]); castAnimation = new Animation(castAnimationDuration, CastTextures[0], CastTextures[1], CastTextures[2], CastTextures[3], CastTextures[4], CastTextures[5], CastTextures[6], CastTextures[7], CastTextures[8], CastTextures[9], CastTextures[8], CastTextures[7], CastTextures[6], CastTextures[5], CastTextures[4], CastTextures[3], CastTextures[2], CastTextures[1], CastTextures[0]); PeanutShield = new AnimatedObject(new Rectangle(0, 0, 0, 0), new Animation(-1, 45, PeanutShieldTextures[0], PeanutShieldTextures[1], PeanutShieldTextures[2], PeanutShieldTextures[3], PeanutShieldTextures[2], PeanutShieldTextures[1], PeanutShieldTextures[0])); createWarpLocations(); magicStaff = new BaseObject(new Rectangle(0, 0, magicStaffWidth, magicStaffHeight)); magicStaff.Texture = MagicStaffTexture; HP = MaxHP = DEFAULTMAXHP; }
public void AddPotentialCollision(BaseObject o) { lock (PotentialCollisionsLock) { potentialCollisions.Add(o); } }
private bool IsAxisCollision(BaseObject theRectangle, Vector2 aAxis) { //List<int> aRectangleAScalars = new List<int>(); aRectangleAScalars.Clear(); aRectangleAScalars.Add(GenerateScalar(theRectangle.UpperLeftCorner, aAxis)); aRectangleAScalars.Add(GenerateScalar(theRectangle.UpperRightCorner, aAxis)); aRectangleAScalars.Add(GenerateScalar(theRectangle.LowerLeftCorner, aAxis)); aRectangleAScalars.Add(GenerateScalar(theRectangle.LowerRightCorner, aAxis)); //List<int> aRectangleBScalars = new List<int>(); aRectangleBScalars.Clear(); aRectangleBScalars.Add(GenerateScalar(UpperLeftCorner, aAxis)); aRectangleBScalars.Add(GenerateScalar(UpperRightCorner, aAxis)); aRectangleBScalars.Add(GenerateScalar(LowerLeftCorner, aAxis)); aRectangleBScalars.Add(GenerateScalar(LowerRightCorner, aAxis)); int aRectangleAMinimum = aRectangleAScalars.Min(); int aRectangleAMaximum = aRectangleAScalars.Max(); int aRectangleBMinimum = aRectangleBScalars.Min(); int aRectangleBMaximum = aRectangleBScalars.Max(); if (aRectangleBMinimum <= aRectangleAMaximum && aRectangleBMaximum >= aRectangleAMaximum) { return true; } else if (aRectangleAMinimum <= aRectangleBMaximum && aRectangleAMaximum >= aRectangleBMaximum) { return true; } return false; }
public bool Intersects(Rectangle theRectangle) { BaseObject o = new BaseObject(theRectangle, 0.0f); o.CalculateCorners(); return Intersects(o); }
public SeekerSnake(Vector2 position, float speed, int size, int length, BaseObject target, float rotationSpeed) : this(position, speed, size, length, 0, rotationSpeed) { Target = target; Angle = (float)Math.Atan2(target.CenterPoint.Y - frontBit.CenterPoint.Y, target.CenterPoint.X - frontBit.CenterPoint.X); }
public bool IsNearRotated(BaseObject r, float factor) { Rectangle inflatedRectangle = new Rectangle(X, Y, Width, Height); inflatedRectangle.Inflate((int)(Width * factor), (int)(Height * factor)); return r.Intersects(inflatedRectangle); }
public override bool Intersects(BaseObject o) { float angle = (float)Math.Atan2(o.CenterPoint.Y - centerPoint.Y, o.CenterPoint.X - centerPoint.X); Vector2 point = centerPoint + new Vector2(Radius * (float)Math.Cos(angle), Radius * (float)Math.Sin(angle)); //return o.Touches(point); return o.Touches(point);// || //((Math.Abs(centerPoint.X - o.X) < radius || Math.Abs(centerPoint.X - (o.X + o.Width)) < radius) && //(Math.Abs(centerPoint.Y - o.Y) < radius || Math.Abs(centerPoint.Y - (o.Y + o.Height)) < radius)); }
public Battle2(EventHandler callback) : base(callback) { if (!contentLoaded) { pauseFont = Content.Load<SpriteFont>("Battle1BillStatusFont"); powerUpFont = Content.Load<SpriteFont>("Battle1PowerUpFont"); alexEnchanterTexture = Content.Load<Texture2D>("alexenchanter"); isaacTexture = Content.Load<Texture2D>("isaac"); transparentTexture = Content.Load<Texture2D>("transparent"); burntPeanutTexture = Content.Load<Texture2D>("peanutgray"); battle2Music = Content.Load<Song>("battle2music"); hurtSounds = new SoundEffect[3]; hurtSounds[0] = Content.Load<SoundEffect>("hurt1"); hurtSounds[1] = Content.Load<SoundEffect>("hurt2"); hurtSounds[2] = Content.Load<SoundEffect>("hurt3"); isaacHurtBadSound = Content.Load<SoundEffect>("isaachurtbad"); alexLaugh = Content.Load<SoundEffect>("alexlaugh"); alexEnchanterHitSound = Content.Load<SoundEffect>("OOT_Armos_Hit"); //alexEnchanterHitSound = Content.Load<SoundEffect>("OOT_ReDead_Hump"); peanutShieldDeflectSound = Content.Load<SoundEffect>("peanutShieldDeflect"); potionDrinkSound = Content.Load<SoundEffect>("potiondrink"); getPowerUpSound = Content.Load<SoundEffect>("getpowerup"); useHammerSound = Content.Load<SoundEffect>("usehammersound"); fireballHitSound = Content.Load<SoundEffect>("fireballhit"); lowHealthBeep = Content.Load<SoundEffect>("lowhealthbeep"); superFireballRoll = Content.Load<SoundEffect>("fireballrolling"); peanutShieldBreakSound = Content.Load<SoundEffect>("peanutshieldbreaksound"); powerUpBarTexture = Content.Load<Texture2D>("poweruptimebar"); sledgeHammerTexture = Content.Load<Texture2D>("sledgehammer"); hearts = new Texture2D[5]; heartEmptyTexture = Content.Load<Texture2D>("heart_empty"); heartOneQuarterTexture = Content.Load<Texture2D>("heart_onequarter"); heartHalfTexture = Content.Load<Texture2D>("heart_half"); heartThreeQuartersTexture = Content.Load<Texture2D>("heart_3quarters"); heartFullTexture = Content.Load<Texture2D>("heart_Full"); contentLoaded = true; } Game1.Game.IsMouseVisible = false; isaac = new Character(new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - ISAACWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height - ISAACHEIGHT, ISAACWIDTH, ISAACHEIGHT), new Vector2(GameSettings.IsaacSpeed, GameSettings.IsaacSpeed)); isaac.Texture = isaacTexture; isaac.HP = isaac.MaxHP = ISAAC_MAX_HP; isaac.ShootDelay = (int)(250 / GameSettings.IsaacShootSpeed); isaac.TimeSinceLastShot = isaac.ShootDelay; isaacHurtAnimation = new Animation(1, 50, transparentTexture, isaacTexture); lowHealthBeeping = new LoopingSoundEffect(lowHealthBeep, .25f); updateHearts(); alexEnchanter = new AlexEnchanter(new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - ENCHANTERWIDTH / 2, 25, ENCHANTERWIDTH, ENCHANTERHEIGHT)); alexEnchanter.Texture = alexEnchanterTexture; alex = alexEnchanter; alexHealthBar = new HealthBar(new Rectangle(0, 0, 200, 10)); sledgeHammer = new BaseObject(new Rectangle(0, 0, SLEDGEHAMMERWIDTH, SLEDGEHAMMERHEIGHT), 0f); sledgeHammerOrigin = new BaseObject(new Rectangle(0, 0, 1, SLEDGEHAMMERHEIGHT), 0f); sledgeHammer.Texture = sledgeHammerTexture; superFireballRolling = new LoopingSoundEffect(superFireballRoll, .35f); soundEffectManager.Play(alexLaugh, .25f); MediaPlayer.Play(battle2Music); MediaPlayer.Volume = .25f; MediaPlayer.IsRepeating = true; }
public PhysicsScreen(EventHandler callback) : base(callback) { // initialize //Game1.Game.Window.Title = "The Physics"; startTime = DateTime.Now; Game1.Game.IsMouseVisible = true; returnButton = new BaseObject(new Rectangle(0, 0, RETURNBUTTONWIDTH, RETURNBUTTONHEIGHT), new Vector2(0, 0)); returnButton.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height - returnButton.Height / 2 - 1); // load content if (!contentLoaded) { physicsFont1 = Content.Load <SpriteFont>("PhysicsFont1"); titleFont2 = Content.Load <SpriteFont>("TitleFont2"); titleTheme = Content.Load <Song>("titletheme"); button1Texture = Content.Load <Texture2D>("titlebutton1"); button2Texture = Content.Load <Texture2D>("titlebutton2"); upButtonTexture = Content.Load <Texture2D>("physicsupbutton"); downButtonTexture = Content.Load <Texture2D>("physicsdownbutton"); multiplierButtonTexture = Content.Load <Texture2D>("physicsmultiplier"); toggleOnTexture = Content.Load <Texture2D>("togglebuttonon"); redRingTexture = Content.Load <Texture2D>("redring"); einsteinTexture = Content.Load <Texture2D>("einstein"); } int x = Graphics.GraphicsDevice.Viewport.Width / 4; einstein = new Rectangle(x / 2 - EINSTEINWIDTH / 2 - 2 + shiftX / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - EINSTEINHEIGHT / 2, EINSTEINWIDTH, EINSTEINHEIGHT); // create button rectangles spacing = (int)physicsFont1.MeasureString(" ").Y; int offsetY = startPosY; x = Graphics.GraphicsDevice.Viewport.Width / 2 + 100; int size = (int)(spacing * .9f); multiplierButton = new Rectangle(x + spacing / 3, offsetY - (int)(size * 1.5f), (int)(size * 1.4f), (int)(size * 1.35f)); isaacSpeedButtonDown = new Rectangle(x, offsetY, size, size); isaacSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; speedBoostButtonDown = new Rectangle(x, offsetY, size, size); speedBoostButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; isaacShootSpeedButtonDown = new Rectangle(x, offsetY, size, size); isaacShootSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; peanutDamageButtonDown = new Rectangle(x, offsetY, size, size); peanutDamageButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; peanutSpeedButtonDown = new Rectangle(x, offsetY, size, size); peanutSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billHPButtonDown = new Rectangle(x, offsetY, size, size); billHPButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billLifeStealButtonDown = new Rectangle(x, offsetY, size, size); billLifeStealButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billSpeedButtonDown = new Rectangle(x, offsetY, size, size); billSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billShootSpeedButtonDown = new Rectangle(x, offsetY, size, size); billShootSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; billSprayFireSpeedButtonDown = new Rectangle(x, offsetY, size, size); billSprayFireSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; canSpeedButtonDown = new Rectangle(x, offsetY, size, size); canSpeedButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpSpawnDelayButtonDown = new Rectangle(x, offsetY, size, size); powerUpSpawnDelayButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpAliveButtonDown = new Rectangle(x, offsetY, size, size); powerUpAliveButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; powerUpActiveButtonDown = new Rectangle(x, offsetY, size, size); powerUpActiveButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; canShieldChargesButtonDown = new Rectangle(x, offsetY, size, size); canShieldChargesButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; spawnSafetyButtonDown = new Rectangle(x, offsetY, size, size); spawnSafetyButtonUp = new Rectangle(x + spacing, offsetY, size, size); offsetY += spacing; // create preset buttons x += spacing * 2; presetEasy = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, startPosY, PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); presetNormal = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, presetEasy.Y + PRESETBUTTONHEIGHT + (int)(spacing * .1), PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); presetHard = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 - PRESETBUTTONWIDTH / 2, presetNormal.Y + PRESETBUTTONHEIGHT + (int)(spacing * .1), PRESETBUTTONWIDTH, PRESETBUTTONHEIGHT); // create toggle buttons offsetY = Graphics.GraphicsDevice.Viewport.Height / 2 + size * 3; cansBlockPeanutsToggleButton = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 + ((int)physicsFont1.MeasureString("Cans block peanuts: ").X) / 2 - size / 2, offsetY, size, size); offsetY += spacing; projectileRotationCollisionToggleButton = new Rectangle(x + (Graphics.GraphicsDevice.Viewport.Width - x) / 2 + ((int)physicsFont1.MeasureString("Cans block peanuts: ").X) / 2 - size / 2, offsetY, size, size); offsetY += spacing; }
public PostGame(EventHandler callback) : base(callback) { Game1.Game.IsMouseVisible = true; Game1.Game.Window.Title = "Congratulations!"; startTime = DateTime.Now; if (!contentLoaded) { postGameMusic = Content.Load<Song>("postgamemusic"); mikeTexture = Content.Load<Texture2D>("mikeglasses"); mrPeanutTexture = Content.Load<Texture2D>("mrpeanut"); buttonTexture1 = Content.Load<Texture2D>("titlebutton1"); buttonTexture2 = Content.Load<Texture2D>("titlebutton2"); bigFont = Content.Load<SpriteFont>("PostGameFont1"); mediumFont = Content.Load<SpriteFont>("PostGameFont2"); smallFont = Content.Load<SpriteFont>("PostGameFont3"); buttonFont = Content.Load<SpriteFont>("TitleFont2"); } pongo = new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - PONGOWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - PONGOHEIGHT / 2, PONGOWIDTH, PONGOHEIGHT); mrPeanut = new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - MRPEANUTWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - MRPEANUTHEIGHT / 2, MRPEANUTWIDTH, MRPEANUTHEIGHT); returnButton = new BaseObject(new Rectangle(pongo.X, Graphics.GraphicsDevice.Viewport.Height - RETURNBUTTONHEIGHT - 1, RETURNBUTTONWIDTH, RETURNBUTTONHEIGHT), new Vector2(0, 0)); returnButton.CenterPoint = new Vector2(pongo.X + pongo.Width * .25f, Graphics.GraphicsDevice.Viewport.Height - returnButton.Height / 2 - 1); exitButton = new BaseObject(new Rectangle(pongo.X + pongo.Width - EXITBUTTONWIDTH, Graphics.GraphicsDevice.Viewport.Height - EXITBUTTONHEIGHT - 1, EXITBUTTONWIDTH, EXITBUTTONHEIGHT), new Vector2(0, 0)); exitButton.CenterPoint = new Vector2(pongo.X + pongo.Width * .75f, Graphics.GraphicsDevice.Viewport.Height - exitButton.Height / 2 - 1); //int pongoRightX = pongo.X + pongo.Width; int pongoRightX = mrPeanut.X + mrPeanut.Width; mike = new BaseObject(new Rectangle(pongoRightX + (Graphics.GraphicsDevice.Viewport.Width - pongoRightX) / 2 - MIKEWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - MIKEHEIGHT / 2, MIKEWIDTH, MIKEHEIGHT)); mike.Texture = mikeTexture; congratsSize = bigFont.MeasureString("Congratulations!"); congratsX = (int)(Graphics.GraphicsDevice.Viewport.Width / 2 - congratsSize.X / 2); congratsY = (int)(pongo.Y / 2 - congratsSize.Y / 2); Bullet b = new Bullet(BulletType.Peanut, new Vector2(0, 0)); b.Width = b.Height = (int)(b.Width * 1.5f); b.CenterPoint = new Vector2(congratsX - b.Width, congratsY + congratsSize.Y / 2); b = new Bullet(BulletType.Peanut, new Vector2(0, 0)); b.Width = b.Height = (int)(b.Width * 1.5f); b.CenterPoint = new Vector2(congratsX + congratsSize.X + b.Width, congratsY + congratsSize.Y / 2); accuracyPercent = (int)Math.Round((Stats.PeanutHits / (float)Stats.PeanutShots) * 100); if (Stats.PeanutShots == 0) accuracyPercent = 0; if (accuracyPercent >= 50) accuracyMsg = "Your skills are second to none."; else if (accuracyPercent >= 25) accuracyMsg = "Don't stop believing"; else accuracyMsg = "Go hit a tree with a stick."; if (Stats.CarChasePeanutScore >= 100) peanutScoreMsg = "You are the chosen one"; else if (Stats.CarChasePeanutScore >= 90) peanutScoreMsg = "IMPECCABLE"; else if (Stats.CarChasePeanutScore >= 80) peanutScoreMsg = "Over 10-12 years of experience"; else if (Stats.CarChasePeanutScore >= 70) peanutScoreMsg = "Looks can always be deceiving"; else if (Stats.CarChasePeanutScore >= 60) peanutScoreMsg = "You've always been a fast learner"; else if (Stats.CarChasePeanutScore >= 50) peanutScoreMsg = "Competing with 3-4 people from your school"; else peanutScoreMsg = "r u dumb?"; MediaPlayer.Play(postGameMusic); MediaPlayer.Volume = .5f; MediaPlayer.IsRepeating = true; }
public Seeker(Vector2 position, int size, BaseObject target, float speed, float rotationSpeed) : this(position, size, 0, speed, rotationSpeed) { this.target = target; Rotation = (float)Math.Atan2(target.CenterPoint.Y - CenterPoint.Y, target.CenterPoint.X - CenterPoint.X); LastMove = new Vector2((float)Math.Cos(Rotation), (float)Math.Sin(Rotation)); }