Skip to content
/ pdbug Public

Debug overlay utility for Lua-based Playdate games

License

Notifications You must be signed in to change notification settings

jaames/pdbug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


pdbug

Debug overlay utility for Lua-based Playdate games

Overview

Pdbug ("p debug") taps into the Playdate's sprite library to provide a paint flashing overlay that highlights sprites when they have been redrawn. It can help to find performance issues (less things drawing per frame is better!) and debug various pitfalls you might come across when developing sprite-based games.

This utility relies on playdate.debugDraw, and as such it is only available in the Playdate Simulator.

Quick Start

Install

All you need to do is download pd.lua from this repo and then drop it into your game's Lua source folder!

Setup

In your game's main.lua file, import the pdbug.lua file you just downloaded and then call pdbug:setEnabled(true) to enable the debug overlay:

-- import from wherever you saved the pdbug.lua file
import './pdbug'
-- call this to enable the debugging overlay!
pdbug:setEnabled(true)

Usage and Options

Methods

pdbug:setEnabled(enabled)

If enabled is true, the overlay will be turned on, otherwise it will be turned off.

pdbug:setOverlayColor(r, g, b, a)

Set the debug overlay color from red, green, blue and alpha values.

r, g and b should be between 0 and 255, and a should be between 0 and 1. The default color is 255, 0, 40, 0.75.

pdbug:addPaintRect(x, y, w, h)

Use this if you ever need to manually add a rectangle to the paint flashing overlay. x and y should give the position of the rectangle's top-left corner, w and h should give its width and height.

Options

pdbug.showFPS

If set to true, the FPS counter will be visible when the overlay is enabled. Defaults to true.

pdbug.showPaintFlashing

If set to true, paint flashing rectangles will be visible when the overlay is enabled. Defaults to true.

pdbug.paintFlashLineWidth

The line width to use for paint flashing rectangles, measured in pixels. Defaults to 2.

pdbug.paintFlashFrameDelay

How long a paint flashing rectangle should be shown for before it disappears, measured in frames. Defaults to 15.


2022 James Daniel

About

Debug overlay utility for Lua-based Playdate games

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages