Better input node.
This commit is contained in:
parent
dd786ef2b4
commit
7c2d3d81ae
10
game/game.py
10
game/game.py
@ -162,16 +162,14 @@ def create_scene(keyboard, mouse):
|
|||||||
FuncNode(update_camera, (mouse, camera, environment)),
|
FuncNode(update_camera, (mouse, camera, environment)),
|
||||||
TextureNode({0: tiles_texture},
|
TextureNode({0: tiles_texture},
|
||||||
ShaderNode(tiles_shader,
|
ShaderNode(tiles_shader,
|
||||||
InputNode(tiles_shader, camera),
|
InputNode(tiles_shader, camera, environment),
|
||||||
InputNode(tiles_shader, environment),
|
|
||||||
DrawNode(tiles_batch)
|
DrawNode(tiles_batch)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
FuncNode(update_tests, (blob, cube, clouds)),
|
FuncNode(update_tests, (blob, cube, clouds)),
|
||||||
TextureNode({0: tests_texture},
|
TextureNode({0: tests_texture},
|
||||||
ShaderNode(tests_shader,
|
ShaderNode(tests_shader,
|
||||||
InputNode(tests_shader, camera),
|
InputNode(tests_shader, camera, environment),
|
||||||
InputNode(tests_shader, environment),
|
|
||||||
DrawNode(tests_batch)
|
DrawNode(tests_batch)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -179,9 +177,7 @@ def create_scene(keyboard, mouse):
|
|||||||
FuncNode(update_sea, (camera, sea_phase)),
|
FuncNode(update_sea, (camera, sea_phase)),
|
||||||
TextureNode({0: sea_polar_textures, 1: sea_detail_texture},
|
TextureNode({0: sea_polar_textures, 1: sea_detail_texture},
|
||||||
ShaderNode(sea_shader,
|
ShaderNode(sea_shader,
|
||||||
InputNode(sea_shader, camera),
|
InputNode(sea_shader, camera, environment, sea_phase),
|
||||||
InputNode(sea_shader, environment),
|
|
||||||
InputNode(sea_shader, sea_phase),
|
|
||||||
DrawNode(sea_triangles)
|
DrawNode(sea_triangles)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -53,37 +53,33 @@ class ShaderNode(Node):
|
|||||||
Node.draw(self, time)
|
Node.draw(self, time)
|
||||||
self._shader.unselect()
|
self._shader.unselect()
|
||||||
|
|
||||||
class InputNode(Node):
|
class InputNode:
|
||||||
__slots__ = '_shader', '_input'
|
__slots__ = '_shader', '_inputs'
|
||||||
|
|
||||||
def __init__(self, shader, input, *subnodes):
|
def __init__(self, shader, *inputs):
|
||||||
Node.__init__(self, *subnodes)
|
|
||||||
self._shader = shader
|
self._shader = shader
|
||||||
self._input = input
|
self._inputs = inputs
|
||||||
|
|
||||||
def draw(self, time):
|
def draw(self, time):
|
||||||
self._input.set_inputs(self._shader)
|
shader = self._shader
|
||||||
Node.draw(self, time)
|
for input in self._inputs:
|
||||||
|
input.set_inputs(shader)
|
||||||
|
|
||||||
class DrawNode(Node):
|
class DrawNode:
|
||||||
__slots__ = '_drawable'
|
__slots__ = '_drawable'
|
||||||
|
|
||||||
def __init__(self, drawable, *subnodes):
|
def __init__(self, drawable):
|
||||||
Node.__init__(self, *subnodes)
|
|
||||||
self._drawable = drawable
|
self._drawable = drawable
|
||||||
|
|
||||||
def draw(self, time):
|
def draw(self, time):
|
||||||
self._drawable.draw()
|
self._drawable.draw()
|
||||||
Node.draw(self, time)
|
|
||||||
|
|
||||||
class FuncNode(Node):
|
class FuncNode:
|
||||||
__slots__ = '_func', '_params'
|
__slots__ = '_func', '_params'
|
||||||
|
|
||||||
def __init__(self, func, params, *subnodes):
|
def __init__(self, func, params):
|
||||||
Node.__init__(self, *subnodes)
|
|
||||||
self._func = func
|
self._func = func
|
||||||
self._params = params
|
self._params = params
|
||||||
|
|
||||||
def draw(self, time):
|
def draw(self, time):
|
||||||
self._func(time, *self._params)
|
self._func(time, *self._params)
|
||||||
Node.draw(self, time)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user