diff options
author | rgraef <romangraef@gmail.com> | 2021-04-22 14:01:38 +0200 |
---|---|---|
committer | rgraef <romangraef@gmail.com> | 2021-04-22 14:01:38 +0200 |
commit | 7d56930630e75ddd26c28de4276bfe8482cbb075 (patch) | |
tree | 0335223ecdd62ccf0123fc3f0bde4c099496bc0f /txtgameengine/__main__.py | |
parent | 2b597ca9617fd424d0785afae15b9f7adc78ef70 (diff) | |
download | txtgameengine-7d56930630e75ddd26c28de4276bfe8482cbb075.tar.gz txtgameengine-7d56930630e75ddd26c28de4276bfe8482cbb075.tar.bz2 txtgameengine-7d56930630e75ddd26c28de4276bfe8482cbb075.zip |
ga yass poem
Diffstat (limited to 'txtgameengine/__main__.py')
-rw-r--r-- | txtgameengine/__main__.py | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/txtgameengine/__main__.py b/txtgameengine/__main__.py index 84d71ca..cc4c11c 100644 --- a/txtgameengine/__main__.py +++ b/txtgameengine/__main__.py @@ -1,31 +1,49 @@ import numpy as np -from .app import TxtGameApp +from .scenes import SceneTxtGameApp, Scene from OpenGL.GL import * -class TestApp(TxtGameApp): - def __init__(self): - super().__init__((640, 480), "OpenGL window") +class TriangleScene(Scene): + TRIANGLE_DATA = [ + -1.0, -1.0, 0.0, + 1.0, -1.0, 0.0, + 0.0, 1.0, 0.0, + ] - def init(self): - self.render.setup_vertex_arrays() - #self.platform.check_debug() - self.default_shaders = self.shaders.load_shaders( + def on_enter(self): + self.default_shaders = self.app.shaders.load_shaders( 'base_shaders/vertex.glsl', 'base_shaders/fragment.glsl') - self.tri_buffer = self.render.setup_triangle(np.array([ - -1.0, -1.0, 0.0, - 1.0, -1.0, 0.0, - 0.0, 1.0, 0.0, - ], np.float32)) - - def update(self, delta: float): - super().update(delta) + + self.tri_buffer = self.app.render.setup_triangle( + np.array(self.TRIANGLE_DATA, np.float32)) + self.t = 0 + + def update(self, delta): + self.t += delta + if self.t > 10: + self.push_scene(EvilTriangleScene) + self.t = 0 with self.default_shaders: - self.render.triangle(self.tri_buffer) - + self.app.render.triangle(self.tri_buffer) + + +class EvilTriangleScene(TriangleScene): + TRIANGLE_DATA = [ + -1.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 0.0, -1.0, 0.0, + ] + +class TestApp(SceneTxtGameApp): + MAIN_SCENE_T = TriangleScene + + def init(self): + super().init() + self.render.setup_vertex_arrays() + # self.platform.check_debug() if __name__ == '__main__': - a = TestApp() + a = TestApp((640, 480), "OpenGL window") a.start() |