your-own-drum/main.lua

70 lines
1.5 KiB
Lua

local love = love
local sound
local beat = {
t = 0,
dt = 0,
}
local wave = {
x = { 1.0, 0.0, -0.5, 0.2, 0.4, 0.8, 0.3, 0.9, -0.4, 0.8, 0.5, 0.1, -0.9 },
dx = { 1.0, 0.0, -0.5, 0.2, 0.4, 0.8, 0.3, 0.9, -0.4, 0.8, 0.5, 0.1, -0.9 },
ddx = { 1.0, 0.0, -0.5, 0.2, 0.4, 0.8, 0.3, 0.9, -0.4, 0.8, 0.5, 0.1, -0.9 },
X = function(th) end,
DX = function(th) end,
DDX = function(th) end,
Draw = function() end,
AddImpulse = function( th, size ) end,
ImpactPoint = function( xi, yi, xf, yf )
local impact = { r = 0, th = 0, x = 0, y = 0, dx = 0, dy = 0 }
return impact
end,
Update = function( dt ) end,
}
--Set up all the game state I need.
local function NewGame()
beat.t = love.timer.getTime()
beat.dt = 0
end
local function OnImpact()
--Update beat timer.
local t = love.timer.getTime()
beat.dt = t - beat.t
beat.t = t
--Handle sound.
love.audio.play(sound)
end
local function OnVictory()
end
function love.draw()
love.graphics.setColor(1.0, 1.0, 1.0)
love.graphics.print("Hello World!", 400, 300)
love.graphics.print( beat.t, 0, 0 )
love.graphics.print( beat.dt, 0, 100 )
love.graphics.setColor(0, 0.4, 0.4)
--love.graphics.circle("fill", 0, 0, 10)
end
function love.load()
sound = love.audio.newSource("soundTest.ogg", "static")
return NewGame()
end
function love.update( dt )
end
function love.keypressed( key, code, isRepeat )
if key == "escape" then return love.event.quit() end
if key == "w" then return OnImpact( ) end
if key == "enter" then return NewGame() end
end