/// <summary> /// Checks if the given gameObject collide with the given gameObject /// </summary> /// <returns></returns> private bool checkCollision(GameObject gameObject1, GameObject gameObject2) { Rectangle objectBounds = gameObject1.getBounds(); Rectangle otherBounds = gameObject2.getBounds(); if (otherBounds.Intersects(objectBounds)) { return true; } return false; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //load sprite font in hudFont = Content.Load<SpriteFont>("SpriteFont/HUDFont"); statFont = Content.Load<SpriteFont>("SpriteFont/StatFont"); // Main Menu titlescreen = Content.Load<Texture2D>("Textures/titlescreen"); howtoplaybutton = new Button(Content, howtoplaybuttonPos, "Textures/Buttons/StartMenu/howtoplaybutton", howToPlay); startgamebutton = new Button(Content, startgamebuttonPos, "Textures/Buttons/StartMenu/startgamebutton", startGame); exitbutton = new Button(Content, exitbuttonPos, "Textures/Buttons/StartMenu/exitbutton", exitGame); // Fail screen failscreen = Content.Load<Texture2D>("Textures/gameoverscreen"); backtomenubutton = new Button(Content, failbacktomenuPos, "Textures/Buttons/StartMenu/exitbutton", backToMainMenu); tryagainbutton = new Button(Content, tryagainPos, "Textures/tryagainbutton", startGame); // Pause screen //pausescreen = Content.Load<Texture2D>("Textures/pausescreen"); //resumebutton = new Button(Content, resumebuttonPos, "Textures/Buttons/PauseMenu/resumebutton", resumeGame); // Debriefing screen debriefingscreen = Content.Load<Texture2D>("Textures/debriefingscreen"); shopbutton = new Button(Content, shopbuttonPos, "Textures/Buttons/DebriefingMenu/shopbutton", showShop); nextwavebutton = new Button(Content, nextwavebuttonPos, "Textures/Buttons/DebriefingMenu/nextbutton", nextWave); // Shop Screen shopscreen = Content.Load<Texture2D>("Textures/shopscreen"); okbutton = new Button(Content, okbuttonPos, "Textures/Buttons/ShopMenu/okaybutton", exitShop); fastballbutton = new Button(Content, fastballbuttonPos, "Textures/Buttons/ShopMenu/fastballpowerup", fastballpu); ballsofsteelbutton = new Button(Content, ballsofsteelbuttonPos, "Textures/Buttons/ShopMenu/ballsofsteelpowerup", ballsofsteelpu); biggerbinsbutton = new Button(Content, biggerbinsbuttonPos, "Textures/Buttons/ShopMenu/biggerbinspowerup", biggerbinpu); umpirepatiencebutton = new Button(Content, umpirepatiencebuttonPos, "Textures/Buttons/ShopMenu/umpirepatiencepowerup", umppatientpu); //confirm purchase screen confirmscreen = Content.Load<Texture2D>("Textures/confirmationscreen"); upgradebutton = new Button(Content, upgradebuttonPos, "Textures/Buttons/ShopMenu/upgradebutton", confirmUpgrade); greyupgradebutton = new Button(Content, upgradebuttonPos, "Textures/Buttons/ShopMenu/upgradedonebutton", confirmUpgrade); cancelbutton = new Button(Content, cancelbuttonPos, "Textures/Buttons/ShopMenu/cancelbutton", cancelUpgrade); // In Game backgroundscreen = Content.Load<Texture2D>("Textures/backgroundscreen"); // How To Screen howtoscreen = Content.Load<Texture2D>("Textures/howtoscreen"); letsplaybutton = new Button(Content, letsplaybuttonPos, "Textures/Buttons/HowToPlayMenu/letsplaybutton", startGame); // Game Objects Baseball.baseballTexture = Content.Load<Texture2D>("Textures/baseball"); Vuvuzela.vuvuzelaTexture = Content.Load<Texture2D>("Textures/vuvuzela"); Bat.batTexture = Content.Load<Texture2D>("Textures/baseballbat"); Popcorn.popcornTexture = Content.Load<Texture2D>("Textures/popcorn"); Popcan.popcanTexture = Content.Load<Texture2D>("Textures/popcan"); Hotdog.hotdogTexture = Content.Load<Texture2D>("Textures/hotdog"); Umpire.umpireTexture = Content.Load<Texture2D>("Textures/umpire"); Trashbin.trashbinTexture = Content.Load<Texture2D>("Textures/trashcan"); Foulpole.foulpoleTexture = Content.Load<Texture2D>("Textures/foulpoles"); UmpireHitEffect.hitSprite = this.Content.Load<Texture2D>("Textures/hitstar"); CashRewardEffect.hitSprite = this.Content.Load<Texture2D>("Textures/dollarsign"); //Stuff for drawing the ball slinging this.ballStartTexture = this.Content.Load<Texture2D>("Textures/ballStartSprite"); this.ballStretchTexture = this.Content.Load<Texture2D>("Textures/lineSegmentTexture"); // this.leftThumbStartObject = new GameObject(this.ballStartTexture); this.leftThumbStartObject.scaleToFitTheseDimensions(this.ballStartImageRadius * 2.0f, this.ballStartImageRadius * 2.0f); this.leftThumbStretchLine = new GameObject(this.ballStretchTexture); this.leftThumbStretchLine.scaleToFitTheseDimensions(10.0f, this.ballStretchLineWidth); this.leftSuspendedBaseBall = new GameObject(Baseball.baseballTexture); this.leftSuspendedBaseBall.scaleToFitTheseDimensions(120.0f, 120.0f); this.rightThumbStartObject = new GameObject(this.ballStartTexture); this.rightThumbStartObject.scaleToFitTheseDimensions(this.ballStartImageRadius * 2.0f, this.ballStartImageRadius * 2.0f); this.rightThumbStretchLine = new GameObject(this.ballStretchTexture); this.rightThumbStretchLine.scaleToFitTheseDimensions(10.0f, this.ballStretchLineWidth); this.rightSuspendedBaseBall = new GameObject(Baseball.baseballTexture); this.rightSuspendedBaseBall.scaleToFitTheseDimensions(120.0f, 120.0f); soundManager.initializeSound(); }