Advertisement
Cassimus

Pileczka

May 24th, 2025
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System.Numerics;
  2. using Raylib_cs;
  3.  
  4. public class Pileczka
  5. {
  6.     public Vector2 Pozycja { get; private set; }
  7.     public Vector2 Predkosc { get; private set; }
  8.  
  9.     private const float grawitacja = 0.5f;
  10.     private const float wspolczynnikOdbicia = 0.95f;
  11.     private const int dlugoscSladu = 20;
  12.  
  13.     private float speed = 5f;
  14.     private List<Vector2> slad;
  15.  
  16.  
  17.     public Pileczka(Vector2 pozycja)
  18.     {
  19.         Pozycja = pozycja;
  20.         Random random = new Random();
  21.  
  22.         Predkosc = new Vector2(
  23.             ((float)random.NextDouble() * 2 - 1) * speed,
  24.             ((float)random.NextDouble() * 2 - 1) * speed
  25.             );
  26.     }
  27.  
  28.     public void Aktualizuj()
  29.     {
  30.         Vector2 nowaPredkosc = Predkosc;
  31.         nowaPredkosc.Y += grawitacja;
  32.  
  33.         Vector2 nowaPozycja = Pozycja + nowaPredkosc;
  34.  
  35.         Raylib.DrawCircleV(nowaPozycja, 10, Color.Yellow);
  36.  
  37.         if (nowaPozycja.Y > Raylib.GetScreenHeight())
  38.         {
  39.             nowaPredkosc.Y *= -1;
  40.         }
  41.  
  42.         Predkosc = nowaPredkosc;
  43.         Pozycja = nowaPozycja;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement