public override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(graphicsDevice); weaponList = new SpriteList(20); playerXLocation = Dir.rnd.Next(0, 1000); playerYLocation = 880; enemyXLocation = -20; enemyYLocation = Dir.rnd.Next(213, 600); enemy2XLocation = Dir.rnd.Next(Dir.rightBoundary - 300, Dir.rightBoundary); anchorXLocation = Dir.rnd.Next(Dir.leftBoundary + 100, Dir.rightBoundary - 100); anchorYLocation = 175; texBackgroundLevel2 = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Sea04.png"); texPlayer = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\ship-md.png"); texEnemy1 = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant1.png"); texEnemy2 = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant2.png"); texMissile = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Torpedo5up.png"); texMissileSmoke = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Particle1.png"); texExplostionAnimation = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explodeWater1024x64.png"); texMineExplostion = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explode1.png"); texMouse = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Mouse.png"); texAnchor = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\anchor-th.png"); texLife = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\life-preserver-th.png"); texMine = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\water_mine.png"); scoreFont = Content.Load <SpriteFont>("display"); helpFont = Content.Load <SpriteFont>("helpText"); explostionSound = Content.Load <SoundEffect>("bazooka_fire"); exLimSound = new LimitSound(explostionSound, 3); backgroundLevel2 = new ImageBackground(texBackgroundLevel2, Color.White, graphicsDevice); player = new Sprite3(true, texPlayer, playerXLocation, playerYLocation); enemy1 = new Sprite3(true, texEnemy1, enemyXLocation, enemyYLocation); enemy2 = new Sprite3(true, texEnemy2, enemy2XLocation, enemyYLocation); explosionAnimation = new Sprite3(true, texExplostionAnimation, 0, playerYLocation); mineExplostionAnimation = new Sprite3(true, texMineExplostion, 0, playerYLocation); mine = new Sprite3(true, texMine, 0, 0); mine.setHSoffset(new Vector2(296, 313)); weaponList.addSpriteReuse(mine); life = new Sprite3(true, texLife, Dir.rnd.Next(Dir.leftBoundary + 200, Dir.rightBoundary - 200), Dir.rnd.Next(300, 600)); life.setActiveAndVisible(false); for (int i = 1; i < 3; i++) { anchor = new Sprite3(true, texAnchor, anchorXLocation, anchorYLocation); anchor.setWidthHeight(50, 50); weaponList.addSpriteReuse(anchor); } for (int m = 1; m < 6; m++) { missile = new Sprite3(true, texMissile, playerXLocation, playerYLocation); missile.setWidthHeight(missile.getWidth() / 2, missile.getHeight() / 2); weaponList.addSpriteReuse(missile); } player.setColor(Color.Red); // Adjusting sprite image sizes to suit my taste player.setWidthHeight(210, 64); enemy1.setWidthHeight(256, 64); enemy2.setWidthHeight(enemy1.getWidth() / 2, 64); life.setWidthHeight(48, 48); mine.setWidthHeight(40, 45); // animation for torpedo explosion explosionAnimation.setWidthHeightOfTex(1024, 64); explosionAnimation.setXframes(16); explosionAnimation.setYframes(1); explosionAnimation.setWidthHeight(80, 80); for (int moveX = 0; moveX <= 15; moveX++) { anim[moveX].X = moveX; anim[moveX].Y = 0; } explosionAnimation.setAnimationSequence(anim, 0, 15, 3); explosionAnimation.setAnimFinished(0); explosionAnimation.animationStart(); // animation for mine explostion mineExplostionAnimation.setWidthHeightOfTex(1024, 64); mineExplostionAnimation.setXframes(16); mineExplostionAnimation.setYframes(1); mineExplostionAnimation.setWidthHeight(80, 80); for (int moveX = 0; moveX <= 15; moveX++) { mineAnim[moveX].X = moveX; mineAnim[moveX].Y = 0; } mineExplostionAnimation.setAnimationSequence(mineAnim, 0, 15, 4); mineExplostionAnimation.setAnimFinished(0); mineExplostionAnimation.animationStart(); HealthBarAttached h1 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); h1.offset = new Vector2(0, -1); // one pixel above the bounding box h1.gapOfbar = 2; enemy1.hitPoints = 10; enemy1.maxHitPoints = 10; enemy1.attachedRenderable = h1; HealthBarAttached h2 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); h2.offset = new Vector2(0, -1); // one pixel above the bounding box h2.gapOfbar = 2; enemy2.hitPoints = 20; enemy2.maxHitPoints = 20; enemy2.attachedRenderable = h2; HealthBarAttached playerHP = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); playerHP.offset = new Vector2(0, -1); // one pixel above the bounding box playerHP.gapOfbar = 2; player.hitPoints = 50; player.maxHitPoints = 50; player.attachedRenderable = playerHP; drawSmoke(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); LineBatch.init(GraphicsDevice); // load all fonts for the splash screen and levels llFont = Content.Load <SpriteFont>("Large"); mmFont = Content.Load <SpriteFont>("Medium"); ssFont = Content.Load <SpriteFont>("Small"); // load textures from local content directory kcTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/kittyCat.png"; kittyCatTex = Util.texFromFile(GraphicsDevice, kcTexPath); bbTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/Background.png"; backgroundTex = Util.texFromFile(GraphicsDevice, bbTexPath); playerTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/KittyCatFrames.png"; playerTex = Util.texFromFile(GraphicsDevice, playerTexPath); doggyTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/CrazyDogFrames.png"; doggyTex = Util.texFromFile(GraphicsDevice, doggyTexPath); yarnTex = Content.Load <Texture2D>("Yarn"); // position vector for the cat sprite on main splash screen kittyCatVec = new Vector2(275, 50); titleVec = new Vector2(100, 300); sloganVec = new Vector2(290, 400); instructVec = new Vector2(315, 425); levelIntroVec = new Vector2(250, 200); playerVec = new Vector2(600, 400); doggyVec = new Vector2(0, 400); // make the cat sprite for the main splash screen kittyCat = new Sprite3(true, kittyCatTex, kittyCatVec.X, kittyCatVec.Y); // prepare the crazy dog for level 2 crazyDog = new Sprite3(false, doggyTex, doggyVec.X, doggyVec.Y); // color for the level text and alpha value ltCol = new Color(0, 255, 0, 1); // level text initialization levelText = new TextRenderable("Blabla", levelIntroVec, llFont, Color.Red); // source and destination rectangles for the scrolling background backgroundDest = new Rectangle(0, 0, 800, 600); backgroundSource = new Rectangle(0, 0, 800, 600); // draw background background = new ScrollBackGround(backgroundTex, backgroundDest, backgroundSource, 5.0f, 2); // player vector and player texture playerSprite = new Sprite3(true, playerTex, playerVec.X, playerVec.Y); // initialize frame vector playerFrames = new Vector2[10]; // frame vector values 1280x128 playerFrames[0].X = 0; playerFrames[0].Y = 0; playerFrames[1].X = 1; playerFrames[1].Y = 0; playerFrames[2].X = 2; playerFrames[2].Y = 0; playerFrames[3].X = 3; playerFrames[3].Y = 0; playerFrames[4].X = 4; playerFrames[4].Y = 0; playerFrames[5].X = 5; playerFrames[5].Y = 0; playerFrames[6].X = 6; playerFrames[6].Y = 0; playerFrames[7].X = 7; playerFrames[7].Y = 0; playerFrames[8].X = 8; playerFrames[8].Y = 0; playerFrames[9].X = 9; playerFrames[9].Y = 0; // set all the parameters for the cute little kitty cat playerSprite.setWidthHeight(64, 64); playerSprite.setWidthHeightOfTex(1280, 128); playerSprite.setXframes(10); playerSprite.setYframes(0); playerSprite.setBB(0, 0, 128, 128); playerSprite.setAnimationSequence(playerFrames, 0, 9, 15); playerSprite.animationStart(); // the parameters for the player sprite jumping playerJump = false; playerJumpSpeed = 0; // store the initial positions of the player sprite prevPos.Y = playerVec.Y; prevPos.X = playerVec.X; // initialize sounds for the game jumpo = Content.Load <SoundEffect>("Sounds/Boing"); jumpoSound = new LimitSound(jumpo, 1); success = Content.Load <SoundEffect>("Sounds/Success"); successSound = new LimitSound(success, 1); barko = Content.Load <SoundEffect>("Sounds/Growl"); barkoSound = new LimitSound(barko, 1); kaching = Content.Load <SoundEffect>("Sounds/Kaching"); kachingSound = new LimitSound(kaching, 1); yowlin = Content.Load <SoundEffect>("Sounds/Yowl"); yowlinSound = new LimitSound(yowlin, 1); easterEgg = Content.Load <SoundEffect>("Sounds/OhWhatever"); eeSound = new LimitSound(easterEgg, 1); /// yarn ball sprite list /// /// /// /// /// /// yarnBalls = new SpriteList(); Sprite3 yb; for (int i = 0; i < maxYarnBalls; i++) { // temporarily set to doggyVec for positioning - change later? yb = new Sprite3(true, yarnTex, doggyVec.X + i * 50, doggyVec.Y - i * 50); yb.setDeltaSpeed(new Vector2((float)(1 + rnd.NextDouble()), 0)); yb.setWidthHeight(32, 32); yb.setWidthHeightOfTex(32, 32); yb.setHSoffset(new Vector2(32, 32)); yb.setBBToTexture(); yb.setMoveSpeed(2.1f); yarnBalls.addSpriteReuse(yb); } // initialize frame vector for dog doggyFrames = new Vector2[8]; doggyFrames[0].X = 0; doggyFrames[0].Y = 0; doggyFrames[1].X = 1; doggyFrames[1].Y = 0; doggyFrames[2].X = 2; doggyFrames[2].Y = 0; doggyFrames[3].X = 3; doggyFrames[3].Y = 0; doggyFrames[4].X = 4; doggyFrames[4].Y = 0; doggyFrames[5].X = 5; doggyFrames[5].Y = 0; doggyFrames[6].X = 6; doggyFrames[6].Y = 0; doggyFrames[7].X = 7; doggyFrames[7].Y = 0; crazyDog.setWidthHeight(64, 64); crazyDog.setWidthHeightOfTex(1024, 128); crazyDog.setXframes(8); crazyDog.setYframes(0); crazyDog.setBB(0, 0, 128, 128); crazyDog.setAnimationSequence(playerFrames, 0, 7, 15); crazyDog.animationStart(); }
public override void LoadContent() { enemyList = new SpriteList(20); playerXLocation = Dir.rnd.Next(0, 1000); playerYLocation = 880; enemyXLocation = -20; enemyYLocation = Dir.rnd.Next(213, 600); enemy2XLocation = Dir.rnd.Next(Dir.rightBoundary - 300, Dir.rightBoundary); enemy3YLocation = enemyYLocation + Dir.rnd.Next(100, 200); // Image Locations Dir.texBackground = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Sea04.png"); texPlayer = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\ship-md.png"); texEnemy1 = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant1.png"); texEnemy2 = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Merchant2.png"); texMissile = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Torpedo5up.png"); texMissileSmoke = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Particle1.png"); texExplostionAnimation = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\explode1.png"); scoreFont = Content.Load <SpriteFont>("display"); helpFont = Content.Load <SpriteFont>("helpText"); explostionSound = Content.Load <SoundEffect>("bazooka_fire"); exLimSound = new LimitSound(explostionSound, 3); // Set Sprites Dir.background = new ImageBackground(Dir.texBackground, Color.White, graphicsDevice); player = new Sprite3(true, texPlayer, playerXLocation, playerYLocation); enemy1 = new Sprite3(true, texEnemy1, enemyXLocation, enemyYLocation); enemy2 = new Sprite3(true, texEnemy2, enemy2XLocation, enemyYLocation); enemy3 = new Sprite3(true, texEnemy1, enemyXLocation, enemy3YLocation); missile = new Sprite3(true, texMissile, playerXLocation, playerYLocation); explosionAnimation = new Sprite3(true, texExplostionAnimation, 0, playerYLocation); // Adjusting sprite image sizes to suit my taste player.setWidthHeight(210, 64); enemy1.setWidthHeight(256, 64); enemy2.setWidthHeight(enemy1.getWidth() / 2, 64); enemy3.setWidthHeight(256, 64); missile.setWidthHeight(missile.getWidth() / 2, missile.getHeight() / 2); HealthBarAttached h1 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); h1.offset = new Vector2(0, -1); // one pixel above the bounding box h1.gapOfbar = 2; enemy1.hitPoints = 10; enemy1.maxHitPoints = 10; enemy1.attachedRenderable = h1; HealthBarAttached h2 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); h2.offset = new Vector2(0, -1); // one pixel above the bounding box h2.gapOfbar = 2; enemy2.hitPoints = 20; enemy2.maxHitPoints = 20; enemy2.attachedRenderable = h2; HealthBarAttached h3 = new HealthBarAttached(Color.Aquamarine, Color.Green, Color.Red, 9, true); h3.offset = new Vector2(0, -1); // one pixel above the bounding box h3.gapOfbar = 2; enemy3.hitPoints = 10; enemy3.maxHitPoints = 10; enemy3.attachedRenderable = h3; // Add to sprite list enemyList.addSpriteReuse(enemy1); enemyList.addSpriteReuse(enemy2); enemyList.addSpriteReuse(enemy3); explosionAnimation.setWidthHeightOfTex(1024, 64); explosionAnimation.setXframes(16); explosionAnimation.setYframes(1); explosionAnimation.setWidthHeight(90, 90); for (int moveX = 0; moveX <= 15; moveX++) { anim[moveX].X = moveX; anim[moveX].Y = 0; } explosionAnimation.setAnimationSequence(anim, 0, 15, 4); explosionAnimation.setAnimFinished(0); explosionAnimation.animationStart(); drawSmoke(); }