Scrupp 0.1 Manual
Create your own 2D games and applications

Functions

mouse.getX()
Returns the current x-coordinate of the mouse pointer.
mouse.getY()
Returns the current y-coordinate of the mouse pointer.
mouse.getPos()
Returns the current x- and y-coordinate of the mouse pointer
mouse.isDown(button)
Returns the boolean state of the button. button is one of the strings "left", "middle" or "right".

Callbacks

mousepressed(x, y, button)
Gets called when a mouse button is pressed. Arguments are the x- and the y-coordinate of the mouse pointer and the pressed button. button is one of the strings "left", "middle", "right", "wheelUp" or "wheelDown".
mousereleased(x, y, button)
Gets called when a mouse button is released. Arguments are the x- and the y-coordinate of the mouse pointer and the released button. button is one of the strings "left", "middle", "right", "wheelUp" or "wheelDown".

Example

game.init("Mouse Test", 600, 400, 32, false)
cursor = game.addImage(<path to cursor image>)

main = {
	render = function(dt)
		if mouse.isDown("left") then
			cursor:render(mouse.getX(), mouse.getY())
			--or: cursor:render(mouse:getPos())
		end
	end,
	
	mousepressed = function(x, y, button)
		print(button .." button pressed at "..x..", "..y)
	end,
	
	mousereleased = function(x, y, button)
		print(button .." button released at "..x..", "..y)
	end
}	

Hosted by
SourceForge.net Logo

Valid XHTML 1.0!

Last modified Sun Apr 27, 2008