summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua51
1 files changed, 39 insertions, 12 deletions
diff --git a/main.lua b/main.lua
index 9f39825..6718cf9 100644
--- a/main.lua
+++ b/main.lua
@@ -1,4 +1,27 @@
require 'honey.std'
+local paused = true
+
+local function formatize(f)
+ return function(fmt, ...)
+ f(string.format(fmt, ...))
+ end
+end
+local printf = formatize(print)
+local log = honey.log
+log.fatal = formatize(log.fatal)
+log.error = formatize(log.error)
+log.warn = formatize(log.warn)
+log.info = formatize(log.info)
+log.debug = formatize(log.debug)
+log.trace = formatize(log.trace)
+
+log.info(
+ "honey v%d.%d.%d -- %s",
+ honey.version.major,
+ honey.version.minor,
+ honey.version.patch,
+ honey.version.string
+)
local glfw = honey.glfw
local gl = honey.gl
@@ -21,7 +44,7 @@ local vw, vh = 640, 480
-- create camera matrices
local camera = {
- view=Mat4():identity():translate(Vec3{0, 0, -60}),
+ view=Mat4():identity():translate(Vec3{0, 0, -20}),
projection=Mat4():perspective(math.rad(45), 640/480, 0.1, 100),
}
@@ -129,11 +152,11 @@ local leaf = {
mesh=tetra,
shader=shader,
}
-local root = growLine(leaf, 24)
-root.update = function(self, dt)
- self.transform:rotateY(0.2 * math.pi * dt)
-end
-level:addEntity(root)
+--local root = growLine(leaf, 24)
+--root.update = function(self, dt)
+-- self.transform:rotateY(0.2 * math.pi * dt)
+--end
+--level:addEntity(root)
local groundPlane = {
transform=Mat4():identity():translate(Vec3{0, -2, 0}):scale(Vec3{10, 10, 10}),
@@ -158,15 +181,19 @@ local mass = ode.MassCreate()
ode.MassSetSphere(mass, 1, 0.5)
ode.BodySetMass(ball.physicsBody, mass)
ode.GeomSetBody(ball.collisionShape, ball.physicsBody)
-ode.BodySetPosition(ball.physicsBody, 0, 3, 0)
-ode.BodySetLinearVel(ball.physicsBody, 1, 0, 0)
+ode.BodySetPosition(ball.physicsBody, -5, 3, 0)
+ode.BodySetLinearVel(ball.physicsBody, 3, 0, 0)
ode.CreatePlane(space, 0, 1, 0, -2)
-- close window on ESCAPE key
-window:setKeyCallback(function(_, key)
- if key == glfw.KEY_ESCAPE then
- window:setShouldClose(true)
+window:setKeyCallback(function(_, key, scancode, action)
+ if action == glfw.PRESS then
+ if key == glfw.KEY_ESCAPE then
+ window:setShouldClose(true)
+ elseif key == glfw.KEY_SPACE then
+ paused = not paused
+ end
end
end)
@@ -199,7 +226,7 @@ honey.loop(window, function(dt)
gl.UseProgram(0)
gl.Enable(gl.DEPTH_TEST)
- level:update(dt)
+ level:update(dt, paused)
nvg.BeginFrame(vg, vw, vh, 1.0)
nvg.StrokeColor(vg, nvg.RGBf(1, 1, 1))
nvg.FontFace(vg, "November")