Page 1 of 1

TUP Base - Another library. Has hooks!

Posted: Sun Mar 29, 2009 8:36 pm
by thelinx
Here's a library (more like a game base) I made. Everything is based around hooks now.

Features:
- Tab restarter.
- Hooks!
- Debug mode.
- Game state basics.
- Utility functions:
+ love.graphics.setDrawMode
+ love.graphics.setAlpha
+ table.Count
Example code:

Code: Select all

require("tupbase.lua")
exl = {}
function load()
	game.media = {	cursor = love.graphics.newImage( "media/cursor.png" ) }
	game.v.state = "menu"
end

function exl.draw()
	if game.v.state == "menu" then
		love.graphics.draw( game.media.cursor, love.mouse.getX(), love.mouse.getY() )
	end
end

function exl.update(dt)
end

function exl.keypressed(key)
	if key == love.key_escape then
		hook.Call("beforeexit")
		love.system.exit()
	end
end

function nooo()
	msg("Nooo don't exit! D:")
end

-- Add hooks.
hook.Add("draw", dfr.draw)
hook.Add("update", dfr.update)
hook.Add("keypressed", dfr.keypressed)
hook.Add("beforeexit", nooo)
Download: http://tup-love-projects.googlecode.com ... upbase.lua

Enjoy.