From 3e83c636ee4b3b17cb41eaea261b9c6c1a37995d Mon Sep 17 00:00:00 2001 From: Roz K Date: Fri, 23 Dec 2022 06:36:24 +0100 Subject: [PATCH] A little bit of clenaup. --- game/batch.py | 1 - game/game.py | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/game/batch.py b/game/batch.py index c099ec9..327cf8a 100644 --- a/game/batch.py +++ b/game/batch.py @@ -14,7 +14,6 @@ # along with this program. If not, see . from ctypes import c_ubyte, c_uint, POINTER -from array import array from engine import ( INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, create_batch, draw_batch, destroy_batch) diff --git a/game/game.py b/game/game.py index d44633e..3744743 100644 --- a/game/game.py +++ b/game/game.py @@ -20,12 +20,12 @@ from ctypes import Structure from engine import * from game import math -from game import generator from game import shader -from game import resources -from game import batch from game import triangles from game import sea +from game.generator import Generator +from game.resources import RuntimeArchive +from game.batch import Batch from game.camera import Camera from game.environment import Environment @@ -42,9 +42,9 @@ sun_power = 1.0 def main(): print("Generating terrain...") - gen_begin = time.process_time() - generated = generator.Generator(256) - gen_end = time.process_time() + gen_begin = time.thread_time() + generated = Generator(256) + gen_end = time.thread_time() print("Done: ", round(gen_end - gen_begin, 2), "seconds") print("Initializing...") @@ -66,7 +66,7 @@ def main(): tests_normalmap_sampler = resolve_input(tests_shader, b'u_normal_sampler') print("Loading resources...") - archive = resources.RuntimeArchive.load('data/rk_island.rkar') + archive = RuntimeArchive.load('data/rk_island.rkar') print("Building tiles...") tiles_texture = archive.get_texture('tiles') @@ -79,7 +79,7 @@ def main(): rock_model = archive.get_model('rock') mud_model = archive.get_model('mud') lava_model = archive.get_model('lava') - terrain_batch = batch.Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT), vec3) + terrain_batch = Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT), vec3) #TODO: generator & for real vc = generated.volcano_c @@ -112,7 +112,7 @@ def main(): model = rock_model model.spawn(terrain_batch, vec3(float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0)) - class testsparams(Structure): + class TestsParams(Structure): _fields_ = ('translation', vec3), ('orientation', vec3) tests_texture = archive.get_texture('tests') @@ -121,14 +121,14 @@ def main(): blob_model = archive.get_model('blob') cube_model = archive.get_model('cube') clouds_model = archive.get_model('clouds') - tests_batch = batch.Batch(tests_vertices, 3, - params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE), testsparams) + tests_batch = Batch(tests_vertices, 3, + params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE), TestsParams) blob_spawn_translation = vec3(-100.0, -500.0, 0.0) cube_spawn_translation = vec3(100.0, -500.0, 0.0) blob_id = blob_model.spawn(tests_batch, - testsparams(blob_spawn_translation, vec3(*math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0))))) - cube_id = cube_model.spawn(tests_batch, testsparams(cube_spawn_translation, vec3_forward)) - clouds_id = clouds_model.spawn(tests_batch, testsparams(vec3(0.0, 0.0, 32.0), vec3_forward)) + TestsParams(blob_spawn_translation, vec3(*math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0))))) + cube_id = cube_model.spawn(tests_batch, TestsParams(cube_spawn_translation, vec3_forward)) + clouds_id = clouds_model.spawn(tests_batch, TestsParams(vec3(0.0, 0.0, 32.0), vec3_forward)) sea_phase = resolve_input(sky_shader, b'u_sea_phase') sea_polar_textures = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png'))