public virtual void Run() { ConectController(); while (true) { this.renderer.RenderAll(); //draw frame System.Threading.Thread.Sleep(100); //wait 0.5sec this.userInterface.ProcessInput(); //check if is pressed arrow,space and if is do the appropriate job this.renderer.ClearQueue(); //clear buffer foreach (var obj in this.allObjects) { obj.Move(); //move the object this.renderer.EnqueueForRendering(obj); //draw the object } CollisionDispatcher.HandleCollisions(this.movingObjects, this.staticObjects); List <GameObject> producedObjects = new List <GameObject>();//check if it has produced objects foreach (var obj in this.allObjects) { producedObjects.AddRange(obj.ProduceObjects()); } this.allObjects.RemoveAll(obj => obj.IsDestroyed);//delete murdered objects this.movingObjects.RemoveAll(obj => obj.IsDestroyed); this.staticObjects.RemoveAll(obj => obj.IsDestroyed); foreach (var obj in producedObjects)//add producuded objects { { this.AddObject(obj); } } }