//protected override void Initialize() { // // TODO: Add your initialization logic here // base.Initialize(); //} //protected override void LoadContent() { // _spriteBatch = new SpriteBatch(GraphicsDevice); // stage = new Vector2(_graphics.PreferredBackBufferWidth, // _graphics.PreferredBackBufferHeight); // ReadLevel(levelName); // Texture2D manTex = game.Content.Load<Texture2D>("Image/jumper"); // Vector2 manInitPos = new Vector2(_tiles[0].Position.X + manTex.Width, _tiles[0].Position.Y - manTex.Height); // man = new JumperMan(game, _spriteBatch, manTex, manInitPos, stage); // this.Components.Add(man); // foreach (var i in _tiles) { // CollisionManager cm = new CollisionManager(game,this, man, i, stage); // this.Components.Add(cm); // } // // TODO: use this.Content to load your game content here //} public override void Update(GameTime gameTime) { //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) // game.Exit(); if (man.getBoundRect().Bottom >= stage.Y) { //todo: loose code xnaMBox.Show("Jumper", "Game over" + "\nYour score: " + score, new[] { "OK" }); GoToMenu(); } Rectangle manRectangle = man.getBoundRect(); explosion.Position = new Vector2(manRectangle.X + manRectangle.Width / 2, manRectangle.Bottom - 10); // TODO: Add your update logic here base.Update(gameTime); }
public override void Update(GameTime gameTime) { Rectangle manRect = man.getBoundRect(); Rectangle tileRect = tile.getBoundRect(); Vector2 bouncy = new Vector2(0, -11); if (manRect.Intersects(tileRect) && tile.Enabled) { man.speed = bouncy; jumpEffect.Play(); main.Explode(); switch (tile.Type) { case JumperTile.TileType.fragile: main.score += 3; man.speed = bouncy; tile.speed = new Vector2(0, 10); //tile.Visible = false; //tile.Enabled = false; break; case JumperTile.TileType.Slide: main.score += 2; break; case JumperTile.TileType.Static: main.score++; break; default: throw new ArgumentOutOfRangeException(); } if (tile.isLast) { //MessageBox.Show("Congrats"); main.GoToNextLevel(); } } }