Add project files.

This commit is contained in:
maxwes08
2025-10-21 10:47:45 +02:00
parent a21be65109
commit f4deaadb57
8 changed files with 305 additions and 0 deletions

39
Pillar.cs Normal file
View File

@@ -0,0 +1,39 @@
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;
}
}