Received Playdate unit in the mail today. I don’t know anything about Lua, and I’m not a good programmer, but that hasn’t stopped me in the past! For now I won’t be working towards one particular game, but rather figuring things out as I go with a collection of prototypes. My focus is less on pushing the boundaries of the tech and more on “what cool things can I make without much coding prowess”.
So here’s my Progress Log, to help document my learning as well as motivate me and keep me accountable. Hopefully it’s helpful to other people in a similar position of feeling totally out of their depth but glad to have jumped in, and also as a form of approachability feedback to the Playdate team. This will probably be laughably basic to most of you, but I appreciate any encouragement and support.
First impressions. Opened box. Unit is small and cute, gorgeous design. Didn’t turn on immediately, contrary to tiny booklet. Plugged into computer and immediately worked. Is Crayons an art collective? No, it’s an example drawing software. Reinforces that A is [action/select] and B is [undo/cancel]. How do I change the paint roller, the 1, the name? Can’t quit - oh, the menu button lets me go back to launcher. Satisfying sound effects. Where do my screenshots go? Screen is crisp, definitely best in sunlight. Crank and accelerometer interest me most in input test. Would have liked a mic level indicator. Having way too much fun on this screen. Connect to wifi easily, keyboard for password is great. No problems connecting Account, super smooth process. I note that when I visit Settings now, it’s unresponsive for a second while it fetches my Account information, surprised by this approach. Digital clock looks great, but it’s 2 hours off. Upside Down mode heck yeah!
Right, time to figure out this SDK thing. Download SDK. Folder with ReadMe that tells me to check Inside Playdate. I’m given an example Basic Playdate Game very quickly but I don’t really know how to run it. Structuring and compiling… Oh, Nova extension. This bit was the most helpful. I can create main.lua and copypaste the basic game code and hit run but it doesn’t work. I think the error is lack of sprites. I look at the Examples folder and grab a random player and background asset and put them into my folder using the suggested structure. It works! Here are the steps I took:
Running Basic Playdate Game
- The SDK is a bunch of tools used to make Playdate games. Download and install the SDK from the pinned post on the Announcements page, then read Sections 1 to 4 of Inside Playdate.html in the SDK’s folder.
- Nova is a code editor. Download Nova from the Nova Beta Access post and set it up with the Playdate extension, following the instructions in section 4.5 of Inside Playdate.html. Keep following the instructions to create a new project (so Build & Run is configured to Playdate Simulator). As part of this process, you’ll create a project folder.
- Inside the project folder, create a folder named source. Inside that, create a file called main.lua and copy the Basic Playdate Game code from Inside Playdate.html.
- Create a folder named images inside source. Put two .png files into it and name them background.png and playerImage.png.
- Click the run button. The simulator pops up and you can play the game (moving the sprite with arrow keys).
- From the simulator and with device plugged in, select Device > Upload Game to Device to play the game on the Playdate.
With that working, it’s time to figure out how this code works. I read this document and get utterly confused. Let’s see if I can just play with the guts of this. Looks like there’s two main sections: a game setup function, called once to initialise the game, and an update function, called every frame. Why is playerSprite outside of the game setup function? Is it because it’s also called by update? I put xvel = 0 and yvel = 0 into the game setup function and make the button presses modify them in the update function, along with playerSprite:moveBy( xvel, yvel ).
Cross my fingers and hit run. It seems to work. Still no idea where I should put variables and whether they should be local or not (or what that means). Experimentation shows me declaring xvel and yvel in game setup function as local doesn’t work, but declaring them just after playerSprite as local does. I’m guessing local means “to the level of where this was declared, but no higher”.
Onwards to Section 5. It’s impenetrable. “We recommend you review the language manual to make sure you understand the difference”. I’m not going to do that, so I expect to be besieged by very-difficult-to-track-down bugs. What is object oriented programming. Help.
Skipping ahead to accelerometer and crank, because those are exciting. Do I turn accelerator on and off each frame? I’ll turn it on at the start and never turn it off for now. What’s a tuple? I guess and set xtilt,ytilt,ztilt = playdate.readAccelerometer() and add xtilt and ytilt to xvel and yvel every frame. Neat, I have a sprite that I can move by tilting the device. Crank time. I add playdate.getCrankChange() to xvel and now I can move my sprite using the crank. I feel very powerful.
Time to load some of these example games. 2020, Flippy Fish, Hammer Down, Pathfinder, and Mode7Driver are all very technically impressive projects. Oh. I got rickrolled.
Spent a few hours poking around and looking up a bunch of things. How does text work? gfx.drawText, ok. How can I store values? In a table. Is there a way to use dynamic variable names? No idea, I’ll put the variables into a table instead. How do I call sound? There’s a helpful forum post. Et cetera. Lots of small realisations and learnings.
I put together some of the things I learned and made a tiny Dadaist toy that lets you make/find a poem by remixing the first few lines of Genesis: thefirstday.pdx.zip (190.3 KB)
…now how do I uninstall games from my device?!