-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (53 loc) · 1.82 KB
/
main.py
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
import pygame
import settings
from action import DoneAction
from translator import Translator
from universe import Universe
from coords import CoordConverter
from Render import Renderer
# from world import World
# from hero import Hero
# from editor import Editor
clock = pygame.time.Clock()
pygame.init()
# pygame.display.init() # initialization of display
display = (1000,1000) # display
screen = pygame.display.set_mode(display)
surface = pygame.Surface(display)
scale = (1,1)
moving = False
dragging = False
# world = World(surface_altitudes=[(0,1080)], blocks=[], bounce=0)
# hero = Hero(world=world, x=960, y=400, speed=15, velocity=15, ClimbSpeed=5)
# render = Renderer(surface, hero, x=0, y=0)
# editor = Editor(screen, world, render, hero)
# GameMode = False
# MapMode = True
universe = Universe()
# coords = CoordConverter(scale, ((0,0), display))
render = Renderer(screen, ((0,0), display), scale)
def main_loop():
translator = Translator(settings.TRANSLATION_MAP, DoneAction())
def collect_actions():
result = translator.translate_pressed(universe.mode)
for event in pygame.event.get():
universe.mouseCoord = pygame.mouse.get_pos()
print(universe.mouseCoord)
result += translator.translate_event(universe.mode, event)
return result
while True:
actions = collect_actions()
if any(action.is_done() for action in actions):
break
for action in actions:
action.change_universe(universe, render)
screen.fill((255,255,255))
render.draw(universe.surface_altitudes)
render.draw_hero(universe.hero) # NEW METHOD
pygame.display.flip()
universe.update()
# render_universe()
clock.tick(settings.FPS)
if __name__ == "__main__":
main_loop()
pygame.quit()