2021-03-04 14:07:44 +01:00
|
|
|
import pygame
|
|
|
|
|
2021-05-24 13:10:10 +02:00
|
|
|
from survival.components.inventory_component import InventoryComponent
|
2021-06-19 00:09:14 +02:00
|
|
|
from survival.game.game_map import GameMap
|
2021-05-21 20:14:00 +02:00
|
|
|
from survival.generators.building_generator import BuildingGenerator
|
2021-05-10 11:02:36 +02:00
|
|
|
from survival.generators.player_generator import PlayerGenerator
|
|
|
|
from survival.generators.resource_generator import ResourceGenerator
|
|
|
|
from survival.generators.world_generator import WorldGenerator
|
2021-06-19 18:04:59 +02:00
|
|
|
from survival.settings import SCREEN_WIDTH, SCREEN_HEIGHT
|
2021-05-24 13:10:10 +02:00
|
|
|
from survival.systems.draw_system import DrawSystem
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-05-24 13:10:10 +02:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
class Game:
|
|
|
|
def __init__(self):
|
|
|
|
self.world_generator = WorldGenerator(win, self.reset)
|
|
|
|
self.game_map, self.world, self.camera = self.world_generator.create_world()
|
|
|
|
self.run = True
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
def reset(self):
|
|
|
|
self.world_generator.reset_world()
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
def update(self, ms):
|
|
|
|
events = pygame.event.get()
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
for event in events:
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
self.run = False
|
|
|
|
if pygame.key.get_pressed()[pygame.K_DELETE]:
|
|
|
|
self.reset()
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
win.fill((0, 0, 0))
|
|
|
|
self.game_map.draw(self.camera)
|
|
|
|
self.world.process(ms)
|
|
|
|
pygame.display.update()
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
pygame.init()
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
pygame.font.init()
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
win = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
|
|
|
pygame.display.set_caption("AI Project")
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
clock = pygame.time.Clock()
|
|
|
|
game = Game()
|
2021-03-04 14:07:44 +01:00
|
|
|
|
2021-06-06 19:55:55 +02:00
|
|
|
while game.run:
|
|
|
|
game.update(clock.tick(60))
|