mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-09 11:30:38 +00:00
Auto urgent commit.
This commit is contained in:
23
pygame/bouncing_ball/balle.py
Normal file
23
pygame/bouncing_ball/balle.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import pygame
|
||||
|
||||
class Balle :
|
||||
"""
|
||||
Definie une balle qui se deplace dans la fenetre ecran
|
||||
Attributs : rayon , xpos , ypos , xvit , yvit
|
||||
Methodes : deplace , affiche
|
||||
"""
|
||||
|
||||
def __init__ ( self ) :
|
||||
self.rayon = 10
|
||||
self.xpos = 300.0
|
||||
self.ypos = 400.0
|
||||
self.xvit = 4.5
|
||||
self.yvit = 3.0
|
||||
|
||||
def deplace ( self ) :
|
||||
self.xpos += self.xvit
|
||||
self.ypos += self.yvit
|
||||
if self.xpos + self.rayon > 600 or self.xpos - self.rayon < 0:
|
||||
self.xvit = - self.xvit
|
||||
elif self.ypos + self.rayon > 800 or self.ypos - self.rayon < 0:
|
||||
self.yvit = - self.yvit
|
||||
Reference in New Issue
Block a user