From a8292a969047773156f8374f5c41ae3192e24d99 Mon Sep 17 00:00:00 2001 From: aliaksei-kudravets Date: Thu, 10 Mar 2022 15:43:03 +0300 Subject: [PATCH 1/5] tmp commit --- main.py | 2 ++ requirements.txt | 0 2 files changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/main.py b/main.py index 96a18ce..e03acd9 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,8 @@ import pygame from map import preparedMap from agent import trashmaster +# import os +# os.environ["SDL_VIDEODRIVER"] = "dummy" pygame.init() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 From a171377b3eba8d5a943c4b566e2cd6104b95f715 Mon Sep 17 00:00:00 2001 From: aliaksei-kudravets Date: Thu, 10 Mar 2022 15:45:49 +0300 Subject: [PATCH 2/5] add requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index e69de29..b4fe918 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +pygame==2.1.2 From 7c2f7596d517eda47b1d7a02a7599e901f330ba9 Mon Sep 17 00:00:00 2001 From: aliaksei-kudravets Date: Thu, 10 Mar 2022 15:53:41 +0100 Subject: [PATCH 3/5] tmp commit --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index e03acd9..31c2b4d 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,14 @@ import pygame from map import preparedMap from agent import trashmaster -# import os -# os.environ["SDL_VIDEODRIVER"] = "dummy" + +class WalleGame(): + def __init__(self): + pass + + + pygame.init() #config From d7214199f28d92693a4375fb0d44ff92778a7dd8 Mon Sep 17 00:00:00 2001 From: aliaksei-kudravets Date: Thu, 10 Mar 2022 16:16:59 +0100 Subject: [PATCH 4/5] refactoring main.py --- agent.py | 1 - main.py | 79 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/agent.py b/agent.py index 63d3450..c87c891 100644 --- a/agent.py +++ b/agent.py @@ -5,7 +5,6 @@ class trashmaster(pygame.sprite.Sprite): def __init__(self): super().__init__() - self.images = [] self.image = pygame.image.load("resources/textures/trashmaster_blu.png") self.image = pygame.transform.scale(self.image, (16, 16)) diff --git a/main.py b/main.py index 31c2b4d..e707f7a 100644 --- a/main.py +++ b/main.py @@ -3,47 +3,56 @@ from map import preparedMap from agent import trashmaster -class WalleGame(): - def __init__(self): - pass - - - -pygame.init() - #config SCREEN_SIZE = [512, 512] BACKGROUND_COLOR = '#ffffff' -if __name__ == '__main__': +class WalleGame(): + + def __init__(self): + self.SCREEN_SIZE = [512, 512] + self.BACKGROUND_COLOR = '#ffffff' + + pygame.init() + pygame.display.set_caption('Wall-e') + + + self.screen = pygame.display.set_mode(SCREEN_SIZE) + self.screen.fill(pygame.Color(self.BACKGROUND_COLOR)) + + # krata + self.map = preparedMap(self.SCREEN_SIZE) + self.screen.blit(self.map, (0,0)) + + def update_window(self): + pygame.display.update() + + def draw_trashmaster(self, smieciara: trashmaster): + smieciara_list = pygame.sprite.Group() + smieciara_list.add(smieciara) + smieciara_list.draw(self.screen) + + - pygame.init() +def main(): + game = WalleGame() + game.update_window() + + smieciara_object = trashmaster() + game.draw_trashmaster(smieciara_object) - # tytul okna - pygame.display.set_caption('Wall-e') + game.update_window() - screen = pygame.display.set_mode(SCREEN_SIZE) - screen.fill(pygame.Color(BACKGROUND_COLOR)) - - # krata - map = preparedMap(SCREEN_SIZE) - screen.blit(map, (0,0)) - - # update okna - pygame.display.update() - -smieciara1 = trashmaster() -smieciara_list = pygame.sprite.Group() -smieciara_list.add(smieciara1) -smieciara_list.draw(screen) - -pygame.display.update() - -running = True -while running: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - running = False + running = True + + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + pygame.quit() + pygame.quit() -pygame.quit() + +if __name__ == '__main__': + main() \ No newline at end of file From e8d39b2e3315c059ac9c2224382aafee39795739 Mon Sep 17 00:00:00 2001 From: aliaksei-kudravets Date: Thu, 10 Mar 2022 16:18:06 +0100 Subject: [PATCH 5/5] refactoring main.py(2) --- main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/main.py b/main.py index e707f7a..d67bfa6 100644 --- a/main.py +++ b/main.py @@ -3,10 +3,6 @@ from map import preparedMap from agent import trashmaster -#config -SCREEN_SIZE = [512, 512] -BACKGROUND_COLOR = '#ffffff' - class WalleGame(): def __init__(self): @@ -17,7 +13,7 @@ class WalleGame(): pygame.display.set_caption('Wall-e') - self.screen = pygame.display.set_mode(SCREEN_SIZE) + self.screen = pygame.display.set_mode(self.SCREEN_SIZE) self.screen.fill(pygame.Color(self.BACKGROUND_COLOR)) # krata