Playdate 1

I’ve decided to try something new: programming a little game for the Playdate console, and documenting it here as I go. I’m new to the console, and to Lua, and I haven’t written a game since the late 1990s, so it’s likely to take me some time.

Here are my notes from Day 1 – getting the SDK up and running on a Mac.

Playdate 1:

Downloaded the latest SDK from https://play.date/dev/

Installed. New folder created: ~/Developer/PlaydateSDK/

Inside that folder: /bin/Playdate Simulator. Open that up, it works – a little Playdate, running away in a window 🙂

Also there’s an Examples folder. Per the docs, to compile some code it should be:

pdc sourcefolder destinationfolder

So – tried that. In Examples:

pdc ./Asheteroids/Source ./compiled 

That creates a file: source.pdx. Double-click it: success!

I should have specified an output file name, though. So let’s try that again:

pdc Asheteroids/Source ./compiled/ash.pdx

And that works too. So that’s how to compile and test. And the Simulator has a console (button at the bottom edge), which should be handy.

Time to write something.

So: I started with the “Basic Playdate game in Lua” sample code. Reading through, it imports a load of standard libraries, then there’s a setup function that sets a single sprite and a background, that’s called, and then there’s a function that looks like the game loop, where the D pad moves the sprite.

The initial file seems to always be called main.lua, so I go with that.

Problem: I need a sprite. And a background image. Not sure of the format for either. Obviously not in colour, and probably some sort of indexed file. PNG?

Draw a simple sprite on Piskel (link). Save that as a PNG.

For the background – no idea. Just delete that whole block of code, for now, see if we can get the sprite up.

Compile with:

pdc day1/Source ./compiled/day1.pdx

And there we go – looks like the PNG is OK. Hello, smiley face:

That’s enough for day 1. Code is here:

https://github.com/tomroyal/playdates

Notes:

https://sdk.play.date/2.6.0/Inside%20Playdate.html

https://www.lua.org/manual/5.4

https://www.piskelapp.com/p/create/sprite


Posted

in

,

by