-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
79 lines (64 loc) · 2.85 KB
/
Copy pathmain.py
File metadata and controls
79 lines (64 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from ecs.display.display import DisplaySystem
from ecs.display.display_component import DisplayComponent
from ecs.action.action import ActionSystem
from ecs.action.action_component import ActionComponent
from structs.actor import Actor
from structs.player import Player
from ecs.input.input import InputSystem
from ecs.input.input_component import InputComponent
from ecs.level.level import LevelSystem
from ecs.camera.camera import CameraSystem
from ecs.camera.camera_component import CameraComponent
from ecs.fov.fov import FovSystem
from ecs.fov.fov_component import FovComponent
from ecs.ai.ai import AiSystem
from structs.game_states import GameStates
from settings import *
from ecs.container import Container
import pygame
class SiliconBlood:
def __init__(self):
pygame.init()
pygame.display.set_caption(TITLE)
pygame.display.set_icon(S_PLAYER)
pygame.key.set_repeat(200, 40)
self.display = pygame.display.set_mode((WIDTH, HEIGHT))
self.clock = pygame.time.Clock()
self.quit = False
self.level_system = LevelSystem(1)
self.camera_system = CameraSystem()
self.fov_system = FovSystem(self.level_system.level)
self.display_system = DisplaySystem(self.display, self.camera_system, self.level_system.level)
self.action_system = ActionSystem(self.level_system.level)
self.ai_system = AiSystem(self.level_system.level)
self.input_system = InputSystem()
self.player = Player(DisplayComponent(S_PLAYER,
self.level_system.map.spawn[0],
self.level_system.map.spawn[1],
alpha=True),
ActionComponent(),
InputComponent(),
CameraComponent(),
FovComponent(self.fov_system.fov_map),
name="player")
self.container = Container()
self.container.add_system(self.action_system)
self.container.add_system(self.ai_system)
self.container.add_system(self.input_system)
self.container.add_system(self.display_system)
self.container.add_system(self.level_system)
self.container.add_system(self.fov_system)
self.container.add_entity(self.player)
for entity in self.level_system.map.entities:
self.container.add_entity(entity)
def game_loop(self):
self.container.update()
self.player.get(FovComponent).fov_recalculate = True
while not self.quit:
self.container.update()
if self.player.get(ActionComponent).action == "quit":
self.quit = True
pygame.display.flip()
self.clock.tick(FPS)
if __name__ == '__main__':
SiliconBlood().game_loop()