Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/Games/JumpyJet/JumpyJet.Game/CharacterScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override async Task Execute()
if (!isRunning)
continue;

var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

// apply impulse on the touch/space
if (Input.IsKeyPressed(Keys.Space) || UserTappedScreen())
Expand Down
2 changes: 1 addition & 1 deletion samples/Games/JumpyJet/JumpyJet.Game/PipesScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override void Update()
if (!isScrolling)
return;

var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

for (int i = 0; i < pipeSets.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void Update()
if (!isScrolling)
return;

var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

// Check if needed to remove the first block
var firstBlock = levelBlocks[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override async Task Execute()
rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X);

rotationSpeed *= 0.93f;
var elapsedTime = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override async Task Execute()
if (inputState == InputState.RunLeft || inputState == InputState.RunRight)
{
// Update Agent's position
var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

Entity.Transform.Position.X += ((inputState == InputState.RunRight) ? AgentMoveDistance : -AgentMoveDistance) * dt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void Start()

public override void Update()
{
var currentTime = Game.DrawTime.Total;
var currentTime = Game.UpdateTime.Total;

keyDown = "";
keyEvents = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override async Task Execute()
{
while (Game.IsRunning)
{
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
timeToProcess = Math.Max(timeToProcess + elapsedTime, 1.0f);

// determine if the user is currently touching the screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected void SpawnInstance()
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}

// Remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override async Task Execute()
rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X);

rotationSpeed *= 0.93f;
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void UpdateDebugShapes()

private void ProcessInput()
{
float deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
float deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
translation = Vector3.Zero;
yaw = 0f;
pitch = 0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override void Start()

public override void Update()
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
var currentPosition = CameraComponent.Entity.Transform.Position;
var currentRotation = CameraComponent.Entity.Transform.Rotation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void Update()

// Update current animation
var currentTicks = TimeSpan.FromTicks((long)(currentTime * currentClip.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor);

var currentClipFinished = (updatedTicks >= currentClip.Duration.Ticks);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void ReloadWeapon()
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float) Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
}

remainingBullets = 9;
Expand All @@ -77,7 +77,7 @@ public override void Update()
bool didReload;
reloadEvent.TryReceive(out didReload);

cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.Elapsed.TotalSeconds) : 0f;
cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.WarpElapsed.TotalSeconds) : 0f;
if (cooldownRemaining > 0)
return; // Can't shoot yet

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void SpawnInstance(Prefab source, Entity attachEntity, float timeout,
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}

// Remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CoinRotation : SyncScript

public override void Update()
{
animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds;
animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds;

if (animationTimer >= animationInterval)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private bool HandleInput()

private void HandleAnimation(bool isMoving)
{
animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds;
animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds;

if (CharacterComponent.IsGrounded && !isMoving)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void ProcessInput()

private void UpdateTransform()
{
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

translation *= elapsedTime;
yaw *= elapsedTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ private void UpdateWalking()
animationClipWalkLerp2 = AnimationRun;
}

// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
// This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration
long blendedMaxDuration = 0;
blendedMaxDuration =
Expand All @@ -150,7 +149,7 @@ private void UpdateWalking()

currentTicks = blendedMaxDuration == 0
? TimeSpan.Zero
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
blendedMaxDuration);

currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration);
Expand All @@ -160,7 +159,7 @@ private void UpdateJumping()
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpStart.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);

if (updatedTicks < AnimationJumpStart.Duration.Ticks)
{
Expand All @@ -177,10 +176,9 @@ private void UpdateJumping()

private void UpdateAirborne()
{
// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpMid.Duration.Ticks));
currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
AnimationJumpMid.Duration.Ticks);
currentTime = ((double)currentTicks.Ticks / (double)AnimationJumpMid.Duration.Ticks);
}
Expand All @@ -189,7 +187,7 @@ private void UpdateLanding()
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpEnd.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long) (Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long) (Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);

