public void Update(GameTime gameTime) { if (powerup == null) { if (remaining < 0) { remaining = rand.NextDouble() * 10 + 10; lock (phyWorld) powerup = (Powerup)Activator.CreateInstance( types[rand.Next(0, types.Length)], phyWorld, gameplay, rand); powerup.LoadContent(content); } else remaining -= gameTime.ElapsedGameTime.TotalSeconds; } else { if (powerup.IsActive) powerup.Update(); else { phyWorld.RemoveBody(powerup); powerup = null; } } }
public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (sprite != null && visible) { spriteBatch.Draw(sprite, position, null, Color.White, 0, Vector2.Zero, new Vector2(1, spriteScale), SpriteEffects.None, 0); } }
protected override void Update(GameTime gameTime) { float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds; map.Update(time); base.Update(gameTime); }
protected override void Draw(GameTime gameTime) { base.Draw(gameTime); this.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); this.spriteBatch.DrawString(this.font, "", new Vector2(1f, 1f), Color.White, 0f, Vector2.Zero, (float)1f, SpriteEffects.None, 1f); this.spriteBatch.End(); }
/// <summary> /// Draws the menu. /// </summary> public override void Draw(GameTime gameTime) { SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Transform); // Draw the menu title. if (titleTexture == null) spriteBatch.DrawString(ScreenManager.GameContent.gameFont, titleString, titlePosition, Color.White * TransitionAlpha, 0, Vector2.Zero, titleSize / ScreenManager.GameContent.gameFontSize, SpriteEffects.None, 0); else spriteBatch.Draw(titleTexture, titlePosition, Color.White * TransitionAlpha); // Draw each menu entry in turn. for (int i = 0; i < menuEntries.Count; i++) { MenuEntry menuEntry = menuEntries[i]; bool isSelected = IsActive && (i == selectedEntry); menuEntry.Draw(isSelected, gameTime); } spriteBatch.End(); }
public override void Update(GameTime gameTime) { Position += Speed; Angle += AngularSpeed; Opacity -= OpacityChange; CurrentLife += gameTime.ElapsedGameTime.Milliseconds; }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Draw(GameTime gameTime) { GestionSprites.Begin(); GestionSprites.DrawString(Font,TexteÀAfficher, Position, CouleurTexte,0,Origine,Échelle, SpriteEffects.None,1f); GestionSprites.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { Matrix world = Matrix.CreateRotationY(this.rotation) * Matrix.CreateTranslation(this.position + (Vector3.Up * height)); Matrix[] transforms = new Matrix[this.model.Bones.Count]; this.model.CopyAbsoluteBoneTransformsTo(transforms); GraphicsDevice.BlendState = BlendState.AlphaBlend; GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.DepthStencilState = DepthStencilState.Default; foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = transforms[mesh.ParentBone.Index] * world; effect.View = CanyonGame.Camera.View; effect.Projection = CanyonGame.Camera.Projection; effect.Alpha = this.alpha; effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } mesh.Draw(); } base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { resolver.RunAllRunners(); if (runCodeForTests != null) runCodeForTests(); resolver.RunAllPresenters(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { currentstate = Keyboard.GetState(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); // TODO: Add your update logic here else { if (currentstate.IsKeyDown(Keys.A) && !oldstate.IsKeyDown(Keys.A)) { sounds[0].Play(); //var sd = soundEffects[0].CreateInstance(); //sd.IsLooped = false; //sd.Play(); //sd.Dispose(); } if (currentstate.IsKeyDown(Keys.R) && !oldstate.IsKeyDown(Keys.R)) { rd.BMS파일분석(); } if (currentstate.IsKeyDown(Keys.Y) && !oldstate.IsKeyDown(Keys.Y)) { rd.노트시간계산();sdmgr.시간들 = rd.시간들; } if (currentstate.IsKeyDown(Keys.S) && !oldstate.IsKeyDown(Keys.S)) { sdmgr.Play(); //var sd = soundEffects[1].CreateInstance(); //sd.Play(); } oldstate = currentstate; } base.Update(gameTime); }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { // TODO: Add your update code here this.time += gameTime.ElapsedGameTime.Milliseconds; if (this.time >= 1000) { this.time = 0; this.s += 1; //if (s >= 60) //{ // s = 0; // m += 1; // if (m >= 60) // h += 1; //} //if (h > 0) // Console.WriteLine("時間計時:" + h + "小時" + m + "分" + s + "秒"); //else if (m > 0) // Console.WriteLine("時間計時:" + m + "分" + s + "秒"); //else Console.WriteLine("時間計時:" + s + "秒"); if (s > time_Max) s = time_Max; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (left.Clicked) this.SceneNavigator.MoveToScene(Scenes.SCENE_2); if (right.Clicked) this.SceneNavigator.MoveToScene(Scenes.SCENE_2); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects) { if (Animation == null) { throw new NotSupportedException("No animation is currently playing."); } time += (float)gameTime.ElapsedGameTime.TotalSeconds; while (time > Animation.frameTime) { time -= Animation.frameTime; if (Animation.isLooping) { frameIndex = (frameIndex + 1) % Animation.FrameCount; } else { frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1); } } Rectangle source = new Rectangle(FrameIndex * Animation.FrameWidth, 0, Animation.FrameWidth, Animation.FrameHeight); spriteBatch.Draw(animation.texture, position, source, Color.White, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f); }
public override void Update(GameTime gameTime) { ControlManager.Update(gameTime, PlayerIndex.One); base.Update(gameTime); }
public void DrawFlagScore(SpriteBatch spriteBatch, GameTime gameTime, float stoppingHeight) { scoreOrigin = ScoreFont.MeasureString(scoreText) / GameValues.ScoreSpriteScoreOriginOffset; spriteBatch.DrawString(ScoreFont, scoreText, new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreYOffset), Color.White, 0, scoreOrigin, 0.4f, SpriteEffects.None, 0f); if (Position.Y > stoppingHeight) { Position = new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreDropOffet); } else if (Position.Y <= stoppingHeight) { //Position.Y = stoppingHeight; Position = new Vector2(Position.X, stoppingHeight); if (scoreBuffer <= 0) { scoreBuffer = GameValues.ScoreSpriteScoreBuffer; ScoringOn = !ScoringOn; } else { scoreBuffer--; } } }
public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime) { Vector2 _position2 = new Vector2(_position.X, _position.Y + 150); Vector2 _position3 = new Vector2(_position.X, _position.Y + 300); if (pause) { spriteBatch.Draw(_texture, Vector2.Zero, Color.White); if (jouerIn) spriteBatch.Draw(jouer, _position, Color.Blue); else spriteBatch.Draw(jouer, _position, Color.White); if (OptionIn) spriteBatch.Draw(options, _position2, Color.Blue); else spriteBatch.Draw(options, _position2, Color.White); if (QuitterIn) spriteBatch.Draw(quitter, _position3, Color.Blue); else spriteBatch.Draw(quitter, _position3, Color.White); } }
/// <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(); //drawas all the objects to the game spriteBatch.Draw(Paddle, PaddlePos, Color.White); spriteBatch.Draw(Ball, BallPos, Color.White); spriteBatch.DrawString(Lives, "Lives = " + Numberlives, new Vector2(020,020), Color.White); spriteBatch.DrawString(Lives, "Score = " + score, new Vector2(580, 020), Color.White); //draws allthe bricks on the board foreach (var pos in BricksPos) spriteBatch.Draw(Block, pos, Color.Turquoise); // makes it so that if there are no more lives it displays some text to tell you if (Numberlives <= 0) { spriteBatch.DrawString(Lives, "You ran out of Lives, press [Esc] to leave", new Vector2(200, 400), Color.White); } if (score >= 300) { spriteBatch.DrawString(Lives, "You won, GG press [Esc] to exit", score, new Vector2(200, 400), Color.White); } spriteBatch.End(); base.Draw(gameTime); }
// Most content in this class will be here, drawn. public override void Draw(GameTime gameTime) { switch (parent.currentState) { // Splash Screen Text case Game1.GameState.Start: // Main Screen Text parent.spriteBatch.Begin(); parent.spriteBatch.Draw(logo, new Vector2(parent.Window.ClientBounds.Width / 2 - 400, -40), new Rectangle(0,0,800,300), Color.White); parent.spriteBatch.End(); break; // INSTRUCTION TEXT case Game1.GameState.Instructions: parent.spriteBatch.Begin(); parent.spriteBatch.Draw(logo, new Vector2(parent.Window.ClientBounds.Width / 2 - 400, -40), new Rectangle(0, 0, 800, 300), Color.White); parent.spriteBatch.DrawString(parent.descriptionFont, "You've decided to adopt a hippo!\n" + "Keep your pet hippo happy by playing minigames and earning points!\n" + "The more points you earn, the more things you can buy!\n", new Vector2(20, 200), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1); parent.spriteBatch.End(); 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) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); base.Draw(gameTime); spriteBatch.End(); }
protected override void Draw(GameTime gameTime) { // Clear the backbuffer graphics.GraphicsDevice.Clear( Color.Black ); spriteBatch.Begin(); // draw the sprites spriteBatch.Draw( background, new Rectangle(0,0,2400,1440), Color.White ); spriteBatch.Draw( earth, new Vector2 (400, 240), Color.White ); foreach(var laser in gameObjects.Lasers) { laser.Draw( spriteBatch ); } foreach(var asteroid in gameObjects.Asteroids){ asteroid.Draw( spriteBatch ); } gameObjects.Shuttle.Draw( spriteBatch ); spriteBatch.DrawString( font, score.ToString(), new Vector2 (100, 100), Color.Red ); spriteBatch.End(); base.Draw( gameTime ); }
public override void Draw(GameTime gameTime) { RasterizerState rs = new RasterizerState(); rs.CullMode = CullMode.None; rs.FillMode = FillMode.WireFrame; this.device.RasterizerState = rs; Viewport viewport = this.device.Viewport; this.defaultEfft.World = Matrix.CreateTranslation(new Vector3(-this.witdth/2, -this.heigh/2, -100.0f)); this.defaultEfft.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, viewport.AspectRatio, 5.0f, 200.0f); foreach (EffectPass pass in this.defaultEfft.CurrentTechnique.Passes) { pass.Apply(); foreach (VertexPositionColor[] row in this.pointMatrics) { this.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, row, 0, row.Length - 2, VertexPositionColor.VertexDeclaration); } } base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { SpriteBatch spriteBatch = ScreenManager.SpriteBatch; SpriteFont font = ScreenManager.TopScoresFont; ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3); Viewport viewport = ScreenManager.GraphicsDevice.Viewport; Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 messageSize = font.MeasureString(message); Vector2 messagePosition = (viewportSize - messageSize) / 2; const int hPad = 32; const int vPad = 16; Rectangle backgroundRectangle = new Rectangle((int)messagePosition.X - hPad, (int)messagePosition.Y - vPad, (int)messageSize.X + hPad * 2, (int)messageSize.Y + vPad * 2); Color color = Color.White * TransitionAlpha; spriteBatch.Begin(); spriteBatch.Draw(questionFrameTex, backgroundRectangle, color); spriteBatch.DrawString(font, message, messagePosition, color); spriteBatch.End(); }
public override void Draw(GameTime aGameTime) { for (int loop = 0; loop < List.Count; loop++) { List[loop].Draw(); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput( InputHelper input, GameTime gameTime ) { if ( input.IsMenuSelect () || input.IsMenuCancel () || input.IsNewMouseButtonPress ( MouseButtons.LeftButton ) ) { ExitScreen (); } }
public override ModuleName Update(GameTime gameTime) { if (PROP.allInput.Back()) return ModuleName.Exit; else if (PROP.allInput.SelectMenuItem()) { switch (selected) { case 0: //New game PROP.InitPlayers(); //create a ship for each player refEngine.LoadLevel(LevelNumber.One); return ModuleName.Engine; case 1: //Options return ModuleName.Options; case 2: //Instructions return ModuleName.Instructions; case 3: //Credits return ModuleName.Credits; case 4: //Exit return ModuleName.Exit; default: //New game return ModuleName.MainMenu; } } else if (PROP.allInput.MenuNext()) SelectNext(); else if (PROP.allInput.MenuPrevious()) SelectPrevious(); return base.Update(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) { int drawCalls = 0; GraphicsDevice.Clear(Color.CornflowerBlue); Debug.Start("drawing"); Map.Draw(GraphicsDevice); player.Draw(); Debug.Stop("drawing"); spriteBatch.Begin(); spriteBatch.Draw(crosshair, new Vector2(GraphicsDevice.Viewport.Width / 2 - crosshair.Width / 2 + 5, GraphicsDevice.Viewport.Height / 2 - crosshair.Height / 2 + 5), Color.White); spriteBatch.End(); this.Window.Title = "FPS: " + fpsCounter.Update(gameTime); Debug.AddString(String.Format("FPS: {0}", fpsCounter.Update(gameTime))); Debug.AddString(String.Format("Draw calls: {0}", drawCalls)); Debug.AddStringTimer("Drawing time", "drawing"); Debug.AddString(String.Format("Player pos: {0}", player.Position)); base.Draw(gameTime); /* * Potrzebne poniewa¿ mieszamy 3D z 2D */ GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
/// <summary> /// Update timers. /// </summary> /// <param name="gameTime">Game time.</param> public void Update(GameTime gameTime) { var timersToRemove = new List<Timer>(); for (var i = 0; i < timers.Count; i++) { var timer = timers[i]; if (!timer.Running) continue; timer.TimeElapsed += gameTime.ElapsedGameTime.TotalSeconds; if (timer.TimeElapsed >= timer.Duration) { timer.Running = false; timer.CallbackAction?.Invoke(); if (timer.RemoveAfterCallback) timersToRemove.Add(timer); } } foreach (var timer in timersToRemove) { timers.Remove(timer); } }
protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Down) && mPrevState.IsKeyUp(Keys.Down)) { if(mSelectedIndex < mUIElements.Count - 1) { mSelectedIndex++; } } if (Keyboard.GetState().IsKeyDown(Keys.Up) && mPrevState.IsKeyUp(Keys.Up)) { if(mSelectedIndex > 0) { mSelectedIndex--; } } if (Keyboard.GetState().IsKeyDown(Keys.Enter) && mPrevState.IsKeyUp(Keys.Enter)) { //do whatever is selected if(mUIElements[mSelectedIndex].Text == "Quit") { ExitGameChanged(this, EventArgs.Empty); } if(mUIElements[mSelectedIndex].Text == "Settings") { } } mPrevState = Keyboard.GetState(); base.Update(gameTime); }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { // This game has a blue background. Why? Because! ScreenManager.GraphicsDevice.Clear(Color.CornflowerBlue); _backSpriteManager.Draw(gameTime); _midSpriteManager.Draw(gameTime); _frontSpriteManager.Draw(gameTime); // Our player and enemy are both actually just text strings. SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(); spriteBatch.DrawString(gameFont, _healthBar.GetH().ToString(), enemyPosition, Color.DarkRed); _healthBar.Draw(); _spawner.Draw(); spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }