public override void Update(GameTime gameTime, InputState inputState) { if (IsAlive) { int rnd = _random.Next(0, 10); float distance = gameTime.ElapsedGameTime.Milliseconds/10.0f; MovementVector = Vector2.Zero; switch (rnd) { case 0: // move up MovementVector.Y -= 1.0f; break; case 1: // move right MovementVector.X += 1.0f; break; case 2: // move down MovementVector.Y += 1.0f; break; case 3: // move left MovementVector.X -= 1.0f; break; } CenterPosition += MovementVector * distance; } }
public override void Update(GameTime gameTime, InputState inputState) { foreach (IDrawableGameComponent item in _enemies) { item.Update(gameTime, inputState); } }
public override void Update(GameTime gameTime, InputState inputState) { if (IsAlive) { // do nothing if MovementVector is zero if (MovementVector.X.ApproximatelyEquals(0) && MovementVector.Y.ApproximatelyEquals(0)) { return; } AdjustRotation(gameTime); // calculate new sprite position float distance = gameTime.ElapsedGameTime.Milliseconds/2.0f; Vector2 newPosition = CenterPosition + (MovementVector*distance); BoundsCheck check = WithinScreenBounds(newPosition); if (check == BoundsCheck.InBounds) { CenterPosition = newPosition; } else { if (check == BoundsCheck.OutsideLeftOrRight) { MovementVector.X = -MovementVector.X; } else { MovementVector.Y = -MovementVector.Y; } } } }
public void Update(GameTime gameTime, InputState inputState) { foreach (KeyValuePair<string, IDrawableGameComponent> item in _gameComponents) { item.Value.Update(gameTime, inputState); } }
public void Update(GameTime gameTime, InputState inputState) { if (inputState.IsPause(PlayerIndex.One)) { _gameStateManager.ChangeState("SpaceDefenderPlaying", _gameComponents); } }
public override void Update(GameTime gameTime, InputState inputState) { var direction = new Vector2(0.0f, 1.0f); var velocity = new Vector2(0.0f, 200.0f); CenterPosition += direction * velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; float scaledSizeY = _textures[0].Height * _scale.Y; if (CenterPosition.Y > (scaledSizeY * (_textures.Count == 1 ? 1 : _textures.Count - 1)) + (scaledSizeY / 2.0f)) { CenterPosition = new Vector2(GameRoot.ScreenSize.X / 2.0f, (GameRoot.ScreenSize.Y / 2.0f) - scaledSizeY); } }
public override void Update(GameTime gameTime, InputState inputState) { if (IsAlive) { _elapsed += (float)gameTime.ElapsedGameTime.TotalSeconds; if (_elapsed > UPDATE_INTERVAL) { _elapsed = 0.0f; float distance = gameTime.ElapsedGameTime.Milliseconds / 16.0f; CenterPosition += (MovementVector * distance); // If the bullet has moved off of the screen, // set it to inactive if ((BottomRightPosition.X > GameRoot.ScreenSize.X) || (TopLeftPosition.X < 0)) { IsAlive = false; } } } }
public override void Update(GameTime gameTime, InputState inputState) { MovementVector = Vector2.Zero; float distanceToMove = gameTime.ElapsedGameTime.Milliseconds / 10.0f; if (inputState.IsRight(PlayerIndex.One)) { MovementVector.X += 3.0f; } if (inputState.IsLeft(PlayerIndex.One)) { MovementVector.X -= 3.0f; } if (inputState.IsSpace(PlayerIndex.One)) { Shoot(_projectiles); } CenterPosition += MovementVector * distanceToMove; }
public override void Update(GameTime gameTime, InputState inputState) { float x = MovementVector.X; float y = MovementVector.Y; x = AdjustX(x); var newPosition = CenterPosition * MovementVector; if (Random.Next(200) == 1) { RandomizeMovement(); } if (newPosition.Y < PlayArea.Top) { newPosition.Y = PlayArea.Top; RandomizeMovement(); } if (newPosition.Y > PlayArea.Bottom) { newPosition.Y = PlayArea.Bottom; RandomizeMovement(); } CenterPosition = newPosition; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //MakeFullScreen(); SetResolution(1280, 720); // 800x600, 1024x768, 1280x720, 1600x900, 1680x1050, 1920x1080 // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); Primitives2D.Initialize(GraphicsDevice); _inputState = new InputState(); SetupGameStates(_gameStateManager); _updateFramesPerSecondCounter.Reset(); _drawFramesPerSecondCounter.Reset(); base.Initialize(); }
public override void Update(GameTime gameTime, InputState inputState) { if (IsPlaying) { _frameTimer += (float) gameTime.ElapsedGameTime.TotalMilliseconds; if (_frameTimer > _frameLength) { _frameTimer = 0.0f; Sprite.TextureAtlas.Frame++; if (Sprite.TextureAtlas.Frame > _endFrame) { Sprite.TextureAtlas.Frame = Row * Columns; if (!IsLooping) { IsPlaying = false; IsAlive = false; } } } } }
public override void Update(GameTime gameTime, InputState inputState) { _updateDelay += (float)gameTime.ElapsedGameTime.TotalSeconds; if (_updateDelay > PlayArea.UpdateInterval) { _updateDelay = 0.0f; BackgroundOffset += new Vector2(_playerShip.ScrollRate, 0.0f); _playerShip.WorldX = BackgroundOffset.X; ParallaxOffset += new Vector2(_playerShip.ScrollRate * 2, 0.0f); } }
public override void Update(GameTime gameTime, InputState inputState) { if (IsPlaying) { _frameTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (_frameTimer > _frameLength) { _frameTimer = 0.0f; Sprite.TextureAtlas.Frame = _animationSequenceList[AnimationSequenceId].GetNextFrame(); if (Sprite.TextureAtlas.Frame == -1) { Sprite.TextureAtlas.Frame = _animationSequenceList[AnimationSequenceId].StartFrame; if (!IsLooping) { IsPlaying = false; IsAlive = false; } } } } }
public void Update(GameTime gameTime, InputState inputState) { if (inputState.IsPause(PlayerIndex.One)) { _gameStateManager.ChangeState("Paused", _gameComponents); return; } CheckForCollisions(); foreach (KeyValuePair<string, IDrawableGameComponent> item in _gameComponents) { item.Value.Update(gameTime, inputState); } }
public abstract void Update(GameTime gameTime, InputState inputState);
public void Update(GameTime gameTime, InputState inputState) { }
public void Update(GameTime gameTime, InputState inputState) { if (_currentState == null) { return; } _currentState.Update(gameTime, inputState); }