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(); }
public override void Update(GameTime gameTime) { ticks++; //load animation //anmiation1.animationTick(); dragonList.animationTick(); 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(); for (int i = 0; i < dragonList.count(); i++) { Sprite3 s = dragonList.getSprite(i); if (s == null) { continue; } if (!s.active) { continue; } if (!s.visible) { continue; } if (ball.getBoundingBoxAA().Intersects(s.getBoundingBoxAA())) { baz.Play(); s.setActive(false); scoure++; ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1)); setSys5(); p.Update(gameTime); } } if (k.IsKeyDown(Keys.B) && prevK.IsKeyUp(Keys.B)) // *** { showbb = !showbb; } k = Keyboard.GetState(); if (k.IsKeyDown(Keys.Right)) { if (paddle.getPosX() < rhs - texpaddle.Width) { paddle.setPosX(paddle.getPosX() + paddleSpeed); } } if (k.IsKeyDown(Keys.Left)) { if (paddle.getPosX() > lhs) { paddle.setPosX(paddle.getPosX() - paddleSpeed); } } if (ballStuck) { ball.setPos(paddle.getPos() + ballOffset); } //if (ballStuck) //{ // ball.setPos(paddle.getPos() + ballOffset); // if (k.IsKeyDown(Keys.Space) && prevK.IsKeyUp(Keys.Space)) // { // ballStuck = false; // ball.setDeltaSpeed(new Vector2(1, -3)); // } //} else { // move ball ball.savePosition(); ball.moveByDeltaXY(); } if (ballStuck) { ball.setPos(paddle.getPos() + ballOffset); if (k.IsKeyDown(Keys.Space) && prevK.IsKeyUp(Keys.Space)) { ballStuck = false; ball.setDeltaSpeed(new Vector2(2, -3)); } } else { // move ball ball.savePosition(); ball.moveByDeltaXY(); Rectangle ballbb = ball.getBoundingBoxAA(); if (ballbb.X + ballbb.Width > rhs) { ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1)); } if (ballbb.X < lhs) { ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1)); } if (ballbb.Y < top) { ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1)); } //pedal intersects if (ballbb.Intersects(paddle.getBoundingBoxAA())) { ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1)); } } if (k.IsKeyDown(Keys.P)) { gameStateManager.setLevel(0); } if (k.IsKeyDown(Keys.M)) { gameStateManager.setLevel(0); ball.setPos(xx, yy); paddle.setPos(xx, bot - texpaddle.Height); scoure = 0; //ball.setDeltaSpeed(new Vector2(0,0)); for (int i = 0; i < dragonList.count(); i++) { Sprite3 s = dragonList.getSprite(i); s.setActive(true); } } if (ball.getPosY() > bot) { gameStateManager.setLevel(5); ball.setPos(xx, yy); paddle.setPos(xx, bot - texpaddle.Height); scoure = 0; //ball.setDeltaSpeed(new Vector2(0,0)); for (int i = 0; i < dragonList.count(); i++) { Sprite3 s = dragonList.getSprite(i); s.setActive(true); // p.Update(gameTime); } } // next leve condition if (scoure >= 15) { gameStateManager.setLevel(0); limSound.playSound(); } ballPos = new Vector2(ball.getPosX(), ball.getPosY()); if (p != null) { p.Update(gameTime); } base.Update(gameTime); }
public void UpdateL1(GameTime gameTime) { ks = Keyboard.GetState(); yarnBalls.moveDeltaXY(); // collision test for (int i = 0; i < yarnBalls.count(); i++) { Sprite3 s = yarnBalls.getSprite(i); bool coll = playerSprite.collision(s); if (coll) { kachingSound.playSoundIfOk(); s.setActive(false); points++; } } // used to move the kitty cat to the left if (ks.IsKeyDown(Keys.Left)) { playerSprite.moveByDeltaXY(); playerSprite.animationTick(gameTime); successSound.playSoundIfOk(); playerSprite.active = true; background.Update(gameTime); } if (ks.IsKeyDown(Keys.Right)) { // NOTE: the move right functionality does not work currently background.Update(gameTime); } if (ks.IsKeyDown(Keys.B)) { showBB = !showBB; } /// increases the player's jump speed - this is a secret function if (ks.IsKeyDown(Keys.Z)) { playerJumpSpeed++; } // decreases the player's jump speed - this is another secret function if (ks.IsKeyDown(Keys.X)) { playerJumpSpeed--; } // this gives the small kitty cat the ability to jump around the screen if (playerJump) { playerVec.Y += playerJumpSpeed; playerJumpSpeed += 1; playerSprite.setPosY(playerVec.Y); if (playerVec.Y >= prevPos.Y) { playerSprite.setPosY(prevPos.Y); playerJump = false; } } else { if (ks.IsKeyDown(Keys.Up)) { playerJump = true; jumpoSound.playSoundIfOk(); playerJumpSpeed = -14; playerSprite.setPosY(playerVec.Y); } } // transition over to level 2 if (points == 5) { state = 3; } }