void generateAliens() { if (numOfTargets >= numOfTargetsMax) { mgState = 3; return; } ; if (rnd.Next(0, 1000) < genAliensPercent * 10 && numOfTargets < numOfTargetsMax) { numOfTargets++; float xx = rnd.Next(innerRectangle.X, (int)(innerRectangle.X + innerRectangle.Width - actualTargetSize.X)); float yy = innerRectangle.Y - actualTargetSize.Y / 2; Sprite3 s = new Sprite3(true, targetTex, xx, yy); s.setWidthHeight(actualTargetSize.X, actualTargetSize.Y); s.setBBToTexture(); //s.setWidthHeightOfTex(1536, 384); //s.setXframes(16); //s.setYframes(4); s.setDeltaSpeed(new Vector2(0, 1)); //s.setBB(10, 10, 48 - 20, 48 - 20); //int frames = 12; //Vector2[] anim = new Vector2[frames]; //for (int i = 0; i < frames; i++) //{ // anim[i].X = i; anim[i].Y = 0; //} //s.setAnimationSequence(anim, 0, frames - 1, 3); //s.animationStart(); targets.addSpriteReuse(s); AI_xxx = s.getPosX() + s.getWidth() / 2; } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here //base initialize calls loadcontent base.Initialize(); random = new Random(); playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); spritePlayer = new Sprite3(true, playerTex, 50, SCREEN_HEIGHT / 2 - 50); spritePlayer.setWidthHeight(100, 100); spritePlayer.setFlip(SpriteEffects.FlipHorizontally); //spritePlayer.setBB(0,0,200, 200); scrollBack = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -1 + playerSpeeeeeed, 2); scrollFore = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -2 + playerSpeeeeeed, 2); textScore = new TextRenderable("Score : " + score.ToString(), new Vector2(100, 100), spriteFont, Color.Red); textStartGame = new TextRenderable("PRESS ENTER TO START", new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2), spriteFont, Color.Red); particleList = new SpriteList(); enemyList = new SpriteList(); playerBulletList = new SpriteList(); }
/// <summary> /// Returns the index of the first (ie lowest numbered) /// sprite it colides with -1 if no collision /// the self parameter is there to allow the avoidance of collision texting against yourself /// </summary> /// <param name="s">the sprite to test the list against</param> /// <param name="self">the number of a single sprite to avoid testing</param> /// <returns></returns> public int collisionAA(Sprite3 s, int self) { if (s == null) { return(-1); } if (!s.getVisible()) { return(-1); } if (!s.getActive()) { return(-1); } for (int i = 0; i < highUsed + 1; i++) { if (sprite[i] != null && sprite[i].active) { if (sprite[i].getVisible() && i != self && s.collision(sprite[i])) { return(i); } } } return(-1); }
void checkIfIAmShot() { Rectangle r = shooter.getBoundingBoxAA(); int temp = targets.collisionWithRect(r); if (temp == -1) { return; } Sprite3 s = targets.getSprite(temp); makeExplosion(shooter.getPos()); makeExplosion(s.getPos()); adjustScore(scoreIfPlayerHit, s.getPosX(), s.getPosY()); s.active = false; s.visible = false; //shooter.visible = false; lives = lives - 1; mgState = 2; timeIn2 = 0; if (lives <= 0) { mgState = 4; } }
/// <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); LineBatch.init(GraphicsDevice); // TODO: use this.Content to load your game content here texBack = Util.texFromFile(GraphicsDevice, dir + "ricefield.png"); texpaddle = Util.texFromFile(GraphicsDevice, dir + "slime.png"); texBall = Util.texFromFile(GraphicsDevice, dir + "slime_slice.png"); //*** texEnemy = Util.texFromFile(GraphicsDevice, dir + "ghost.png"); texGrass1 = Util.texFromFile(GraphicsDevice, dir + "grass1.png"); texBoom = Util.texFromFile(GraphicsDevice, dir + "Boom3.png"); font = Content.Load <SpriteFont>("incoming"); paddle = new Sprite3(true, texpaddle, lhs, yy); paddle.setBBToTexture(); enemyList = new SpriteList(); ballList = new SpriteList(); booms = new SpriteList(); back1 = new ScrollBackGround(texBack, texBack.Bounds, new Rectangle(0, 0, rhs, 380), -1, 2); grass1 = new ScrollBackGround(texGrass1, texGrass1.Bounds, new Rectangle(0, bot - (texGrass1.Height + 30), rhs, bot / 2), -1, 2); playArea = new Rectangle(lhs, top, rhs, bot - 10); enemyYY = new Random(); enemySpeed = new Random(); }
public override void LoadContent() { scrolling1 = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(0, 0, 800, 600)); scrolling2 = new Scrolling(Content.Load <Texture2D>("skyMenu"), new Rectangle(800, 0, 800, 600)); texBack = texFromFile(graphicsDevice, dir + "menu1.png"); texBall = texFromFile(graphicsDevice, dir + "ballMenu.png"); back1 = new ImageBackground(texBack, Color.White, graphicsDevice); texBack1 = texFromFile(graphicsDevice, dir + "help.png"); back2 = new ImageBackground(texBack1, Color.White, graphicsDevice); anmiationList = new SpriteList(); for (int y = 0; y < 2; y++) { anmiation1 = new Sprite3(true, texBall, 190, 265 + b); anmiation1.setXframes(3); anmiation1.setYframes(1); anmiation1.setWidthHeight(32, 32); Vector2[] seq = new Vector2[3]; seq[0].X = 1; seq[0].Y = 0; seq[1].X = 2; seq[1].Y = 0; seq[2].X = 0; seq[2].Y = 0; anmiation1.setAnimationSequence(seq, 0, 2, 15); anmiation1.animationStart(); anmiationList.addSpriteReuse(anmiation1); b = b + 56; } }
public override void LoadContent() { // Load Textures continueTex = Content.Load <Texture2D>("Textures/Menu/Continue"); optionsTex = Content.Load <Texture2D>("Textures/Menu/Options"); howToPlayTex = Content.Load <Texture2D>("Textures/Menu/HowToPlay"); exitTex = Content.Load <Texture2D>("Textures/Menu/Exit"); titleTex = Content.Load <Texture2D>("Textures/Menu/Title"); triangleTex = Content.Load <Texture2D>("Textures/Menu/TriangleMan"); newgameTex = Content.Load <Texture2D>("Textures/Menu/NewGame"); hexagonTex = Content.Load <Texture2D>("Textures/Menu/HexagonGuy"); // Create sprites for title and display characters sTitle = new Sprite3(true, titleTex, 0, 0); sTriangle = new Sprite3(true, triangleTex, 0, 0); // Set sprite offsets sTitle.setHSoffset(new Vector2(titleTex.Width / 2, titleTex.Height / 2)); sTriangle.setHSoffset(new Vector2(triangleTex.Width / 2, triangleTex.Height / 2)); // Set Position of Sprites sTitle.setPos(new Vector2(xAligned, 0 + sTitle.getHeight())); sTriangle.setPos(675, 275); buttonNewGame = new Button(newgameTex, new Vector2(xAligned, (95 + sTitle.getPosY()) + (newgameTex.Height)), Resources.ColorHighLight, Button.ButtonType.ResetGame, 0); buttonContinue = new Button(continueTex, new Vector2(xAligned, buttonNewGame.getPosY() + (minorOffset + continueTex.Height)), Resources.ColorHighLight, Button.ButtonType.ChangeLevelSet, Resources.currPlayLevel); buttonOptions = new Button(optionsTex, new Vector2(xAligned, buttonContinue.getPosY() + (minorOffset + optionsTex.Height)), Resources.ColorHighLight, Button.ButtonType.ChangeLevelSet, 5); buttonHowToPlay = new Button(howToPlayTex, new Vector2(xAligned, buttonOptions.getPosY() + (minorOffset + howToPlayTex.Height)), Resources.ColorHighLight, Button.ButtonType.ChangeLevelPush, 8); buttonExit = new Button(exitTex, new Vector2(xAligned, buttonHowToPlay.getPosY() + (minorOffset + exitTex.Height)), Resources.ColorHighLight, Button.ButtonType.Exit, 0); buttonHighScore = new Button(hexagonTex, new Vector2(135, 339), Resources.ColorLose, Button.ButtonType.ChangeLevelSet, 13); }
/// <summary> /// Make a boom sprite if boomn size == 0 then default size is used /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="boomKind"></param> /// <param name="boomSize"></param> /// <returns></returns> public Sprite3 makeBoom(int x, int y, int boomKind, float boomSize) { //Texture2DSequence fs = new Texture2DSequence(boomSpriteSheets[boomKind]); //fs.setAnimationSequence(frameSeqs[boomKind].firstFrame,frameSeqs[boomKind].lastFrame,frameSeqs[boomKind].ticksBetweenFrames); Sprite3 boom = new Sprite3(true, boomImages[boomKind], x, y); GCG_SpriteSheet ss = boomSpriteSheets[boomKind]; boom.setXframes(ss.getXframes()); boom.setYframes(ss.getYframes()); int q = ss.getXframes() * ss.getYframes(); Vector2[] animSeq = new Vector2[q]; int ctr = 0; for (int yy = 0; yy < ss.getYframes(); yy++) { for (int xx = 0; xx < ss.getXframes(); xx++) { animSeq[ctr].X = xx; animSeq[ctr].Y = yy; ctr++; } } boom.setAnimationSequence(animSeq, 0, q - 1, 4); //boom.setFrameSource(boomSpriteSheets[boomKind], true); if (boomSize > 0) { boom.setWidthHeight(boomSize, boomSize); } boom.animationStart(); //boom.animInfo = fs; boom.setAnimFinished(2); return(boom); }
public override void LoadContent() { minusTex = Content.Load <Texture2D>("Textures/Options/Minus"); plusTex = Content.Load <Texture2D>("Textures/Options/Plus"); medTex = Content.Load <Texture2D>("Textures/Options/Med"); lowTex = Content.Load <Texture2D>("Textures/Options/Low"); mediumTex = Content.Load <Texture2D>("Textures/Options/Medium"); highTex = Content.Load <Texture2D>("Textures/Options/High"); triangleTex = Content.Load <Texture2D>("Textures/Menu/TriangleMan"); buttonMinus = new Button(minusTex, new Vector2(-35 + minusTex.Width, 215 + minusTex.Height), Resources.ColorHighLight, Button.ButtonType.VolumeControl, 0); buttonPlus = new Button(plusTex, new Vector2(xOffset + buttonMinus.getPosX() + minusTex.Width, buttonMinus.getPosY()), Resources.ColorHighLight, Button.ButtonType.VolumeControl, 1); buttonMed = new Button(medTex, new Vector2(xOffset + buttonPlus.getPosX() + minusTex.Width, buttonMinus.getPosY()), Resources.ColorHighLight, Button.ButtonType.VolumeControl, 2); buttonLow = new Button(lowTex, new Vector2(-35 + lowTex.Width, 375 + lowTex.Height), Resources.ColorHighLight, Button.ButtonType.GraphicsControl, 0); buttonMedium = new Button(mediumTex, new Vector2(xOffset + buttonLow.getPosX() + lowTex.Width, 375 + lowTex.Height), Resources.ColorHighLight, Button.ButtonType.GraphicsControl, 1); buttonHigh = new Button(highTex, new Vector2(xOffset + buttonMedium.getPosX() + lowTex.Width, 375 + lowTex.Height), Resources.ColorHighLight, Button.ButtonType.GraphicsControl, 2); sTriangle = new Sprite3(true, triangleTex, 0, 0); sTriangle.setHSoffset(new Vector2(triangleTex.Width / 2, triangleTex.Height / 2)); sTriangle.setPos(new Vector2(675, 305)); title = "Options:"; subtitle = "Adjust to Your Hearts Content"; instructions = "Press Any Key to Return to Main Menu"; displayGraphicsQuality(); }
/// <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); LineBatch.init(GraphicsDevice); texBack = Util.texFromFile(GraphicsDevice, dir + "back3.png"); //*** texpaddle = Util.texFromFile(GraphicsDevice, dir + "red64x32.png"); //*** texBall = Util.texFromFile(GraphicsDevice, dir + "ball2.png"); //*** texBlock1 = Util.texFromFile(GraphicsDevice, dir + "white64x32.png"); paddle = new Sprite3(true, texpaddle, xx, yy); paddle.setBBToTexture(); ball = new Sprite3(true, texBall, xx, yy); ball.setBBandHSFractionOfTexCentered(0.7f); sl = new SpriteList(); back1 = new ImageBackground(texBack, Color.White, GraphicsDevice); playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); // width and height for (int y = 0; y < 5; y++) { for (int x = 0; x < 4; x++) { Sprite3 s = new Sprite3(true, texBlock1, x * 68 + playArea.X + blocksOffsetX, y * 36 + playArea.Y + blocksOffsetY); s.hitPoints = 1; if (y == 0) { s.hitPoints = 2; s.setColor(Color.LightBlue); } sl.addSpriteReuse(s); } } // TODO: use this.Content to load your game content here }
//Creates blood splatter animation when player or enemy gets hit public void Blood(float x, float y, bool isHorse) { Sprite3 blood = new Sprite3(true, texBlood, x - 10, y - 20); blood.setYframes(6); if (isHorse) { blood.setWidthHeight(texBlood.Width * 0.2f, texBlood.Height / 6 * 0.2f); } else { blood.setWidthHeight(texBlood.Width * 0.1f, texBlood.Height / 6 * 0.1f); } Vector2[] animBlood = new Vector2[6]; for (int h = 0; h < animBlood.Length; h++) { animBlood[h].Y = h; } blood.setAnimationSequence(animBlood, 0, 5, 5); blood.setAnimFinished(2); blood.animationStart(); bloodSplat.addSpriteReuse(blood); }
public override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(graphicsDevice); // put a font to tell play to press space to start //Dir.texBackground = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Press_Space.png"); float xLocation = Dir.rightBoundary / 2; texpressStart = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Press_Space.png"); texStartSub = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\navio-hi.png"); titleFont = Content.Load <SpriteFont>("display"); texTitle = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\title.png"); introSound = Content.Load <SoundEffect>("intro_theme"); intro = introSound.CreateInstance(); pressStart = new Sprite3(true, texpressStart, xLocation - 302, Dir.topBoundary + 400); startSub = new Sprite3(true, texStartSub, movingXLocation, Dir.bottomBoundary / 2); title = new Sprite3(true, texTitle, xLocation - 300, 50); pressStart.setWidthHeight(pressStart.getWidth() * 2, pressStart.getHeight() * 2); title.setWidthHeight((title.getWidth() * 3) / 2, (title.getHeight() * 3) / 2); startSub.setWidthHeight(startSub.getWidth() / 2, startSub.getWidth() / 2); pressStart.setColor(Color.Aqua); startSub.setColor(Color.GreenYellow); }
public override void LoadContent() { transparency = new ColorField(new Color(Color.Black, 0.5f), new Rectangle(0, 0, (int)Game1.screenSize.X, (int)Game1.screenSize.Y)); displayTex = Content.Load <Texture2D>("Textures/Menu/HowToPlayScreen"); display = new Sprite3(true, displayTex, 0, 0); display.setHSoffset(new Vector2(displayTex.Width / 2, displayTex.Height / 2)); display.setPos(Game1.screenSize / 2); }
public override void LoadLevel() { base.LoadLevel(); Sprite3 newPlatform; //DASH LEVEL OutOfBounds = new Rectangle(-100, 0, 7000, 1000); ////debug //newPlatform = new Sprite3(true, texPixel, 0, 700); //newPlatform.setWidthHeight(7000, 30); //platformList.addSpriteReuse(newPlatform); //start platform newPlatform = new Sprite3(true, texPixel, 200, 600); newPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(newPlatform); PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100); newPlatform = new Sprite3(true, texPixel, 3000, 600); newPlatform.setWidthHeight(300, 30); platformList.addSpriteReuse(newPlatform); //make goal on last platform goal = new GoalZone(newPlatform); if (!isChallengeMode) { targetSpawnPositions.Add(new Vector2(512, 429)); targetSpawnPositions.Add(new Vector2(833, 422)); targetSpawnPositions.Add(new Vector2(1119, 424)); //targetSpawnPositions.Add(new Vector2(1430, 422)); targetSpawnPositions.Add(new Vector2(1745, 422)); //targetSpawnPositions.Add(new Vector2(2065, 422)); targetSpawnPositions.Add(new Vector2(2378, 422)); //targetSpawnPositions.Add(new Vector2(2725, 422)); } else { //ceiling newPlatform = new Sprite3(true, texPixel, 0, 400); newPlatform.setWidthHeight(7000, 30); platformList.addSpriteReuse(newPlatform); targetSpawnPositions.Add(new Vector2(512, 429)); targetSpawnPositions.Add(new Vector2(833, 422)); targetSpawnPositions.Add(new Vector2(1119, 424)); targetSpawnPositions.Add(new Vector2(1430, 422)); targetSpawnPositions.Add(new Vector2(1745, 422)); targetSpawnPositions.Add(new Vector2(2065, 422)); targetSpawnPositions.Add(new Vector2(2378, 422)); targetSpawnPositions.Add(new Vector2(2725, 422)); targetSpawnPositions.Add(new Vector2(2992, 422)); } }
// Basic Sprite Constructor public SpriteActor(Texture2D tex, Vector2 position, Vector2 velocity) { spriteSize = new Vector2(tex.Width, tex.Height); this.position = position; this.velocity = velocity; sprite = new Sprite3(true, tex, position.X - tex.Width, position.Y - tex.Height); sprite.setHSoffset(new Vector2(spriteSize.X / 2, spriteSize.Y / 2)); sprite.setBBToTexture(); }
public override void Update(GameTime gameTime) { anmiationList.animationTick(); prevKeyState = keyState; keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Space) && !prevKeyState.IsKeyDown(Keys.Space)) { gameStateManager.setLevel(1); } if (keyState.IsKeyDown(Keys.H) && !prevKeyState.IsKeyDown(Keys.H)) { back1 = new ImageBackground(texBack1, Color.White, graphicsDevice); for (int i = 0; i < anmiationList.count(); i++) { Sprite3 s = anmiationList.getSprite(i); if (s == null) { continue; } if (!s.active) { continue; } if (!s.visible) { continue; } s.setActive(false); } } if (keyState.IsKeyDown(Keys.M) && !prevKeyState.IsKeyDown(Keys.M)) { back1 = new ImageBackground(texBack, Color.White, graphicsDevice); for (int i = 0; i < anmiationList.count(); i++) { Sprite3 s = anmiationList.getSprite(i); if (s == null) { continue; } // if (!s.active) continue; // if (!s.visible) continue; s.setActive(true); } } if (scrolling1.rectangle.X + scrolling1.texture.Width <= 0) { scrolling1.rectangle.X = scrolling2.rectangle.X + scrolling2.texture.Width; } if (scrolling2.rectangle.X + scrolling2.texture.Width <= 0) { scrolling2.rectangle.X = scrolling1.rectangle.X + scrolling1.texture.Width; } scrolling1.Update(); scrolling2.Update(); }
/// <summary> /// Returns the first (ie lowest numbered) Sprite collided with /// or null for no collision /// </summary> /// <param name="s"></param> /// <returns>null or collision sprite </returns> public Sprite3 collisionAASprite(Sprite3 s) { int i = collisionAA(s, -1); if (i == -1) { return(null); } return(getSprite(i)); }
/// <summary> /// Create a basic button /// </summary> /// <param name="tex">Button texture</param> /// <param name="pos">Position</param> /// <param name="highLight">Highlighted colour</param> /// <param name="buttonType">Button type</param> /// <param name="nextLevel">nextlevel/value if applicable</param> public Button(Texture2D tex, Vector2 pos, Color highLight, ButtonType buttonType, int nextLevel) { // Initialise our Button this.highLight = highLight; this.nextLevel = nextLevel; type = buttonType; button = new Sprite3(true, tex, 0, 0); button.setHSoffset(new Vector2(button.getWidth() / 2, button.getHeight() / 2)); button.setPos(pos); }
public void NewBall(float x, float y) { Sprite3 ball = new Sprite3(true, texBall, x, y); ball.setBBandHSFractionOfTexCentered(0.4f); ball.setPos(paddle.getPos() + ballOffset); ball.setDeltaSpeed(new Vector2(7, 0)); ballList.addSpriteReuse(ball); }
public override void LoadLevel() { base.LoadLevel(); Sprite3 newPlatform; //PIT LEVEL. OutOfBounds = new Rectangle(-100, 0, Game1.SCREEN_WIDTH + 100, 1000); //ceiling newPlatform = new Sprite3(true, texPixel, 0, 0); newPlatform.setWidthHeight(2000, 30); platformList.addSpriteReuse(newPlatform); //start platform newPlatform = new Sprite3(true, texPixel, PlayerSpawnPosition.X - player.getWidth(), PlayerSpawnPosition.Y + 100); newPlatform.setWidthHeight(150, 30); platformList.addSpriteReuse(newPlatform); //wall blocking way newPlatform = new Sprite3(true, texPixel, 500, 0); newPlatform.setWidthHeight(30, 500); platformList.addSpriteReuse(newPlatform); //goalplatform newPlatform = new Sprite3(true, texPixel, 700, PlayerSpawnPosition.Y + 100); newPlatform.setWidthHeight(150, 30); platformList.addSpriteReuse(newPlatform); if (!isChallengeMode) { //EASY PIT LEVEL targetSpawnPositions.Add(new Vector2(368, 175)); targetSpawnPositions.Add(new Vector2(360, 316)); targetSpawnPositions.Add(new Vector2(346, 448)); targetSpawnPositions.Add(new Vector2(337, 594)); targetSpawnPositions.Add(new Vector2(468, 592)); targetSpawnPositions.Add(new Vector2(592, 590)); targetSpawnPositions.Add(new Vector2(587, 479)); targetSpawnPositions.Add(new Vector2(580, 358)); targetSpawnPositions.Add(new Vector2(583, 243)); targetSpawnPositions.Add(new Vector2(590, 149)); } else { //TAEWOOKS LEVEL targetSpawnPositions.Add(new Vector2(736, 459)); targetSpawnPositions.Add(new Vector2(1039, 574)); targetSpawnPositions.Add(new Vector2(910, 389)); targetSpawnPositions.Add(new Vector2(83, 711)); targetSpawnPositions.Add(new Vector2(509, 599)); targetSpawnPositions.Add(new Vector2(577, 298)); targetSpawnPositions.Add(new Vector2(577, 180)); } //make goal on platform // goal = new GoalZone(new Vector2(700, PlayerSpawnPosition.Y), 100, 100); goal = new GoalZone(newPlatform); }
public override void LoadLevel() { Sprite3 newPlatform; base.LoadLevel(); OutOfBounds = new Rectangle(-100, 0, 7000, 1000); //TUTORIAL START newPlatform = new Sprite3(true, texPixel, 0, 700); newPlatform.setWidthHeight(800, 30); platformList.addSpriteReuse(newPlatform); //pit between these two newPlatform = new Sprite3(true, texPixel, 1700, 700); newPlatform.setWidthHeight(2000, 30); platformList.addSpriteReuse(newPlatform); //the double jump test. player has to hold A on one or both of the jumps to pass. newPlatform = new Sprite3(true, texPixel, 500, 500); newPlatform.setWidthHeight(30, 200); platformList.addSpriteReuse(newPlatform); //tutorial target targetSpawnPositions.Add(new Vector2(2051, 507)); //High wall newPlatform = new Sprite3(true, texPixel, 2551, 300); newPlatform.setWidthHeight(30, 400); platformList.addSpriteReuse(newPlatform); //targets to make the high wall targetSpawnPositions.Add(new Vector2(2432, 587)); targetSpawnPositions.Add(new Vector2(2427, 493)); targetSpawnPositions.Add(new Vector2(2427, 389)); targetSpawnPositions.Add(new Vector2(2430, 300)); targetSpawnPositions.Add(new Vector2(2436, 196)); //----------- newPlatform = new Sprite3(true, texPixel, 3000, 700); newPlatform.setWidthHeight(800, 30); platformList.addSpriteReuse(newPlatform); //bigger target pit newPlatform = new Sprite3(true, texPixel, 4850, 700); newPlatform.setWidthHeight(3000, 30); platformList.addSpriteReuse(newPlatform); //tutorial target. respawn? targetSpawnPositions.Add(new Vector2(4274, 463)); //checkpoint targetSpawnPositions.Add(new Vector2(3527, 627)); //goalPlatform Sprite3 goalPlatform = new Sprite3(true, texPixel, 5150, 700); goalPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(goalPlatform); goal = new GoalZone(goalPlatform); //Wall behind goal newPlatform = new Sprite3(true, texPixel, 5350, -10); newPlatform.setWidthHeight(800, 900); platformList.addSpriteReuse(newPlatform); }
/// <summary> /// Replace or set a specifically numbered sprite /// </summary> /// <param name="i"></param> /// <param name="spriteZ"></param> public void setSprite(int i, Sprite3 spriteZ) { sprite[i] = spriteZ; if (spriteZ == null && i < lowFree) { lowFree = i; } if (spriteZ != null && i > highUsed) { highUsed = i; } }
public void NewEnemy(float x, float y) { Sprite3 enemy = new Sprite3(true, texEnemy, x, (float)enemyYY.NextDouble() * y); enemy.setWidth(texEnemy.Width * 0.7f); enemy.setHeight(texEnemy.Height * 0.7f); enemy.setBBToTexture(); enemy.hitPoints = 3; enemy.setDeltaSpeed(new Vector2((float)enemySpeed.NextDouble() * -10, 0)); enemyList.addSpriteReuse(enemy); }
public override void LoadContent() { pauseHelpText = Content.Load <SpriteFont>("helpText"); texPauseScreen = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause.jpg"); // texBack = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause.jpg"); // texPause = Util.texFromFile(graphicsDevice, Dir.dir + @"Art\Pause2.jpg"); // pauseBackground = new ImageBackground(texBack, Color.White, graphicsDevice); pause = new Sprite3(true, texPause, 444, 30); pause.setWidthHeight(pause.getWidth() / 2, pause.getHeight() / 2); pause.setColor(Color.Aquamarine); }
//Adds bullet to bullet list based on parameters public void AddBullet(int x, int y) { int xOffset = (int)spritePlayer.getWidth(); int yOffset = (int)spritePlayer.getHeight() / 2; //int bulletSpeed = 100; Sprite3 bullet = new Sprite3(true, bulletTex, x + xOffset, y + yOffset); bullet.setWidthHeight(10, 10); playerBulletList.addSpriteReuse(bullet); }
public void Follow(Sprite3 target) { var position = Matrix.CreateTranslation( -target.getPosX() - (target.getWidth() / 2), -target.getPosY() - (target.getHeight() / 2), 0); var offset = Matrix.CreateTranslation( Game1.screenWidth / 2, Game1.screenHeight / 2, 0); Transform = position * offset; }
/// <summary> /// Add a sprite and return then number we added it at and allow inactive sprites to be oever written /// return -1 if not possible /// </summary> /// <param name="spriteZ"></param> /// <returns></returns> public int addSpriteReuse(Sprite3 spriteZ) { int i = findFreeSpriteOrInactive(); if (i != -1) { setSprite(i, spriteZ); if (i > highUsed) { highUsed = i; } return(i); } return(-1); }
public override void LoadLevel() { base.LoadLevel(); Sprite3 newPlatform; //PIT LEVEL. OutOfBounds = new Rectangle(-100, 0, Game1.SCREEN_WIDTH + 100, 1000); newPlatform = new Sprite3(true, texPixel, 200, 600); newPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(newPlatform); PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100); targetSpawnPositions.Add(new Vector2(135, 79)); targetSpawnPositions.Add(new Vector2(411, 53)); targetSpawnPositions.Add(new Vector2(295, 295)); targetSpawnPositions.Add(new Vector2(270, 145)); targetSpawnPositions.Add(new Vector2(515, 376)); targetSpawnPositions.Add(new Vector2(484, 213)); targetSpawnPositions.Add(new Vector2(123, 461)); targetSpawnPositions.Add(new Vector2(164, 246)); targetSpawnPositions.Add(new Vector2(400, 502)); targetSpawnPositions.Add(new Vector2(399, 368)); targetSpawnPositions.Add(new Vector2(701, 511)); targetSpawnPositions.Add(new Vector2(562, 461)); targetSpawnPositions.Add(new Vector2(642, 261)); targetSpawnPositions.Add(new Vector2(907, 494)); targetSpawnPositions.Add(new Vector2(730, 381)); targetSpawnPositions.Add(new Vector2(628, 93)); targetSpawnPositions.Add(new Vector2(839, 52)); targetSpawnPositions.Add(new Vector2(945, 378)); targetSpawnPositions.Add(new Vector2(819, 201)); targetSpawnPositions.Add(new Vector2(847, 410)); targetSpawnPositions.Add(new Vector2(976, 200)); targetSpawnPositions.Add(new Vector2(1082, 499)); targetSpawnPositions.Add(new Vector2(1077, 293)); newPlatform = new Sprite3(true, texPixel, 1100, 150); newPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(newPlatform); //make goal on platform // goal = new GoalZone(new Vector2(700, PlayerSpawnPosition.Y), 100, 100); goal = new GoalZone(newPlatform); player.LoadPlatformsPlayer(platformList); }
public override void LoadLevel() { Game1.TimeScore = 0; base.LoadLevel(); Sprite3 newPlatform; OutOfBounds = new Rectangle(0, 0, Game1.SCREEN_WIDTH, 1000); newPlatform = new Sprite3(true, texPixel, 200, 500); newPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(newPlatform); PlayerSpawnPosition = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100); newPlatform = new Sprite3(true, texPixel, 900, 500); newPlatform.setWidthHeight(100, 30); platformList.addSpriteReuse(newPlatform); if (!isChallengeMode) { targetSpawnPositions.Add(new Vector2(380, 362)); targetSpawnPositions.Add(new Vector2(552, 359)); targetSpawnPositions.Add(new Vector2(717, 354)); } else { targetSpawnPositions.Add(new Vector2(74, 396)); targetSpawnPositions.Add(new Vector2(69, 537)); targetSpawnPositions.Add(new Vector2(70, 682)); targetSpawnPositions.Add(new Vector2(272, 675)); targetSpawnPositions.Add(new Vector2(471, 664)); targetSpawnPositions.Add(new Vector2(668, 656)); targetSpawnPositions.Add(new Vector2(850, 654)); targetSpawnPositions.Add(new Vector2(1018, 647)); targetSpawnPositions.Add(new Vector2(1158, 650)); targetSpawnPositions.Add(new Vector2(1144, 545)); targetSpawnPositions.Add(new Vector2(1144, 420)); } goal = new GoalZone(newPlatform); }
//Adds explosion to particle list public void AddExplosion(int x, int y) { float scale = 0.6f; float xOffset = -10; float yOffset = -5; Sprite3 newExplosion = new Sprite3(true, explosionTex, x + xOffset, y + yOffset); newExplosion.setXframes(7); newExplosion.setYframes(3); newExplosion.setWidthHeight(896 / 7 * scale, 384 / 3 * scale); Vector2[] anim = new Vector2[21]; anim[0].X = 0; anim[0].Y = 0; anim[1].X = 1; anim[1].Y = 0; anim[2].X = 2; anim[2].Y = 0; anim[3].X = 3; anim[3].Y = 0; anim[4].X = 4; anim[4].Y = 0; anim[5].X = 5; anim[5].Y = 0; anim[6].X = 6; anim[6].Y = 0; anim[7].X = 0; anim[7].Y = 1; anim[8].X = 1; anim[8].Y = 1; anim[9].X = 2; anim[9].Y = 1; anim[10].X = 3; anim[10].Y = 1; anim[11].X = 4; anim[11].Y = 1; anim[12].X = 5; anim[12].Y = 1; anim[13].X = 6; anim[13].Y = 1; anim[14].X = 0; anim[14].Y = 2; anim[15].X = 1; anim[15].Y = 2; anim[16].X = 2; anim[16].Y = 2; anim[17].X = 3; anim[17].Y = 2; anim[18].X = 4; anim[18].Y = 2; anim[19].X = 5; anim[19].Y = 2; anim[20].X = 6; anim[20].Y = 2; newExplosion.setAnimationSequence(anim, 0, 20, 2); newExplosion.setAnimFinished(2); // make it inactive and invisible newExplosion.animationStart(); particleList.addSpriteReuse(newExplosion); soundExplosionLimit.playSoundIfOk(); }