if (updatedTicks < AnimationJumpEnd.Duration.Ticks)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public override void Start()
/// </summary>
public override void Update()
{
// var dt = Game.UpdateTime.Elapsed.Milliseconds * 0.001;
Move(MaxRunSpeed);

Jump();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void SpawnPrefabInstance(this ScriptComponent script, Prefab sourc
while (secondsCountdown > 0f)
{
await script.Script.NextFrame();
secondsCountdown -= (float)script.Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)script.Game.UpdateTime.WarpElapsed.TotalSeconds;
}

// Remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Update()

public void UpdateAnimation()
{
var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationMatrix(Matrix.RotationY(spinSpeed * (float)(dt * Math.PI)));

if (!activated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void UpdateAnimation()
if (!activated)
return;

var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

animationTime += dt * 8;
var coinHeight = Math.Max(0, Math.Sin(animationTime));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override void Update()

public void UpdateAnimation()
{
var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

if (!activated)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private void UpdateWalking()
animationClipWalkLerp2 = AnimationRun;
}

// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
// This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration
long blendedMaxDuration = 0;
blendedMaxDuration =
Expand All @@ -132,7 +131,7 @@ private void UpdateWalking()

currentTicks = blendedMaxDuration == 0
? TimeSpan.Zero
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
blendedMaxDuration);

currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration);
Expand All @@ -142,7 +141,7 @@ private void UpdatePunching()
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationPunch.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);

if (updatedTicks < AnimationPunch.Duration.Ticks)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void Update()

private void Attack()
{
var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
attackCooldown = (attackCooldown > 0) ? attackCooldown - dt : 0f;

PunchCollision.Enabled = (attackCooldown > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Start()
public override void Update()
{
/// We can access Delta time through the static 'Game' object.
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;

// We update the total time
totalTime += deltaTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void Update()
DebugText.Print("Hold the 1 key down to rotate the blue teapot", new Int2(340, 500));
if (Input.IsKeyDown(Keys.D1))
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.3f * deltaTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Start()
public override void Update()
{
// Keep track of elapsed time
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
elapsedTime += deltaTime;

// In order to make use of the lerp method, we need to calculate the 'interpolation value': a value going from 0 to 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Update()
DebugText.Print("Hold the left mouse button down to rotate the blue teapot", new Int2(400, 600));
if (Input.IsMouseButtonDown(MouseButton.Left))
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.4f * deltaTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void CloneEntityAndAddToScene()
public override void Update()
{
// We use a simple timer
timer += (float)Game.UpdateTime.Elapsed.TotalSeconds;
timer += (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
if (timer > currentTimer)
{
// If the entities exist, we remove them from the scene
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override void Update()
{
if (startTransform != null && cameraLerpTimer < cameraLerpTime)
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
cameraLerpTimer += deltaTime;
var lerpTime = cameraLerpTimer / cameraLerpTime;
Camera.Transform.Position = Vector3.Lerp(startTransform.Position, targetTransform.Position, lerpTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Update()
// Note: Gamepad sticks can be a negative value. For this example we only check if the value is higher than 0
if (forward > 0)
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.6f * forward * deltaTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void UpdateMovement()
return;
}

var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
var curPosition = RegularCharacter.Transform.WorldMatrix.TranslationVector;
var nextWaypointPosition = waypoints[waypointIndex];
var distanceToWaypoint = Vector3.Distance(curPosition, nextWaypointPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void Update()
movement.X -= 1;
}

var delta = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var delta = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Position += movement * delta * MoveSpeed;
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/UI/GameMenu/GameMenu.Game/MainScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private async Task FillLifeBar()
{
await Script.NextFrame();

gaugePercentage = Math.Min(1f, gaugePercentage + (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.02f);
gaugePercentage = Math.Min(1f, gaugePercentage + (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.02f);

var gaugeCurrentRegion = lifebarGaugeImage.Region;
gaugeCurrentRegion.Width = gaugePercentage * gaugeBarRegion.Width;
Expand Down
Loading