diff options
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 61 |
1 files changed, 42 insertions, 19 deletions
@@ -61,25 +61,6 @@ package.loaded['cameraKeyHandler'] = function(entities, id, data) end function setupEntities() - local camera = entities:createEntity() - entities:addComponents(camera, { - camera={ - projection=Mat4():perspective(math.rad(45), 640/480, 0.1, 100), - render="screen", - }, - transform={ - matrix=Mat4():identity():translate(Vec3{0, 0, -6}), - }, - z = {value=-60}, - script={ - script="cameraRotationScript", - }, - onKey = { - script="cameraKeyHandler", - }, - onWindowResize = { script = "cameraHandleResize" }, - }) - local plane = entities:createEntity() entities:addComponents(plane, { @@ -143,6 +124,47 @@ function setupEntities() textures = { ourTexture = { filename = "44d9a0ec1c18e6126a5e9d9d9317f5ac.png" } }, }, }) + + local capsule = entities:createEntityWithComponents{ + transform = { + matrix = Mat4():identity():translate(Vec3{0,10,0}) + }, + collision = { + class = "capsule", + radius = 1, + length = 2, + }, + physics = { + mass = { + class = "capsule", + density = 1, + direction = 3, + radius = 1, + length = 2, + }, + }, + renderMesh = { + mesh = { filename="assets/capsule.obj", index=1 }, + shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, + }, + } + + + local camera = entities:createEntity() + entities:addComponents(camera, { + camera={ + projection=Mat4():perspective(math.rad(45), 640/480, 0.1, 100), + render="screen", + }, + transform={ + matrix=Mat4():identity():rotateX(math.rad(-20)):translate(Vec3{0, 10, 30}), + }, + z = {value=-60}, + onKey = { + script="cameraKeyHandler", + }, + onWindowResize = { script = "cameraHandleResize" }, + }) end setupEntities() @@ -200,5 +222,6 @@ honey.loop(window, function(dt) nvg.EndFrame(vg) end) + -- clean up honey.terminate() |