Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created March 11, 2015 19:17
Show Gist options
  • Save fowlmouth/2862a0569295102e21e5 to your computer and use it in GitHub Desktop.
Save fowlmouth/2862a0569295102e21e5 to your computer and use it in GitHub Desktop.
type
App* = ref object of RootObj
vt*: AppVT
AppVT = object
draw*: proc(my:App)
update*: proc(my:App, dt:float)
var defaultVT = AppVT(
draw: (proc(my:App) = discard),
update: (proc(my:App, dt:float) = discard)
)
## accessors
proc draw* (my:App) {.inline.} = my.vt.draw(my)
## to implement your game state
var myVT = defaultVT
myVT.draw = ...
myVT.update = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment