Löve2D library to aid in even faster prototyping.
The following code should display an 8x8 tile from the some-image.png
image onto the screen at coordinates (0, 0).
local BB = require("breadboard")
local img = BB.makeTileset("some-image.png")
BB.tile(img, 0, 0, 0)
function BB.frame(dt)
BB.draw(0, 0)
end
Set the viewport size. The default is 240 and will be integer scaled to the height of the actual screen.
- size - the size in pixels; I like 240 (default), 120 and 420.
Obtain information about the viewport position and window size.
This function is useful to get info about the whereabouts in the real coordinate space of the device that Löve2D is being run on.
The viewport is always square, but I allow for drawing outside it, such as that if you have a larger platformer for example, the buttons may hide some of the playfield but hopefully not the viewport.
A dict containing these keys:
- offsetX - start position of the top left corner of the screen (may be negative) (coordinate x)
- offsetY - start position of the top left corner of the screen (may be negative) (coordinate y)
- width - the full width of the window
- height - the full height of the window
- zoom - the scale factor
Clear the screen with a given colour. (black default)
- colour (default:
{1, 1, 1}
) - the colour to use while clearing the screen
Draw from the tilemap to the screen.
- sourceCellX - source tile to start the copy from (x coordinate)
- sourceCellY - source tile to start the copy from (y coordinate)
- spanCellX (default:
1
) - number of tiles to copy (x coordinate) - spanCellY (default:
1
) - number of tiles to copy (y coordinate) - offsetX (default:
0
) - displacement (x coordinate) - offsetY (default:
0
) - displacement (y coordinate) - rotationAngle (default:
0
) - rotation to apply when copying - scale (default:
1
) - scale to apply when copying - alpha (default:
1
full opacity) - the amount of transparency to copy the tile with - colour (default:
{1, 1, 1}
full white) - the colour multiplier (basically love.graphics.setColor)
Draw to the tilemap.
- tilesetID - ID of the loaded tileset (use makeTileset)
- sourceCellX - source cell to copy from (x coordinate)
- sourceCellY - source cell to copy from (y coordinate)
- destCellX - destination cell to copy to on the tilemap (x coordinate)
- destCellY - destination cell to copy to on the tilemap (y coordinate)
- spanCellX (default:
1
) - number of tiles to copy (x coordinate) - spanCellY (default:
1
) - number of tiles to copy (y coordinate) - alpha (default:
1
full opacity) - the amount of transparency to copy the tile with - colour (default:
{1, 1, 1}
full white) - the colour multiplier (basically love.graphics.setColor) - offsetX (default:
0
) - displacement (x coordinate) - offsetY (default:
0
) - displacement (y coordinate) - flipX (default:
false
) - do a horizontal flip - flipY (default:
false
) - do a vertical flip
Clear a tile on the tilemap.
- destCellX - position of the first tile to clear (x coordinate)
- destCellY - position of the first tile to clear (y coordinate)
- spanCellX (default:
1
) - number of tiles to clear (x coordinate) - spanCellY (default:
1
) - number of tiles to clear (y coordinate) - alpha (default:
0
full transparency) - the amount of transparency to set - colour (default:
{0, 0, 0}
full black) - the colour to set - offsetX (default:
0
) - displacement (x coordinate) - offsetY (default:
0
) - displacement (y coordinate)
Load a tileset from file. If the file has already been loaded, this returns a cached version.
Use removeTileset
if needed.
- fileName - the path/filename to load the data from
A tileset ID.
List all loaded tilesets.
A list with all the loaded tileset IDs.
Remove a tileset given its ID.
- tilesetID - ID of the tileset to remove
Get the status of a button. The buttons are:
l
- Left- KB:
Left
,S
- KB:
u
- Up- KB:
Up
,E
- KB:
r
- Right- KB:
Right
,F
- KB:
d
- Down- KB:
Down
,D
- KB:
a
- A button- KB:
Space
,z
,j
- KB:
b
- B button- KB:
Ctrl
,x
,k
- KB:
c
- C button- KB:
Alt
,c
,l
- KB:
s
- Start button- KB:
Enter
- KB:
The library also makes a touchscreen virtual joystick for Android and uses default mappings for a joystick.
- butID - button ID, one of the ones above
Boolean representing the state of the button.
Return if a button has been pressed in the current frame.
- butID - button ID, check
button
for IDs
Boolean whether the button has been pressed in the current frame.