HEBitmap (High Efficiency Bitmap) is a custom implementation of the drawBitmap function (Playdate SDK).
This implementation is up to 2x faster than the SDK drawBitmap function, but native features (flip, stencil) are not supported.
The library also provides an optional sprite system to efficiently move sprites and check collisions.
Bitmap info: 96x96 (masked)
Bitmap count | HEBitmap | drawBitmap | Faster |
---|---|---|---|
1000 | 22 ms | 42 ms | 1.9x |
#include "he_api.h"
// Initialize with PlaydateAPI pointer
// Pass 1 to enable Lua support
he_library_init(pd, 0);
// Load HEBitmap from a Playdate image file
HEBitmap *bitmap = HEBitmap_load("catbus");
// Draw
HEBitmap_draw(bitmap, 0, 0);
// Free
HEBitmap_free(bitmap);
#include "he_api.h"
// Initialize in kEventInitLua
// Pass 1 to enable Lua support
he_library_init(pd, 1);
import "he/bitmap"
-- Load HEBitmap from a Playdate image file
local bitmap = he.bitmap.new("catbus")
function playdate.update()
-- Draw
bitmap:draw(100, 100)
end
- Install CMake (run
brew install cmake
from the terminal) - In the lua folder of the repo you can find a minimal template to create a C-Lua project
- Copy all the files beginning with "he_" from src into lua/src
- Navigate into the lua folder and create a build folder
- Open the terminal and navigate into it
- Run
cd <your_build_folder>
- Run
cmake ..
- Run
make
- Before building again, delete all the files in the build folder
- Run
cmake -DCMAKE_TOOLCHAIN_FILE=<path to SDK>/PlaydateSDK/C_API/buildsupport/arm.cmake -DCMAKE_BUILD_TYPE=Release ..
- Note: replace
<path to SDK>
with your SDK path - Run
make
You can now build and run it as a Lua project.
The sprite system allows to efficiently move, check collisions and draw sprites. You can find two Lua examples in the repo.
Source/dino
Source/survival
You can use the Python encoder to create heb/hebt files, supported inputs are:
- Image
- Animated GIF (saved as bitmap table)
- Folder containing a Playdate image table (name-table-1.png, name-table-2.png, ...)
-i
--input
input file or folder-r
--raw
save as raw data (no compression)
python encoder.py -i <file_or_folder>