/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); foreach (EnemyBasic eb in enemyBasics) { eb.Draw(spriteBatch); } foreach (Explosion e in explosions) { e.Draw(spriteBatch); } if (!Gameover) // If the game is still in play { player.Draw(spriteBatch); spriteBatch.DrawString(font, "Score: " + score, new Vector2(10, 10), Color.Black); particleSystem.Draw(); } else // If the game has ended { spriteBatch.DrawString(font, "Game over! Final Score: " + score, new Vector2(100, 100), Color.Black); } spriteBatch.End(); particleSystemEnemy.Draw(); base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch) { if (state != AnimationState.Dead) { /* * if (state == AnimationState.Attack) * { * attackParticles.Draw(spriteBatch); * state = AnimationState.Idle0; * } */ //Draw piece Rectangle source = new Rectangle((int)state * 64, 0, 64, 64); spriteBatch.Draw(texture, positionCurrent, source, Color.White); /* * if (state == AnimationState.Move) * { * movementParticles.Draw(spriteBatch); * state = AnimationState.Idle0; * } */ //Draw movement if selected if (drawMovement) { } } else { Rectangle source = new Rectangle((int)state * 64, 0, 64, 64); spriteBatch.Draw(texture, positionCurrent, source, Color.White); deathParticles.Draw(spriteBatch); } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); spriteBatch.DrawString(font, "Points: " + Points, new Vector2(5, 5), Color.Black); //spriteBatch.DrawString(font, "Player Coord X: " + paddle.playerPosition.X, new Vector2(10, 10), Color.Black); //spriteBatch.DrawString(font, "Player Coord Y: " + paddle.playerPosition.Y, new Vector2(10, 30), Color.Black); //spriteBatch.DrawString(font, "Viewport Width: " + GraphicsDevice.Viewport.Width, new Vector2(10, 60), Color.Black); //spriteBatch.DrawString(font, "Viewport Height: " + GraphicsDevice.Viewport.Height, new Vector2(10, 90), Color.Black); //spriteBatch.DrawString(font, "ball Coord X: " + ball.bounds.X, new Vector2(10, 120), Color.Black); //spriteBatch.DrawString(font, "ball Coord Y: " + ball.bounds.Y, new Vector2(10, 150), Color.Black); smokeParticleSystem.Draw(); coinParticleSystem.Draw(); playerParticleSystem.Draw(); //spriteBatch.End(); //var offset = new Vector2(450,300) - paddle.playerPosition; //var matrix = Matrix.CreateTranslation(offset.X, offset.Y, 0); //spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, matrix); ball.Draw(spriteBatch); coin.Draw(spriteBatch); paddle.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.DeepSkyBlue); var offset = new Vector2(750, 500); offset.X -= player.Bounds.X; offset.Y -= player.Bounds.Y; var tMatrix = Matrix.CreateTranslation(offset.X, offset.Y, 0); // TODO: Add your drawing code here spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, tMatrix); //spriteBatch.Begin(); ball1.Draw(spriteBatch); ball2.Draw(spriteBatch); player.Draw(spriteBatch); particleSystem1.Draw(); particleSystem2.Draw(); particleSystem3.Draw(); spriteBatch.Draw(wallText, wallN, Color.Brown); spriteBatch.Draw(wallText, wallS, Color.Brown); spriteBatch.Draw(wallText, wallE, Color.Brown); spriteBatch.Draw(wallText, wallW, Color.Brown); var textOffset1 = offset * -1; var textOffset2 = offset * -1; textOffset2.Y += 31; var textOffset3 = offset * -1; textOffset3.X += 500; spriteBatch.DrawString(font, "Use the arrow keys to move", textOffset1, Color.White); spriteBatch.DrawString(font, "Dodge the balls", textOffset2, Color.White); spriteBatch.DrawString(font, $"Score: {score}", textOffset3, Color.White); if ((ball1.State == GameState.Over) || (ball2.State == GameState.Over)) { var textOffsetGameOver = offset * -1; textOffsetGameOver.X += 500; textOffsetGameOver.Y += 500; spriteBatch.DrawString(font, "Game Over", textOffsetGameOver, Color.White); } spriteBatch.End(); base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch) { if (active) { spriteBatch.Draw(bomb, Bounds, Color.White); } if (detonated) { //spriteBatch.Draw(explosion, Explosion, Color.White); } if (explosionP) { explosionParticleSystem.Draw(); } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(color); // TODO: Add your drawing code here spriteBatch.Begin(); // TODO: Add your drawing code here normalParticle.Draw(); fastParticle.Draw(); bombParticle.Draw(); spriteBatch.DrawString( spriteFont, "Player Lane: " + laneInd, new Vector2(graphics.PreferredBackBufferWidth / 2 - 100, graphics.PreferredBackBufferHeight - 200), Color.White ); //Uncomment to check frames /*for (var i = 17; i < 30; i++) * { * sheet[i].Draw(spriteBatch, new Vector2(i * 25, 25), Color.White); * }*/ spriteBatch.Draw(background, Vector2.Zero, backgroundFrame, Color.White, 0f, Vector2.Zero, 0f, SpriteEffects.None, 1f); //bullet.Draw(spriteBatch); normalBullet.Draw(spriteBatch); fastBullet.Draw(spriteBatch); bombBullet.Draw(spriteBatch); player.Draw(spriteBatch); //proj.Draw(spriteBatch); lane0.Draw(spriteBatch); lane1.Draw(spriteBatch); lane2.Draw(spriteBatch); lane3.Draw(spriteBatch); lane4.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch) { /*------------------------- * Draw player ship * -------------------------*/ spriteBatch.Draw(texturePlayer, Bounds, Color.White); /*------------------------- * Draw left and right bullets * -------------------------*/ for (int i = 0; i < Math.Min(bulletLefts.Count, bulletRights.Count); i++) { bulletLefts[i].Draw(spriteBatch); bulletRights[i].Draw(spriteBatch); } particleSystem.Draw(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Orange); var keyboardState = Keyboard.GetState(); //var offset = new Vector2(200, 300) - new Vector2(player.testmanRec.X, player.testmanRec.Y); //var t = Matrix.CreateTranslation(offset.X, offset.Y, 0); spriteBatch.Begin(); rainParticle.Draw(); particleSystem.Draw(); finishSystem.Draw(); spriteBatch.Draw(texture, new Rectangle(0, 0, 1942, 200), Color.Black); spriteBatch.Draw(texture, new Rectangle(0, 600, 1942, 395), Color.Black); spriteBatch.Draw(finish, finishRect, Color.Yellow); player.Draw(spriteBatch); foreach (Enemy en in enemies) { en.LoadContent(Content); en.Draw(spriteBatch); } spriteBatch.DrawString(spriteFont, "(0.0)/ GET TO THE FINISH -> ", new Vector2(325, 400), Color.Green); spriteBatch.DrawString(spriteFont, "SCORE: " + score, scoreRect, Color.DeepPink); if (won && !lost) { spriteBatch.DrawString(spriteFont, "YOU WIN WOO HOO!!!!!! \n press R to restart", new Vector2(325, 450), Color.Purple); } if (lost && !won) { spriteBatch.DrawString(spriteFont, "YOU LOSE BOO HOO!!!!!! \n press R to restart", new Vector2(325, 450), Color.Red); } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(transformMatrix: camera.Transform); spriteBatch.Draw(background, backgroundPosition, Color.White); playerParticleSystem.Draw(); rainParticleSystem.Draw(); //currentTime = (float)gameTime.ElapsedGameTime.TotalSeconds; //if(currentTime - oldTime >= 5) { // oldTime = currentTime; //cometParticleSystem.Draw(); //} player.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); // TODO: Add your drawing code here fireParticle.Draw(); collisionParticle.Draw(); rainParticle.Draw(); player.Draw(spriteBatch); map.Draw(spriteBatch); if (win) { spriteBatch.DrawString(bigFont, "YOU WIN", new Vector2(300, 200), Color.White); } spriteBatch.DrawString(timeFont, "Time: " + time.ToString(), new Vector2(34, 34), Color.White); base.Draw(gameTime); spriteBatch.End(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of t;iming values.</param> protected override void Draw(GameTime gameTime) { spriteBatch.Begin(SpriteSortMode.Immediate); GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Draw(background, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), Color.White); bubbles.Draw(); player.Draw(spriteBatch); rain.Draw(); // TODO: Add your drawing code here for (int i = 0; i < 4; i++) { levelFive[i].Draw(spriteBatch); levelFour[i].Draw(spriteBatch); levelThree[i].Draw(spriteBatch); levelTwo[i].Draw(spriteBatch); levelOne[i].Draw(spriteBatch); } if (finishFlag) { spriteBatch.DrawString(font, "You WIN!", new Vector2(490, 50), Color.White); youWin.Draw(); } else { spriteBatch.DrawString(font, "Finish Line", new Vector2(490, 50), Color.White); } if (deadFlag) { youDie.Draw(); } spriteBatch.DrawString(font, "Death Count: " + deathCount, new Vector2(0, 0), Color.White); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here switch (viewState) { case ViewState.IDLE: spriteBatch.Begin(); if (win) { winner.Draw(spriteBatch); Vector2 messageCentered = scoreFont.MeasureString("Thanks For Playing!") / 2; spriteBatch.DrawString(scoreFont, "Thanks For Playing!", new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - messageCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2)), Color.Red); Vector2 fontCentered = scoreFont.MeasureString("Score: " + winner_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + winner_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else if (game_over) { gameOver.Draw(spriteBatch); Vector2 fontCentered = scoreFont.MeasureString("Score: " + game_over_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + game_over_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else { current_maze.Draw(spriteBatch); // render the score in the top left of the screen spriteBatch.DrawString(scoreFont, $"Score: {score}", Vector2.Zero, Color.Black); player.Draw(spriteBatch); wallParticleSystem.Draw(); } spriteBatch.End(); break; case ViewState.TRANSITION_RIGHT: DrawTransitionOld(prev_maze, translationX); DrawTransitionNew(current_maze, translationX); Debug.WriteLine($"{-translationX} , {graphics.GraphicsDevice.Viewport.Width - translationX}"); //float timer = 0F; //while(timer < 1000000) //{ // timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; //} if (translationX == graphics.GraphicsDevice.Viewport.Width - 1) { Debug.WriteLine("One More"); } translationX++; if (translationX >= graphics.GraphicsDevice.Viewport.Width) { viewState = ViewState.IDLE; translationX = 0; } break; } base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { var offset = new Vector2(360, 351) - player.position; var t = Matrix.CreateTranslation(offset.X, 0, 0); var gameVect = new Vector2(1080, 351); var o = new Vector2(360, 351) - gameVect; var tmp = Matrix.CreateTranslation(o.X, o.Y, 0); if (player.position.X <= 360) { spriteBatch.Begin(); } else if (player.position.X >= (worldWidth - (0.5 * graphics.PreferredBackBufferWidth))) //1080 in our case, 3/4 of full world { spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, tmp); } else { spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, t); } GraphicsDevice.Clear(Color.White); //spriteBatch.Begin(); Vector2 midScreen = new Vector2(player.position.X, 0); if (player.position.X <= 360) { midScreen.X = 360; } if (player.position.X >= (worldWidth - (0.5 * graphics.PreferredBackBufferWidth))) { midScreen.X = 1080; } cloudRect.X = (int)midScreen.X; spriteBatch.Draw(grass, grassRect, Color.White); spriteBatch.DrawString(font, "Score: " + score, midScreen, Color.Black); if (player.position.X <= buttonRect.X + buttonRect.Width && player.position.Y < 340) { hasPressedButton = true; } if (hasPressedButton) { spriteBatch.DrawString(font, message.text, new Vector2(0, 0), Color.Gold); } spriteBatch.Draw(button, buttonRect, Color.White); spriteBatch.Draw(cloud, cloudRect, Color.Gray); spriteBatch.Draw(wood, woodRect, Color.White); block1.Draw(spriteBatch); block2.Draw(spriteBatch); block3.Draw(spriteBatch); player.Draw(spriteBatch); cake.Draw(spriteBatch); cookie.Draw(spriteBatch); donut.Draw(spriteBatch); carrot.Draw(spriteBatch); broccoli.Draw(spriteBatch); spriteBatch.End(); if (player.position.X <= 360 && !hasPressedButton) { sparkleSystem.Draw(); } if (player.position.X >= (worldWidth - (0.5 * graphics.PreferredBackBufferWidth)) && !hasPressedButton) { fireSystem.Draw(); } if (hasPressedButton) { particleSystem.Draw(); } base.Draw(gameTime); }
public void Draw() { particleSystem.Draw(); }
/// <summary> /// Renders the sprite on-screen /// </summary> /// <param name="spriteBatch"></param> public void Draw(SpriteBatch spriteBatch) { // determine the source rectagle of the sprite's current frame var source = new Rectangle( frame * (FRAME_WIDTH), // X value (int)moving_state % 4 * (FRAME_HEIGHT + FRAME_HEIGHT_GAP), // Y value FRAME_WIDTH, // Width FRAME_HEIGHT // Height ); int x_value; if (moving_state == MovingState.Idle) { switch (prev_moving_state) { case MovingState.East: x_value = 1; break; default: x_value = 0; break; } source = new Rectangle( x_value * (FRAME_WIDTH), // X value (int)prev_moving_state % 4 * (FRAME_HEIGHT + FRAME_HEIGHT_GAP), // Y value FRAME_WIDTH, // Width FRAME_HEIGHT // Height ); } bomb.Draw(spriteBatch); spriteBatch.DrawString(font, "Bomb Power: ", new Vector2(200, 0), Color.DarkRed); spriteBatch.Draw(powerUpBarBack, new Rectangle(300, 0, 100, 20), null, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 1); spriteBatch.Draw(powerUpBar, new Rectangle(300, 5, powerUpBarSize, 10), null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, 0); spriteBatch.DrawString(font, "Stamina: ", new Vector2(535, 0), Color.DarkBlue); spriteBatch.Draw(staminaBarBack, new Rectangle(600, 0, 100, 20), null, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 1); spriteBatch.DrawString(font, $"{staminaBarSize}", new Vector2(702, 2), Color.White); if (staminaColor.B < 50) { staminaColor.B = 60; } if (speed_state == SpeedState.Penalty) { staminaColor.B += 5; } else { staminaColor = Color.Blue; } spriteBatch.Draw(staminaBar, new Rectangle(600, 5, staminaBarSize, 10), null, staminaColor, 0, Vector2.Zero, SpriteEffects.None, 0); dirtParticleSystem.Draw(); // spriteBatch.DrawString(font, $"{staminaColor.B}", new Vector2(700, 20), Color.White); // spriteBatch.DrawString(font, $"{staminaDelayTimer.TotalMilliseconds}", new Vector2(700, 0), Color.White); // spriteBatch.DrawString(font, $"{drainedStaminaPenalty && !(staminaDelayTimer.TotalMilliseconds < staminaDelay)}", new Vector2(700, 20), Color.White); // spriteBatch.DrawString(font, $"{powerUpBarSize}", new Vector2(500, 10), Color.Black); //spriteBatch.DrawString( // font, // $"powerUpTimer.TotalMilliseconds:{powerUpTimer.TotalMilliseconds}", // new Vector2(200, 0), // Color.White // ); // render the sprite spriteBatch.Draw(texture, Bounds, source, Color.White); }