From cbae4ec0e7e0a1f69f501ee6f8e84543e77e0679 Mon Sep 17 00:00:00 2001 From: Roz K Date: Wed, 4 Jan 2023 09:38:27 +0100 Subject: [PATCH] Cleanup game script. --- game/game.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/game/game.py b/game/game.py index 2c21dc0..a349cdc 100644 --- a/game/game.py +++ b/game/game.py @@ -129,16 +129,15 @@ def create_scene(keyboard, mouse): print("Building tiles...") tiles_texture = Texture(*archive.get_texture('tiles')) - tiles_vertices_data = archive.get_vertices('tiles') - tiles_vertices = Vertices(*tiles_vertices_data) - water_mesh = tiles_vertices_data.get_mesh('water') - sand_mesh = tiles_vertices_data.get_mesh('sand') - grass_mesh = tiles_vertices_data.get_mesh('grass') - forest_mesh = tiles_vertices_data.get_mesh('forest') - rock_mesh = tiles_vertices_data.get_mesh('rock') - mud_mesh = tiles_vertices_data.get_mesh('mud') - lava_mesh = tiles_vertices_data.get_mesh('lava') - tiles_batch = Batch(tiles_vertices, generated.size ** 2, translation = PARAM_FORMAT_VEC3_SHORT) + tiles_vertices = archive.get_vertices('tiles') + water_mesh = tiles_vertices.get_mesh('water') + sand_mesh = tiles_vertices.get_mesh('sand') + grass_mesh = tiles_vertices.get_mesh('grass') + forest_mesh = tiles_vertices.get_mesh('forest') + rock_mesh = tiles_vertices.get_mesh('rock') + mud_mesh = tiles_vertices.get_mesh('mud') + lava_mesh = tiles_vertices.get_mesh('lava') + tiles_batch = Batch(Vertices(*tiles_vertices), generated.size ** 2, translation = PARAM_FORMAT_VEC3_SHORT) #TODO: generator & for real vc = generated.volcano_c @@ -175,12 +174,11 @@ def create_scene(keyboard, mouse): tiles_batch.freeze(flags = True, mesh = True, translation = True) tests_texture = Texture(*archive.get_texture('tests')) - tests_vertices_data = archive.get_vertices('tests') - tests_vertices = Vertices(*tests_vertices_data) - blob_mesh = tests_vertices_data.get_mesh('blob') - cube_mesh = tests_vertices_data.get_mesh('cube') - clouds_mesh = tests_vertices_data.get_mesh('clouds') - tests_batch = Batch(tests_vertices, 3, + tests_vertices = archive.get_vertices('tests') + blob_mesh = tests_vertices.get_mesh('blob') + cube_mesh = tests_vertices.get_mesh('cube') + clouds_mesh = tests_vertices.get_mesh('clouds') + tests_batch = Batch(Vertices(*tests_vertices), 3, translation = PARAM_FORMAT_VEC3_FLOAT, orientation = PARAM_FORMAT_MAT3_INT10 | PARAM_FORMAT_NORMALIZE) blob_forward = math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0)) @@ -192,8 +190,8 @@ def create_scene(keyboard, mouse): tests_batch.fill() tests_batch.freeze(flags = True, mesh = True) - sea_polar_textures = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png')) - sea_detail_texture = sea.load_detail_texture('data/sea_bump.png') + sea_polar = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png')) + sea_detail = sea.load_detail_texture('data/sea_bump.png') sea_triangles = sea.sea_triangles(64, proj_far_z - 0.1, proj_ratio) assert tiles_shader.u_height_sampler == tests_shader.u_height_sampler @@ -215,8 +213,7 @@ def create_scene(keyboard, mouse): PerfGroup('tests_batch', DrawNode(tests_batch))))), FuncNode(update_sea, (camera, sea_phase)), - TextureGroup( - {sea_shader.u_polar_sampler: sea_polar_textures, sea_shader.u_detail_sampler: sea_detail_texture}, + TextureGroup({sea_shader.u_polar_sampler: sea_polar, sea_shader.u_detail_sampler: sea_detail}, ShaderGroup(sea_shader, InputNode(sea_shader, camera, environment, sea_phase), PerfGroup('sea_triangles', @@ -228,14 +225,14 @@ def loop(display): mouse = Mouse(events, wheel = 60, wheel_min = 20) scene = create_scene(keyboard, mouse) print("Running... Ctrl+c to quit") - time = Time() try: + time = Time() while not keyboard.quit: events.update() - time.update() clear_buffer(True, True, True) scene.draw(time) swap_buffers(display) + time.update() except KeyboardInterrupt: pass