public override void OnUpdate() { // time between updates float dt = stopwatch.ElapsedMilliseconds; foreach (BasePhysicObject pyhsicObject in AllObjects.OfType <BasePhysicObject>()) { pyhsicObject.ApplyForce(Gravity, dt); } distanceTraveled += previousPos.X - player3.Position.X; previousPos = new Vector2(player3.Position.X, 0); if (SpacePressed) { player3.ApplyForce(Jump, dt); } CameraPosition.X = -player3.Position.X + Resolution.X / 2; text.Position.X = player3.Position.X - 15; text.Position.Y = 15; text.Text = distanceTraveled.ToString(); stopwatch.Restart(); }
protected void Initialize(AllObjects allObjects) { AddRange(allObjects.OfType <AccessObject>().Select(o => new AccessObjectModel(o))); }
public IEnumerable <T> Get <T>() where T : GameObject, new() { return(AllObjects.OfType <T>()); }