import kandinsky as k import time import math # Paramètres width, height = 320, 240 # Dimensions de l'écran NumWorks gravity = 0.5 # Gravité bounce_factor = 0.7 # Facteur de rebond class Ball: def __init__(self, x, y, radius, color): self.x = x self.y = y self.radius = radius self.color = color self.vx = 0 self.vy = 0 def update(self): self.vy += gravity # Appliquer la gravité self.y += self.vy # Collision avec le sol if self.y + self.radius > height: self.y = height - self.radius self.vy = -self.vy * bounce_factor def draw(self): k.fill_rect(int(self.x), int(self.y), self.radius,self.radius, self.color) # Initialisation ball = Ball(width // 2, 50, 10, (255, 0, 0)) # Boucle principale def main(): while True: k.fill_rect(0, 0, width, height, (255, 255, 255)) # Effacer l'écran ball.update() ball.draw() time.sleep(0.05) # Pause pour animation # Lancer la simulation main()