public void Update( GameTimerEventArgs gameTime ) { TimeToChange -= gameTime.ElapsedTime; if( TimeToChange < TimeSpan.Zero ) { m_Position = new Vector2( s_RandomNumberGenerator.Next( 0, m_Device.Viewport.Width ), s_RandomNumberGenerator.Next( 0, m_Device.Viewport.Height ) ); m_Shading = new Color( s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ) ); m_SpriteFrame = new Rectangle( m_Frame * 5, 0, 5, 5 ); if( m_SpriteFrame.X + m_SpriteFrame.Width == s_Sprite.Width ) { m_Frame = 0; m_Position = new Vector2( s_RandomNumberGenerator.Next( 0, m_Device.Viewport.Width ), s_RandomNumberGenerator.Next( 0, m_Device.Viewport.Height ) ); m_Shading = new Color( s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ), s_RandomNumberGenerator.Next( 0, 255 ) ); } else { ++m_Frame; } TimeToChange = new TimeSpan( 0, 0, 0, 0, 100 * s_RandomNumberGenerator.Next( 1, 6 ) ); } }
/// <summary> /// Advances the time position and draws the current frame of the animation. /// </summary> public void Draw(GameTimerEventArgs gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects) { if (Animation == null) throw new NotSupportedException("No animation is currently playing."); // Process passing time. time += (float)gameTime.ElapsedTime.TotalSeconds; while (time > Animation.FrameTime) { time -= Animation.FrameTime; // Advance the frame index; looping or clamping as appropriate. if (Animation.IsLooping) { frameIndex = (frameIndex + 1) % Animation.FrameCount; } else { frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1); } } // Calculate the source rectangle of the current frame. Rectangle source = new Rectangle(FrameIndex * Animation.Texture.Height, 0, Animation.Texture.Height, Animation.Texture.Height); // Draw the current frame. spriteBatch.Draw(Animation.Texture, position, source, Color.White, 0.0f, Origin, 1.0f, spriteEffects, 0.0f); }
public void Update(GameTimerEventArgs e) { // Calculate the time/movement scalar for this entity timeScalar = (float)e.ElapsedTime.TotalMilliseconds; Angle += 0.001f * timeScalar; }
/// <summary> /// Checks all touchpoints at each call /// </summary> /// <param name="gameTime">The GameTimerEventArgs</param> public static void checkTouchpoints(GameTimerEventArgs gameTime) { while (TouchPanel.IsGestureAvailable) { GestureSample gs = TouchPanel.ReadGesture(); switch (gs.GestureType) { case GestureType.FreeDrag: HandleShipTouchment(gs); break; case GestureType.DragComplete: if (AppCache.CurrentMatch != null) { if (AppCache.CurrentMatch.MatchState == Enum.MatchState.ShipPlacement) { Point p = new Point(Convert.ToInt32(gs.Position.X), Convert.ToInt32(gs.Position.Y)); foreach (Ship s in AppCache.CurrentMatch.OwnShips) { if (s.isTouched) { s.GlueToFields(); AppCache.CurrentMatch.OwnPlayground.Refresh(); s.isTouched = false; VibrationManager.Vibration.Start(new TimeSpan(0, 0, 0, 0, 100)); } } } } break; case GestureType.Tap: #region Buttons foreach (IconButton b in AppCache.CurrentMatch.FooterMenu.Buttons) { if (b != null) b.CheckClick(gs); } for (int i = 0; i < AppCache.CurrentMatch.FooterMenu.Dices.Length; i++) { if (AppCache.CurrentMatch.FooterMenu.Dices[i] != null) { AppCache.CurrentMatch.FooterMenu.Dices[i].CheckClick(gs); } } AppCache.CurrentMatch.OwnPlayground.CheckClick(gs); AppCache.CurrentMatch.ShootingPlayground.CheckClick(gs); #region Ships HandleShipSelection(gs); #endregion #endregion break; } } }
public void Update(GameTimerEventArgs e) { if (TargetActor != null) { Position = new Vector3(TargetActor.Position.X, TargetActor.Position.Y, 1.0f); Target = new Vector3(TargetActor.Position.X, TargetActor.Position.Y, 0.0f); } }
public override void Update(GameTimerEventArgs gameTime) { // Animate same way with normal AnimatedSprite // //base.Update(gameTime); if (IsAlive && !IsStunned) { this.X = this.X-Velocity; } }
public override void Update(GameTimerEventArgs e) { foreach (Multiplier m in Multipliers) { m.HandleCollisions(); } base.Update(e); }
public override void Update(GameTimerEventArgs e) { foreach (Bullet b in Bullets) { b.HandleCollisions(); } base.Update(e); }
public void onUpdate(GameTimerEventArgs e) { if (wait) time += (float)e.ElapsedTime.TotalSeconds; if (time > 0.5) { time = 0; wait = false; } }
public override void Update(GameTimerEventArgs e) { if (!ShipManager.PlayerShip.Alive) { gameOver = true; } base.Update(e); }
/// <summary> /// Allows the page to draw itself. /// </summary> private void OnDraw(object sender, GameTimerEventArgs e) { SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.White); // TODO: Add your drawing code here var gameTime = new GameTime(e.TotalTime, e.ElapsedTime); spriteBatch.Begin(); level.Draw(gameTime, spriteBatch); spriteBatch.End(); }
public void Draw(SpriteBatch spriteBatch, GameTimerEventArgs gameTime) { for (int n = 0; n < spriteList.Count; n++) { if (spriteList[n].IsValid(gameTime)) { spriteList[n].Draw(gameTime, spriteBatch); } } }
public void Update(object sender, GameTimerEventArgs e) { // TODO: Fügen Sie Ihre Aktualisierungslogik hier hinzu this.offset -= 15; if (this.offset < -Background.SliceWidth) { this.sprite = this.randomSprite(); this.offset = Background.ScreenW; } }
public override void Update(Microsoft.Xna.Framework.GameTimerEventArgs e) { if (particleEffectDelay++ >= 10) { particleEffectDelay = 0; particleManager.CreateParticleEffect(10, new Vector3(random.Next(-400, 400), random.Next(-200, 200), random.Next(0, 0)), random.Next(10), new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); } base.Update(e); }
public override void Update(Microsoft.Xna.Framework.GameTimerEventArgs e) { if (particleEffectDelay++ >= 1) { particleEffectDelay = 0; particleManager.CreateParticleEffect(25, new Vector3(random.Next(-400, 400), random.Next(-200, 200), random.Next(0, 0)), random.Next(50), new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); } audioManager.PlaySong("BasicDrumBeat", true); base.Update(e); }
public override void Update(GameTimerEventArgs e) { if (VirtualThumbsticks.LeftThumbstick.Length() > 0.0f) PlayerShip.Thrust(VirtualThumbsticks.LeftThumbstick); else PlayerShip.Acceleration = Vector3.Zero; if (VirtualThumbsticks.RightThumbstick.Length() > 0.5f) PlayerShip.Fire(ref PlayerShip, VirtualThumbsticks.RightThumbstick); base.Update(e); }
public void Update(GameTimerEventArgs e) { // Calculate the time/movement scalar for this entity timeScalar = (float)(e.ElapsedTime.TotalMilliseconds * 8d); // Update the player position based on the current velocity Position += new Vector2(Velocity.X * timeScalar, Velocity.Y * timeScalar); // Decrease the velocity for a slowdown effect Velocity *= 0.99f; BoundsCheck(); }
public void Update(GameTimerEventArgs e) { if (Active) { Velocity *= 0.9f; Position += Velocity; Color = new Color(Color.R - 3, Color.G - 3, Color.B - 3, Color.A - 1); Life--; if (Life <= 0) Die(); } }
/// <summary> /// Allows the page to draw itself. /// </summary> private void OnDraw(object sender, GameTimerEventArgs e) { scoreboardRenderer.Render(); var device = SharedGraphicsDeviceManager.Current.GraphicsDevice; device.Clear(Color.CornflowerBlue); device.DepthStencilState = DepthStencilState.Default; device.RasterizerState = RasterizerState.CullCounterClockwise; gamePlay.Draw(); spriteBatch.Begin(); spriteBatch.Draw(scoreboardRenderer.Texture, scoreboardPosition, Color.White); spriteBatch.End(); }
public void Update(GameTimerEventArgs e) { animationHandler.Update(); timeScalar = (float)e.ElapsedTime.TotalMilliseconds; var delta = new Vector2(0, (target.Y - Position.Y) * 0.01f); Position += delta * timeScalar; if (animationHandler.Animations[0].HasCompleted) { target = new Vector2(target.X, -Texture.Height); } }
public override void Update(GameTimerEventArgs e) { if (gameOver) { EnemyManager.KillEnemies(); EnemyManager.Active = false; postgameTimer -= e.ElapsedTime; if (postgameTimer.TotalSeconds < 0) EndScene = true; } AudioManager.PlaySong("ParticleFusion", true); base.Update(e); }
public void Draw(GameTimerEventArgs gameTime, Rectangle square, Rectangle screen, SpriteBatch sb, Map map) { Point p; Point off; double factX = ((this.egg.getBounds().Width * 0.45) * (square.Width / 155.0)); double factY = ((this.egg.getBounds().Height * 0.45) * (square.Height / 58.0)); off.X = (this.pos.X + 1) * (square.Width / 2); off.Y = (this.pos.X) * (square.Height / 2); p.X = -this.pos.Y * (square.Width / 2) + off.X + square.X + ((int)map.getSize().Y - 1) * (square.Width / 2); p.Y = this.pos.Y * (square.Height / 2) + off.Y + square.Y - ((int)map.getSize().Y - 1) * (square.Height / 2); Rectangle tar = new Rectangle((int)(p.X + (int)(117 * (square.Width / 155.0))), (int)(p.Y + (int)(38 * (square.Height / 58.0))), (int)factX, (int)factY); if (screen.Intersects(tar)) this.egg.Draw(sb, tar); }
public void Draw(GameTimerEventArgs gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(0, null, null, null, null, null, _camera.View); foreach (var entity in _WorldEntity.WorldElements) { if (entity is PhysicsWorldElementEntity) { PhysicsWorldElementEntity physicsEntity = entity as PhysicsWorldElementEntity; if (physicsEntity.Texture2D != null) { spriteBatch.Draw(physicsEntity.Texture2D, ConvertUnits.ToDisplayUnits(physicsEntity.Position), null, Color.White, physicsEntity.Rotation, physicsEntity.Origin, 1f, SpriteEffects.None, 0f); } } else if (entity is TextElementEntity){ TextElementEntity textEntity = entity as TextElementEntity; spriteBatch.DrawString(textEntity.Font, textEntity.Text, ConvertUnits.ToDisplayUnits(textEntity.Position), textEntity.FillColor); } //switch (entity.ElementType) //{ // case ElementType.Circle: // _CircleElementRenderer.Draw(gameTime, entity as CircleElementEntity); // break; // case ElementType.Elipsis: // throw new NotImplementedException(); // case ElementType.Polygon: // throw new NotImplementedException(); // case ElementType.Rectangle: // throw new NotImplementedException(); // default: // throw new NotSupportedException(); //} } spriteBatch.End(); }
public override void Update(GameTimerEventArgs gameTime) { // Check if it is time to take a shot if (Catapult.CurrentState == CatapultState.Aiming && !Catapult.AnimationRunning) { // Fire at a random strength and angle float shotVelocity = random.Next((int)MinShotVelocity, (int)MaxShotVelocity); float shotAngle = MinShotAngle + (float)random.NextDouble() * (MaxShotAngle - MinShotAngle); Catapult.ShotStrength = (shotVelocity / MaxShotVelocity); Catapult.ShotVelocity = shotVelocity; Catapult.ShotAngle = shotAngle; } Catapult.Update(gameTime); }
public override void Update(GameTimerEventArgs gameTime) { base.Update(gameTime); if (start) { time += (float)gameTime.ElapsedTime.TotalSeconds; if (time > 0.02) { metervalue += (reverse)? -1 : 1; barmeter.Width = metervalue; //Debug.WriteLine(metervalue + "meter"+time); time = 0; } if (metervalue > width) { start = false; //reverse = true; } //if (metervalue == 0) start = false; } }
/// <summary> /// Allows the page to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Microsoft.Xna.Framework.GameTimerEventArgs"/> instance containing the event data.</param> private void OnUpdate(object sender, GameTimerEventArgs e) { this.currentLine = 0; for (var i = 0; i < this.nodes.Count; ++i) { // update the node's position this.nodes[i].Update(); for (var j = i + 1; j < this.nodes.Count; ++j) { // calculate the distance between each 2 nodes var distance = Vector2.Distance(this.nodes[i].CurrentPosition, this.nodes[j].CurrentPosition); // if distance is within the threshold if (distance < Global.MinDist) { // add a mapped value between 1-0 to each node's connectedness value var connectedness = Global.Map(distance, 0, Global.MinDist, 1, 0); this.nodes[i].ApplyConnection(connectedness, this.nodes[j]); this.nodes[j].ApplyConnection(connectedness, this.nodes[i]); if (this.currentLine < Global.NumberOfLines) { this.connections[this.currentLine++].FormConnection(this.nodes[i], this.nodes[j], distance); } } } this.nodes[i].FinishConnection(); } if (this.currentLine < this.connections.Count) { for (int i = this.currentLine; i < Global.NumberOfLines; i++) { this.connections[i].BreakConnection(null, null); } } }
/// <summary> /// Allows the page to draw itself. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Microsoft.Xna.Framework.GameTimerEventArgs"/> instance containing the event data.</param> private void OnDraw(object sender, GameTimerEventArgs e) { SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Black); // begin drawing sprites this.spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); // draw all nodes foreach (var node in this.nodes) { node.Draw(this.spriteBatch); } // draw all connections foreach (var con in this.connections) { con.Draw(this.spriteBatch); } this.elementRenderer.Render(); this.spriteBatch.Draw(this.elementRenderer.Texture, Vector2.Zero, Color.White); // end drawing sprites this.spriteBatch.End(); }
/// <summary> /// Allows the page to draw itself. /// </summary> private void OnDraw(object sender, GameTimerEventArgs e) { SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here }
/// <summary> /// Allows the page to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> private void OnUpdate(object sender, GameTimerEventArgs e) { // TODO: Add your update logic here }
// Allows the page to draw itself. private void OnDraw(object sender, GameTimerEventArgs e) { //SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GraphicsDevice.Clear(Color.Black); // Draws previous button, current page and next button currBatch.Begin(); nextBatch.Begin(); prevBatch.Begin(); // initialize counter for page string currPage = ""; currPage = (CURRPAGE + 1) + " of 10"; // draw counter for current page currBatch.Draw(currTexture, currPosition, Color.Black); currBatch.DrawString(Font1, currPage, currPosition, Color.White); // draw the previous page button if not first page if (CURRPAGE != 0) prevBatch.Draw(prevTexture, prevPosition, Color.White); // draw the next page button if not last page if (CURRPAGE != 9) nextBatch.Draw(nextTexture, nextPosition, Color.White); // Ends the drawing currBatch.End(); nextBatch.End(); prevBatch.End(); // Draws textBatch, sprite for displaying current composition textBatch.Begin(); textBatch.Draw(textTexture, textPosition, Color.White); textBatch.DrawString(Font1, textText, textTextPosition, Color.Black); textBatch.End(); // Draws targetBatch, sprite for target area to drop tiles into for adding to composition targetBatch.Begin(); targetBatch.Draw(targetTexture, targetPosition, Color.White); // If the screen is unedited, include instructional text if (unedited) targetText = "\n\n Click the tiles and tap here\n to append it to the quote"; // Clear instructional text else { targetText = ""; } // Draw text targetBatch.DrawString(Font1, targetText, targetTextPosition, Color.White); targetBatch.End(); // Draws yesBatch yesBatch.Begin(); yesBatch.Draw(yesTexture, yesPosition, Color.White); yesBatch.End(); // Draws noBatch noBatch.Begin(); noBatch.Draw(noTexture, noPosition, Color.White); noBatch.End(); // Draws tile sprites spriteBatch.Begin(); Color fontColor; // Loop through all tiles for (int i = 0; i < NUMWORDS; i++) { // Looking only at those on the current page if (Piece[i].spritePage == CURRPAGE) { // Draw the sprite texture spriteBatch.Draw(myTexture, Piece[i].spritePosition, Color.White); // Change the font color from black to red if clicked if (Piece[i].isClicked) fontColor = Color.Red; else { fontColor = Color.Black; } // Draw the string for the sprite spriteBatch.DrawString(Font1, Piece[i].Word, Piece[i].fontPosition, fontColor); } } spriteBatch.End(); }
// Allows the page to run logic such as updating the world, checking for collisions, gathering input, and playing audio. private void OnUpdate(object sender, GameTimerEventArgs e) { //TOUCH // Process touch events TouchCollection touchCollection = TouchPanel.GetState(); foreach (TouchLocation tl in touchCollection) { // when there is a touch on the screen if ((tl.State == TouchLocationState.Pressed)) { // loop through each tile for (int i = 0; i < NUMWORDS; i++) { // only enable tiles on current page if (Piece[i].spritePage == CURRPAGE) { // if nothing is already clicked if (!currTile) { // activate tile user touched if needed if (tl.Position.X < Piece[i].spritePosition.X + TWIDTH && tl.Position.X > Piece[i].spritePosition.X - 5 && tl.Position.Y < Piece[i].spritePosition.Y + 5 && tl.Position.Y > Piece[i].spritePosition.Y - THEIGHT) { Piece[i].isClicked = true; currTile = true; deleted = false; lastIndex = i; } // if touching near yes button, return tile if (tl.Position.X < yesPosition.X + ICON && tl.Position.X > yesPosition.X - 10 && tl.Position.Y < yesPosition.Y + 20 && tl.Position.Y > yesPosition.Y - ICON) { MoveSprite(original[i].spritePosition.X, original[i].spritePosition.Y, i); Piece[i].isClicked = false; } } // if tile is activated else if (Piece[i].isClicked == true) { if (tl.Position.X < 480 && tl.Position.X > 0 && tl.Position.Y > 110 && tl.Position.Y < 310) { // move tile to new touch location MoveSprite(tl.Position.X, tl.Position.Y, i); // add text to textText AddText(i); //MoveSprite(x, y, i); // unactivate tile Piece[i].isClicked = false; // no tile clicked anymore currTile = false; // remember index of last tile clicked lastIndex = i; deleted = false; } //else //Piece[i].isClicked = false; } } } //if touching near no button if (tl.Position.X < noPosition.X + ICON && tl.Position.X > noPosition.X - 10 && tl.Position.Y < noPosition.Y + 20 && tl.Position.Y > noPosition.Y - ICON && (deleted == false)) { // delete last word added RemoveText(lastIndex); // return tile to grid MoveSprite(original[lastIndex].spritePosition.X, original[lastIndex].spritePosition.Y, lastIndex); Piece[lastIndex].isClicked = false; Debug.WriteLine("i" + lastIndex); deleted = true; } // if no tile was originally clicked if (!currTile) { // if touching near previous button, reduce page of tiles if (tl.Position.X < prevPosition.X + ICON && tl.Position.X > prevPosition.X - 10 && tl.Position.Y < prevPosition.Y + 10 && tl.Position.Y > prevPosition.Y - ICON && CURRPAGE > 0) CURRPAGE--; // if touching near next button, increase page of tiles if (tl.Position.X < nextPosition.X + ICON && tl.Position.X > nextPosition.X - 10 && tl.Position.Y < nextPosition.Y + 10 && tl.Position.Y > nextPosition.Y - ICON && CURRPAGE < 9) CURRPAGE++; } } } }
public override void Update(GameTimerEventArgs gameTime) { this.CurrentTime += gameTime.ElapsedTime.Milliseconds; if (CurrentTime > animatedtime) { CurrentTime -= animatedtime; if (increment) { if (++CurrentFrame >= last) CurrentFrame = first; } else { if (--CurrentFrame < first) CurrentFrame = last - 1; } if (stop && CurrentFrame == stopFrame) { stop = false; this.animate(stopFrame, stopFrame+1); } } base.DrawArea = area[CurrentFrame]; }