Beispiel #1
0
		public static void Update( GameTime gt ) {
			if( BomberMan.bombs.Count > 0 ) {
				for( int i = 0; i < BomberMan.bombs.Count; i++ ) {
					Bomb bomb = (Bomb)BomberMan.bombs[ i ];
					if( bomb.currentTime < bomb.bombTimer ) {
						bomb.currentTime += (float)gt.ElapsedGameTime.TotalSeconds;
					} else {
						// DETONATE
						Explosion ex = new Explosion( bomb.position );
						bomb.detonate = true;
						--bomb.owner.CurrentBombs;
					}
				}
			}
		}
Beispiel #2
0
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            sb.Begin();
            #region Frames Per Second Stuff
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            frameCount++;
            timeSinceLastUpdate += elapsed;
            if (timeSinceLastUpdate > updateInterval)
            {
                fps                  = frameCount / timeSinceLastUpdate;
                frameCount           = 0;
                timeSinceLastUpdate -= updateInterval;
            }
            string FPS = String.Empty;
            FPS += "FPS: " + fps.ToString();
            //FPS += " - RT: " + gameTime.ElapsedRealTime.TotalSeconds.ToString();
            //FPS += " - GT: " + gameTime.ElapsedGameTime.ToString();
            sb.DrawString(font, FPS, new Vector2(60, 70), Color.Black);
            #endregion


            // Begin Debug Info
            sb.DrawString(font, "Player X: " + player.playerPosition.X.ToString(), new Vector2(60, 30), Color.Black);
            sb.DrawString(font, "Player Y: " + player.playerPosition.Y.ToString(), new Vector2(60, 50), Color.Black);
            sb.DrawString(font, "Bombs: " + player.CurrentBombs.ToString(), new Vector2(60, 90), Color.Black);
            sb.DrawString(font, "Player Collision: " + collision.ToString(), new Vector2(60, 110), Color.Black);
            // End Debug Info

            if (collision != true && player.IsDead != true)
            {
                switch (player.currentDirection)
                {
                case MoveDirection.Up:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Up, gameTime, 0.5f);
                    break;

                case MoveDirection.Right:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Right, gameTime, 0.5f);
                    break;

                case MoveDirection.Down:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Down, gameTime, 0.5f);
                    break;

                case MoveDirection.Left:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Left, gameTime, 0.5f);
                    break;

                default:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Idle, gameTime, 0.5f);
                    break;
                }
                // Draw Bombs
                for (int i = 0; i < bombs.Count; i++)
                {
                    Bomb bomb = (Bomb)bombs[i];
                    if (bomb.Detonate == false)
                    {
                        Animation.DrawAnimation(sb, bombsTexture, bomb.TimerAnimation, gameTime, bomb.Position, true, 0.5f);
                    }
                    else
                    {
                        bombs.RemoveAt(i);
                    }
                }
                for (int j = 0; j < explosions.Count; j++)
                {
                    Explosion exp = (Explosion)explosions[j];
                    if (exp.Elapsed < exp.ExplosionTime)
                    {
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameMiddle, gameTime, exp.Position, false, 0.1f);
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameLeft, gameTime, exp.positionLeft, false, 0.1f);
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameRight, gameTime, exp.positionRight, false, 0.1f);
                    }
                    else
                    {
                        explosions.RemoveAt(j);
                    }
                }
            }
            else
            {
                player.IsDead = true;
                sb.DrawString(font, "PWNED", new Vector2(380, 200), Color.Red);
            }

            sb.End();
            base.Draw(gameTime);
        }