Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Feat/refactor #4

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ball_release_event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from game import Game
from stoppable_thread import StoppableThread
from vector import Vector
from math import (ceil, atan, pi, cos, sin)
from math import (ceil, atan, cos, sin)
import pygame

class BallReleaseEventListener(EventListener):
Expand Down
8 changes: 7 additions & 1 deletion game.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pygame
import sys

from event_listener import EventListener
from player import Player
from element import Element
from window import Window

from event_listener import EventListener
from drag_event_listener import DragEventListener
from ball_release_event_listener import BallReleaseEventListener

class Game():
def __init__(self, screen:pygame.Surface, img_location:str, sound_location:str) -> None:
# get the actual display screen.
Expand Down Expand Up @@ -38,6 +41,9 @@ def __init__(self, screen:pygame.Surface, img_location:str, sound_location:str)
self.__window.register_element("ball", Element(ball, 200, 400))
# register the placeholder ball.
self.__window.register_element("placeholder_ball", Element(placeholder_ball, 200, 400))
# listen to events.
self.listen(pygame.MOUSEMOTION, DragEventListener())
self.listen(pygame.MOUSEBUTTONUP, BallReleaseEventListener())
def get_window(self) -> Window:
"""
:return: the game's window.
Expand Down
6 changes: 0 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import pygame

from game import Game
from drag_event_listener import DragEventListener
from ball_release_event_listener import BallReleaseEventListener

# init pygame.
pygame.init()
Expand All @@ -16,9 +13,6 @@
screen = pygame.display.set_mode((1024,640))
# create a new instance of the Game.
game = Game(screen, "img/", None)
# listen to events.
game.listen(pygame.MOUSEMOTION, DragEventListener())
game.listen(pygame.MOUSEBUTTONUP, BallReleaseEventListener())
# register dummy player.
game.register_player("Yanis")
# setup the game.
Expand Down