From 4eb565d01b3d6ae45da793c7b6c8fe1fc7a9ab84 Mon Sep 17 00:00:00 2001 From: Jean Dupont Date: Wed, 8 Oct 2025 12:16:37 +0200 Subject: [PATCH 1/4] docs: :memo: Add docs all file part 1. Add docs all file part 1. --- src/entities/background.py | 11 +++++++++++ src/entities/entity.py | 27 +++++++++++++++++++++++++++ src/entities/floor.py | 11 +++++++++++ src/flappy.py | 22 ++++++++++++++++++++++ 4 files changed, 71 insertions(+) diff --git a/src/entities/background.py b/src/entities/background.py index 6e1226ed..a3d82c0f 100644 --- a/src/entities/background.py +++ b/src/entities/background.py @@ -3,6 +3,17 @@ class Background(Entity): + """ + Represents the background entity in the FlapPyBird game. + + This class is responsible for rendering the background image across the entire game window. + + Args: + config (GameConfig): The game configuration object containing window dimensions and image resources. + + Attributes: + Inherits all attributes from the Entity base class, including position and size. + """ def __init__(self, config: GameConfig) -> None: super().__init__( config, diff --git a/src/entities/entity.py b/src/entities/entity.py index 6ec067ce..9cb2e754 100644 --- a/src/entities/entity.py +++ b/src/entities/entity.py @@ -6,6 +6,33 @@ class Entity: + """ + Represents a game entity with position, size, image, and collision detection. + Attributes: + config (GameConfig): Game configuration object containing settings and screen. + x (float): X-coordinate of the entity's top-left corner. + y (float): Y-coordinate of the entity's top-left corner. + w (int): Width of the entity. + h (int): Height of the entity. + image (Optional[pygame.Surface]): Image representing the entity. + hit_mask (Optional[list[list[bool]]]): Pixel-perfect collision mask. + Additional attributes can be set via kwargs. + Methods: + update_image(image, w=None, h=None): + Updates the entity's image, hit mask, and optionally its size. + cx: + Returns the X-coordinate of the entity's center. + cy: + Returns the Y-coordinate of the entity's center. + rect: + Returns a pygame.Rect representing the entity's position and size. + collide(other): + Checks for collision with another entity, using pixel-perfect collision if available. + tick(): + Draws the entity and, if debug mode is enabled, draws its bounding box and position info. + draw(): + Draws the entity's image on the screen if available. + """ def __init__( self, config: GameConfig, diff --git a/src/entities/floor.py b/src/entities/floor.py index 95013f05..d70fe77d 100644 --- a/src/entities/floor.py +++ b/src/entities/floor.py @@ -3,6 +3,17 @@ class Floor(Entity): + """ + Represents the moving floor entity in the FlapPyBird game. + The Floor entity scrolls horizontally to simulate movement. It inherits from Entity and uses the base image. + The floor's position is updated in the `draw` method to create a looping effect, giving the illusion of continuous motion. + Attributes: + vel_x (int): The horizontal velocity of the floor. + x_extra (int): The extra width used for looping the floor image. + Methods: + stop(): Stops the floor's movement by setting its velocity to zero. + draw(): Updates the floor's position and draws it on the screen. + """ def __init__(self, config: GameConfig) -> None: super().__init__(config, config.images.base, 0, config.window.vh) self.vel_x = 4 diff --git a/src/flappy.py b/src/flappy.py index a8c87321..5b799580 100644 --- a/src/flappy.py +++ b/src/flappy.py @@ -18,6 +18,28 @@ class Flappy: + """ + Main class for the Flappy Bird game. + Handles game initialization, main loop, and transitions between game states: + splash screen, gameplay, and game over. + Attributes: + config (GameConfig): Configuration object containing game settings, resources, and state. + Methods: + __init__(): + Initializes pygame, sets up the display, and loads game resources. + async start(): + Main game loop. Cycles through splash, play, and game over states. + async splash(): + Displays the welcome splash screen and waits for user input to start the game. + check_quit_event(event): + Checks for quit events (window close or escape key) and exits the game. + is_tap_event(event): + Determines if the user has tapped/clicked/flapped to interact with the game. + async play(): + Runs the main gameplay loop, handling player movement, collision detection, and scoring. + async game_over(): + Handles the game over state, animates the player crash, and waits for user input to restart. + """ def __init__(self): pygame.init() pygame.display.set_caption("Flappy Bird") From b77f0b8e80bad929732bfd60daef30467fa81bcc Mon Sep 17 00:00:00 2001 From: Maxvoltaire <82141695+Maxvoltaire@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:31:08 +0200 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20:sparkles:=20Ajouter=20des=20fichie?= =?UTF-8?q?rs=20de=20configuration=20pour=20l'int=C3=A9gration=20continue?= =?UTF-8?q?=20et=20l'analyse=20de=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ sonar-project.propertie | 1 + 2 files changed, 28 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 sonar-project.propertie diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..bb617fda --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Build + +on: + push: + branches: + - main + + +jobs: + build: + name: Build and analyze + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: SonarSource/sonarqube-scan-action@v6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment. + # - uses: SonarSource/sonarqube-quality-gate-action@v1 + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/sonar-project.propertie b/sonar-project.propertie new file mode 100644 index 00000000..c649d5c1 --- /dev/null +++ b/sonar-project.propertie @@ -0,0 +1 @@ +sonar.projectKey=myproject \ No newline at end of file From dec0eabba39da3998da15e58c3d4055ce35ec189 Mon Sep 17 00:00:00 2001 From: Maxvoltaire <82141695+Maxvoltaire@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:31:53 +0200 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20:bug:=20Ajouter=20une=20nouvelle=20l?= =?UTF-8?q?igne=20=C3=A0=20la=20fin=20du=20fichier=20main.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index afbf6ae8..549b67fe 100644 --- a/main.py +++ b/main.py @@ -3,4 +3,4 @@ from src.flappy import Flappy if __name__ == "__main__": - asyncio.run(Flappy().start()) + asyncio.run(Flappy().start()) \ No newline at end of file From 1ee10552690954a14807b5c5f474c1cfb73dc437 Mon Sep 17 00:00:00 2001 From: Maxvoltaire <82141695+Maxvoltaire@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:33:30 +0200 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20:bug:=20Corriger=20la=20branche=20de?= =?UTF-8?q?=20d=C3=A9clenchement=20de=20'main'=20=C3=A0=20'master'=20dans?= =?UTF-8?q?=20le=20fichier=20build.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb617fda..748d1059 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build on: push: branches: - - main + - master jobs: