summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-04-15 20:04:57 -0500
committersanine <sanine.not@pm.me>2023-04-15 20:04:57 -0500
commit02c6f822e2cca41d5d28afd9f3a05211316587fd (patch)
treeafb1fec88273f8fe123ae8750a75c146969f4d9a /main.lua
parente603997055259039cefcdceaece5604e3856e36d (diff)
add collision system
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 },
},
})