using SFML.Graphics; class Pillar { public Sprite Top; public Sprite Bottom; public float X; public Pillar(Texture topTex, Texture bottomTex, float startX, float gapY, float gapHeight) { X = startX; Top = new Sprite(topTex) { Scale = new SFML.System.Vector2f(2f, 2f) }; Bottom = new Sprite(bottomTex) { Scale = new SFML.System.Vector2f(2f, 2f) }; Top.Position = new SFML.System.Vector2f(X, gapY - gapHeight / 2f - topTex.Size.Y * Top.Scale.Y); Bottom.Position = new SFML.System.Vector2f(X, gapY + gapHeight / 2f); } public void Update(float deltaTime, float speed) { X -= speed * deltaTime; Top.Position = new SFML.System.Vector2f(X, Top.Position.Y); Bottom.Position = new SFML.System.Vector2f(X, Bottom.Position.Y); } public void Draw(RenderWindow window) { window.Draw(Top); window.Draw(Bottom); } public bool IsOffscreen(float screenWidth) { // Rightmost point of the pillar float pillarRightEdge = X + Top.Texture.Size.X * Top.Scale.X; return pillarRightEdge < 0; } }