Scrupp 0.4 Manual
Create your own 2D games and applications

Scrupp 0.4 contains version 2.0.2 of the Lua network library LuaSocket written by Diego Nehab.

The website of LuaSocket contains an introduction and a reference.

The doc directory of the Scrupp distribution contains a local snapshot of the LuaSocket documentation.

Everything described in this documentation works exactly the same way in Scrupp.

Example

-- size of the window
local width, height = 600, 400

scrupp.init("LuaSocket Test", width, height, 32, false)

-- loads the HTTP module and any libraries it requires
local http = require("socket.http")

-- download a screenshot from the scrupp website
local img = http.request("http://scrupp.sourceforge.net/screenshots/linux_default_thumb.png")

-- convert the string to a scrupp image
img = scrupp.addImageFromString(img)

-- get the size of the image
local w, h = img:getSize()

-- calculate the coordinates of the image (for center position)
local x, y = (width-w)/2, (height-h)/2

main = {
	render = function(dt)
		-- render the screenshot at the center of the window
		img:render(x,y)	
	end,
	
	keypressed = function(key)
		if key == "ESCAPE" then
			scrupp.exit()
		end
	end
}

Hosted by
SourceForge.net Logo

Valid XHTML 1.0!

Last modified Mon Jun 01, 2009