Minor Changes

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2021-05-29 01:26:18 +02:00
parent 9ae6c2707c
commit cf1b3c33a6

View File

@@ -60,6 +60,7 @@ init_scenes()
"end " "end "
" " " "
"this.on_fixedupdate = function () " "this.on_fixedupdate = function () "
" print('Scene0 OnFixedUpdate Entity #' .. this.entityID)"
" if Input.getKeyDown(Input.KeyCode.Left) then " " if Input.getKeyDown(Input.KeyCode.Left) then "
" this.custom_eulerangles:add(Vec3:new(0,0.01,0)) " " this.custom_eulerangles:add(Vec3:new(0,0.01,0)) "
" end " " end "
@@ -101,18 +102,18 @@ init_scenes()
"end " "end "
"this.on_fixedupdate = function() " "this.on_fixedupdate = function() "
/* " if Input.getKeyDown(Input.KeyCode.Up) then " */ " if Input.getKeyDown(Input.KeyCode.Up) then "
/* " this.position = this.position + Vec3:new(0, 1, 0) * this.speed " */ " this.position = this.position + Vec3:new(0, 1, 0) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Down) then " */ " if Input.getKeyDown(Input.KeyCode.Down) then "
/* " this.position = this.position - Vec3:new(0, 1, 0) * this.speed " */ " this.position = this.position - Vec3:new(0, 1, 0) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Right) then " */ " if Input.getKeyDown(Input.KeyCode.Right) then "
/* " this.position = this.position + Vec3:new(1, 0, 0) * this.speed " */ " this.position = this.position + Vec3:new(1, 0, 0) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Left) then " */ " if Input.getKeyDown(Input.KeyCode.Left) then "
/* " this.position = this.position - Vec3:new(1, 0, 0) * this.speed " */ " this.position = this.position - Vec3:new(1, 0, 0) * this.speed "
/* " end " */ " end "
"end " "end "
); );
@@ -152,7 +153,7 @@ init_scenes()
scenes[1] = Game->newScene(); scenes[1] = Game->newScene();
GameObject playerBox = Scene->createObject(scenes[1]); GameObject playerBox = Scene->createObject(scenes[1]);
GameObject childBox = Scene->createChildObject(scenes[1], playerBox); GameObject childBox = Scene->createObject(scenes[1]);
GameObject ground = Scene->createObject(scenes[1]); GameObject ground = Scene->createObject(scenes[1]);
GameObject camera = Scene->createCamera(scenes[1], EV_CAMERA_VIEWTYPE_PERSPECTIVE); GameObject camera = Scene->createCamera(scenes[1], EV_CAMERA_VIEWTYPE_PERSPECTIVE);
@@ -171,13 +172,14 @@ init_scenes()
"end " "end "
" " " "
"this.on_fixedupdate = function () " "this.on_fixedupdate = function () "
/* " if Input.getKeyDown(Input.KeyCode.Left) then " */ " print('Scene1 OnFixedUpdate Entity #' .. this.entityID)"
/* " this.custom_eulerangles:add(Vec3:new(0,0.01,0)) " */ " if Input.getKeyDown(Input.KeyCode.Left) then "
/* " end " */ " this.custom_eulerangles:add(Vec3:new(0,0.01,0)) "
/* " if Input.getKeyDown(Input.KeyCode.Right) then " */ " end "
/* " this.custom_eulerangles:sub(Vec3:new(0,0.01,0)) " */ " if Input.getKeyDown(Input.KeyCode.Right) then "
/* " end " */ " this.custom_eulerangles:sub(Vec3:new(0,0.01,0)) "
/* " this.eulerAngles = this.custom_eulerangles " */ " end "
" this.eulerAngles = this.custom_eulerangles "
"end " "end "
); );
@@ -187,22 +189,22 @@ init_scenes()
"end " "end "
" " " "
"this.on_update = function () " "this.on_update = function () "
/* " rb = this:getComponent(Rigidbody) " */ " rb = this:getComponent(Rigidbody) "
/* " if Input.getKeyDown(Input.KeyCode.Space) then " */ " if Input.getKeyDown(Input.KeyCode.Space) then "
/* " rb:addForce(Vec3:new(0, 100, 0)) " */ " rb:addForce(Vec3:new(0, 100, 0)) "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.D) then " */ " if Input.getKeyDown(Input.KeyCode.D) then "
/* " rb:addForce(Vec3:new(10, 0, 0)) " */ " rb:addForce(Vec3:new(10, 0, 0)) "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.A) then " */ " if Input.getKeyDown(Input.KeyCode.A) then "
/* " rb:addForce(Vec3:new(-10, 0, 0)) " */ " rb:addForce(Vec3:new(-10, 0, 0)) "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.W) then " */ " if Input.getKeyDown(Input.KeyCode.W) then "
/* " rb:addForce(Vec3:new(0, 0, -10)) " */ " rb:addForce(Vec3:new(0, 0, -10)) "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.S) then " */ " if Input.getKeyDown(Input.KeyCode.S) then "
/* " rb:addForce(Vec3:new(0, 0, 10)) " */ " rb:addForce(Vec3:new(0, 0, 10)) "
/* " end " */ " end "
"end " "end "
); );
@@ -212,18 +214,18 @@ init_scenes()
"end " "end "
"this.on_fixedupdate = function() " "this.on_fixedupdate = function() "
/* " if Input.getKeyDown(Input.KeyCode.Up) then " */ " if Input.getKeyDown(Input.KeyCode.Up) then "
/* " this.position = this.position - Vec3:new(0, 0, 1) * this.speed " */ " this.position = this.position - Vec3:new(0, 0, 1) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Down) then " */ " if Input.getKeyDown(Input.KeyCode.Down) then "
/* " this.position = this.position + Vec3:new(0, 0, 1) * this.speed " */ " this.position = this.position + Vec3:new(0, 0, 1) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Right) then " */ " if Input.getKeyDown(Input.KeyCode.Right) then "
/* " this.position = this.position + Vec3:new(1, 0, 0) * this.speed " */ " this.position = this.position + Vec3:new(1, 0, 0) * this.speed "
/* " end " */ " end "
/* " if Input.getKeyDown(Input.KeyCode.Left) then " */ " if Input.getKeyDown(Input.KeyCode.Left) then "
/* " this.position = this.position - Vec3:new(1, 0, 0) * this.speed " */ " this.position = this.position - Vec3:new(1, 0, 0) * this.speed "
/* " end " */ " end "
"end " "end "
); );
@@ -243,8 +245,9 @@ init_scenes()
RigidbodyHandle childRigidbody = Rigidbody->addToEntity(scenes[1], childBox, &(RigidbodyInfo) { RigidbodyHandle childRigidbody = Rigidbody->addToEntity(scenes[1], childBox, &(RigidbodyInfo) {
.type = EV_RIGIDBODY_KINEMATIC, .type = EV_RIGIDBODY_DYNAMIC,
.collisionShape = boxCollider, .collisionShape = boxCollider,
.mass = 1.0,
}); });
RigidbodyHandle playerRigidbody = Rigidbody->addToEntity(scenes[1], playerBox, &(RigidbodyInfo) { RigidbodyHandle playerRigidbody = Rigidbody->addToEntity(scenes[1], playerBox, &(RigidbodyInfo) {
@@ -290,7 +293,6 @@ int main(int argc, char **argv)
init_scenes(); init_scenes();
rmt_SetCurrentThreadName("Main Thread"); rmt_SetCurrentThreadName("Main Thread");
U32 result = 0; U32 result = 0;