Skip to content

Instantly share code, notes, and snippets.

@guillaC
Created February 29, 2024 20:12
Show Gist options
  • Save guillaC/8896ac0409065bfa13362014a8dbc126 to your computer and use it in GitHub Desktop.
Save guillaC/8896ac0409065bfa13362014a8dbc126 to your computer and use it in GitHub Desktop.
texture SinScroll with Raylib
static void SinScroll(float offsetX, List<Texture2D> texturesList)
{
int startX = screenWidth;
int startY = screenHeight / 2;
float frequency = 3.3f; // Fréquence de l'ondulation
float baseAmplitude = 110f; // Amplitude de base de l'ondulation
Raylib.BeginBlendMode(BlendMode.Alpha);
for (int i = 0; i < texturesList.Count; i++)
{
float x = startX + (i * 21) + (offsetX * 50);
float amplitude = baseAmplitude * (startX - x) / startX;
float y = startY + (amplitude * MathF.Sin(frequency * x / 128.0f));
Texture2D texture = texturesList[i];
Rectangle destRect = new(x, y, texture.Width, texture.Height);
Raylib.DrawTexturePro(texture, new Rectangle(0, 0, texture.Width, texture.Height), destRect, Vector2.Zero, 0.0f, Color.RayWhite);
}
Raylib.EndBlendMode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment