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
|
2021-03-28 18:05:52 +02:00
|
|
|
from survival import esper
|
2021-03-15 13:31:25 +01:00
|
|
|
from survival.camera import Camera
|
2021-03-28 18:05:52 +02:00
|
|
|
from survival.components.camera_target_component import CameraTargetComponent
|
|
|
|
from survival.components.input_component import InputComponent
|
|
|
|
from survival.components.movement_component import MovementComponent
|
|
|
|
from survival.components.position_component import PositionComponent
|
|
|
|
from survival.components.sprite_component import SpriteComponent
|
2021-03-04 15:02:42 +01:00
|
|
|
from survival.game_map import GameMap
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.player_generator import PlayerGenerator
|
2021-03-28 18:42:04 +02:00
|
|
|
from survival.resource_generator import ResourceGenerator
|
2021-03-28 18:05:52 +02:00
|
|
|
from survival.systems.camera_system import CameraSystem
|
|
|
|
from survival.systems.collision_system import CollisionSystem
|
|
|
|
from survival.systems.draw_system import DrawSystem
|
|
|
|
from survival.systems.input_system import InputSystem
|
|
|
|
from survival.systems.movement_system import MovementSystem
|
2021-03-28 18:42:04 +02:00
|
|
|
from survival.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()
|