summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua27
1 files changed, 24 insertions, 3 deletions
diff --git a/main.lua b/main.lua
index fe97123..0f46f70 100644
--- a/main.lua
+++ b/main.lua
@@ -38,6 +38,7 @@ local systems = ecs.SystemDb(entities)
systems:addSystem(sys.transform)
systems:addSystem(sys.renderCamera)
systems:addSystem(sys.script)
+systems:addSystem(sys.collision, {space=space})
systems:addSystem(sys.physics, {space=space, world=world})
package.loaded['baseRotationScript'] = function(entities, id, dt)
local transform = entities:getComponent(id, "transform")
@@ -77,6 +78,19 @@ function setupEntities()
},
onWindowResize = { script = "cameraHandleResize" },
})
+
+
+ local plane = entities:createEntity()
+ entities:addComponents(plane, {
+ transform = {
+ matrix = Mat4()
+ :identity()
+ :rotateZ(math.rad(5))
+ },
+ collision = {
+ class = "plane",
+ },
+ })
@@ -88,7 +102,14 @@ function setupEntities()
mesh = { filename="assets/icosahedron.obj", index=1 },
},
transform = {
- matrix = Mat4():identity():rotateZ(math.rad(45)),
+ matrix = Mat4()
+ :identity()
+ :translate(Vec3{0,1,0})
+ :rotateZ(math.rad(45)),
+ },
+ collision = {
+ class = "sphere",
+ radius = 1,
},
physics = {
mass = {
@@ -96,8 +117,8 @@ function setupEntities()
density = 1,
radius = 1,
},
- velocity = Vec3{ 0, 10, 0 },
- angularVelocity = Vec3{ 0, 1, 0 },
+ velocity = Vec3{ 0, 0, 0 },
+ angularVelocity = Vec3{ 0, 0, 0 },
},
})