jcmoyer / hug

A utility library for LÖVE with a focus on simplicity
Apache License 2.0
2 stars 1 forks source link

Improve gamestate API #14

Closed jcmoyer closed 9 years ago

jcmoyer commented 9 years ago

Current way to define a new state is something like:

local menustate = setmetatable({}, {__index = gamestate})
local mt = {__index = menustate}

function menustate.new()
  return setmetatable({}, mt)
end

function menustate:draw()
  -- draw the menu here
end

Lines 1-2 should be collapsed into something like local menustate = gamestate.extend(). A default menustate constructor could also be provided, though I'm not sure how useful it would be. Typically states need some data associated with them.

jcmoyer commented 9 years ago

I just realized I added this in 543bd003!