refactoring main.py
This commit is contained in:
parent
7c2f7596d5
commit
d7214199f2
1
agent.py
1
agent.py
@ -5,7 +5,6 @@ class trashmaster(pygame.sprite.Sprite):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
||||||
self.images = []
|
self.images = []
|
||||||
self.image = pygame.image.load("resources/textures/trashmaster_blu.png")
|
self.image = pygame.image.load("resources/textures/trashmaster_blu.png")
|
||||||
self.image = pygame.transform.scale(self.image, (16, 16))
|
self.image = pygame.transform.scale(self.image, (16, 16))
|
||||||
|
79
main.py
79
main.py
@ -3,47 +3,56 @@ from map import preparedMap
|
|||||||
from agent import trashmaster
|
from agent import trashmaster
|
||||||
|
|
||||||
|
|
||||||
class WalleGame():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
|
||||||
|
|
||||||
#config
|
#config
|
||||||
SCREEN_SIZE = [512, 512]
|
SCREEN_SIZE = [512, 512]
|
||||||
BACKGROUND_COLOR = '#ffffff'
|
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
|
game.update_window()
|
||||||
pygame.display.set_caption('Wall-e')
|
|
||||||
|
|
||||||
screen = pygame.display.set_mode(SCREEN_SIZE)
|
running = True
|
||||||
screen.fill(pygame.Color(BACKGROUND_COLOR))
|
|
||||||
|
while running:
|
||||||
# krata
|
for event in pygame.event.get():
|
||||||
map = preparedMap(SCREEN_SIZE)
|
if event.type == pygame.QUIT:
|
||||||
screen.blit(map, (0,0))
|
running = False
|
||||||
|
pygame.quit()
|
||||||
# update okna
|
pygame.quit()
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
pygame.quit()
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user