Syncing with the game module

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2021-05-17 02:38:27 +02:00
parent e1f4f80c8b
commit a00e90424c

View File

@@ -65,31 +65,52 @@ int main(int argc, char **argv)
Game->initECS(); Game->initECS();
ECSEntityID playerBox = ECS->createEntity(); ECSEntityID playerBox = ECS->createEntity();
ECSEntityID childBox = ECS->createChild(playerBox); ECSEntityID childBox = ECS->createEntity();
ECS->addChild(playerBox, childBox);
ECSEntityID ground = ECS->createEntity(); ECSEntityID ground = ECS->createEntity();
ScriptHandle childBoxScript = Script->new("Entity1Script",
"this.on_init = function () "
" this.custom_eulerangles = Vec3:new() "
" this.custom_angularvelocity = Vec3:new(0, 0.01, 0) "
"end "
" "
"this.on_fixedupdate = function () "
" if Input.getKeyDown(Input.KeyCode.Left) then "
" this.custom_eulerangles:add(Vec3:new(0,0.01,0)) "
" end "
" if Input.getKeyDown(Input.KeyCode.Right) then "
" this.custom_eulerangles:sub(Vec3:new(0,0.01,0)) "
" end "
" this.eulerAngles = this.custom_eulerangles "
"end "
);
ScriptHandle childBoxScript = Script->new("Entity1Script", "");
ScriptHandle playerBoxScript = Script->new("Entity2Script", ScriptHandle playerBoxScript = Script->new("Entity2Script",
"this.on_update = function () \n" "this.on_collisionenter = function(other) "
" rb = this:getComponent(Rigidbody) \n" " other.position = other.position + Vec3:new(0.2, 0, 0) "
" if Input.getKeyDown(Input.KeyCode.Space) then \n" "end "
" this.position = Vec3:new(-1, 5, -10) \n" " "
" end \n" "this.on_update = function () "
" if Input.getKeyDown(Input.KeyCode.D) then \n" " rb = this:getComponent(Rigidbody) "
" rb:addForce(Vec3:new(10, 0, 0)) \n" " if Input.getKeyDown(Input.KeyCode.Space) then "
" end \n" " rb:addForce(Vec3:new(0, 100, 0)) "
" if Input.getKeyDown(Input.KeyCode.A) then \n" " end "
" rb:addForce(Vec3:new(-10, 0, 0)) \n" " if Input.getKeyDown(Input.KeyCode.D) then "
" end \n" " rb:addForce(Vec3:new(10, 0, 0)) "
" if Input.getKeyDown(Input.KeyCode.W) then \n" " end "
" rb:addForce(Vec3:new(0, 0, -10)) \n" " if Input.getKeyDown(Input.KeyCode.A) then "
" end \n" " rb:addForce(Vec3:new(-10, 0, 0)) "
" if Input.getKeyDown(Input.KeyCode.S) then \n" " end "
" rb:addForce(Vec3:new(0, 0, 10)) \n" " if Input.getKeyDown(Input.KeyCode.W) then "
" end \n" " rb:addForce(Vec3:new(0, 0, -10)) "
"end \n" " end "
" if Input.getKeyDown(Input.KeyCode.S) then "
" rb:addForce(Vec3:new(0, 0, 10)) "
" end "
"end "
); );
Script->addToEntity(playerBox, playerBoxScript); Script->addToEntity(playerBox, playerBoxScript);
@@ -157,9 +178,9 @@ int main(int argc, char **argv)
evol_unloadmodule(physics_module); evol_unloadmodule(physics_module);
evol_unloadmodule(input_module); evol_unloadmodule(input_module);
evol_unloadmodule(asset_module); evol_unloadmodule(asset_module);
evol_unloadmodule(window_module);
evol_unloadmodule(ecs_module); evol_unloadmodule(ecs_module);
evol_unloadmodule(script_module); evol_unloadmodule(script_module);
evol_unloadmodule(window_module);
evol_deinit(engine); evol_deinit(engine);
evol_destroy(engine); evol_destroy(engine);
return 0; return 0;