2021-03-04 14:07:44 +01:00
|
|
|
import pygame
|
|
|
|
|
2021-03-15 13:31:25 +01:00
|
|
|
from settings import SCREEN_WIDTH, SCREEN_HEIGHT
|
|
|
|
from survival.camera import Camera
|
2021-03-04 15:02:42 +01:00
|
|
|
from survival.game_map import GameMap
|
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-03-04 14:07:44 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
pygame.init()
|
|
|
|
|
2021-03-15 13:31:25 +01:00
|
|
|
win = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
2021-03-04 14:07:44 +01:00
|
|
|
pygame.display.set_caption("AI Project")
|
|
|
|
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
|
2021-03-15 13:31:25 +01:00
|
|
|
game_map = GameMap(int(SCREEN_WIDTH / 32) * 2, 2 * int(SCREEN_HEIGHT / 32) + 1)
|
|
|
|
camera = Camera(game_map.width * 32, game_map.height * 32, win)
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-03-28 18:42:04 +02:00
|
|
|
world = WorldGenerator().create_world(camera, game_map)
|
2021-03-28 18:56:32 +02:00
|
|
|
player = PlayerGenerator().create_player(world, game_map)
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-03-28 18:42:04 +02:00
|
|
|
ResourceGenerator(world, game_map).generate_resources()
|
2021-03-28 18:05:52 +02:00
|
|
|
|
2021-03-04 14:07:44 +01:00
|
|
|
run = True
|
|
|
|
|
|
|
|
while run:
|
|
|
|
# Set the framerate
|
2021-03-14 20:23:38 +01:00
|
|
|
ms = clock.tick(60)
|
2021-03-04 14:07:44 +01:00
|
|
|
|
|
|
|
events = pygame.event.get()
|
|
|
|
|
|
|
|
for event in events:
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
run = False
|
|
|
|
|
|
|
|
keys = pygame.key.get_pressed()
|
|
|
|
|
2021-03-28 18:42:04 +02:00
|
|
|
win.fill((0, 0, 0))
|
|
|
|
game_map.draw(camera)
|
|
|
|
world.process(ms)
|
|
|
|
pygame.display.update()
|