From 56ee2c6a658ac978ff64f77cc4a9c982ac5583fa Mon Sep 17 00:00:00 2001 From: Quattro-Bajeena Date: Sun, 22 Aug 2021 19:30:13 +0200 Subject: [PATCH] Completed the app --- .gitignore | 1 + map_viewer_app.py | 2 +- xgl.py | 27 ++++++++++++++++----------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 4a50f0d..0cf937e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ STRIPCD1/ +output/ .vscode/* !.vscode/settings.json diff --git a/map_viewer_app.py b/map_viewer_app.py index f393571..2c440ea 100644 --- a/map_viewer_app.py +++ b/map_viewer_app.py @@ -10,7 +10,7 @@ def lanch_viewer(fileIndex): model = load_level(fileIndex) - map_viewer = MapViewer(model) + map_viewer = MapViewer(model, debug=False) map_viewer.main_loop() sg.theme('DarkBrown4') diff --git a/xgl.py b/xgl.py index ca1ca87..efa1332 100644 --- a/xgl.py +++ b/xgl.py @@ -956,7 +956,8 @@ def saveModel(path : Path, model): class MapViewer: - def __init__(self, model): + def __init__(self, model, debug = False): + self.debug = debug self.model = model self.initialize() @@ -966,8 +967,10 @@ def initialize(self): icon = pygame.image.load(Path(__file__).parent / "Resources" / "xenogears logo.png") pygame.init() - - resolution = {'x':1080, 'y' : 1080} + if self.debug: + resolution = {'x':1080, 'y' : 1080} + else: + resolution = {'x':1792, 'y' : 1008} screen = pygame.display.set_mode((resolution['x'], resolution['y']), HWSURFACE|DOUBLEBUF|OPENGL) pygame.display.set_caption("Map Viewer") @@ -1005,9 +1008,11 @@ def initialize(self): self.pos_z = -2000 self.object = OpenGLObject(self.model) - + self.normal_speed_min = 5 + self.sprint_speed_min = 15 + self.normal_speed = 25 - self.sprint_speed = 70 + self.sprint_speed = 75 self.LOOK_SPEED = 0.2 self.speed = self.normal_speed @@ -1112,11 +1117,11 @@ def events(self): # elif event.key == pygame.K_c: # saveModel(Path(f"level{fileIndex}.dae"), model) elif event.type == MOUSEWHEEL: - self.normal_speed += 4 * event.y - self.sprint_speed += 4 * event.y + self.normal_speed += 3 * event.y + self.sprint_speed += 3 * event.y - self.normal_speed = max(0, self.normal_speed) - self.sprint_speed = max(0, self.sprint_speed) + self.normal_speed = max(self.normal_speed_min, self.normal_speed) + self.sprint_speed = max(self.sprint_speed_min, self.sprint_speed) @@ -1143,7 +1148,7 @@ def render(self): def load_level(fileIndex): - print("loading archive...") + print(f"loading archive {fileIndex}...") diskIndex = 1 # there are disk 1 and disk 2 dirIndex = 11 # 0-based index @@ -1184,5 +1189,5 @@ def load_level(fileIndex): if __name__ == '__main__': model = load_level(1) - map_viewer = MapViewer(model) + map_viewer = MapViewer(model, debug=True) map_viewer.main_loop() \ No newline at end of file