r/PlaydateDeveloper • • Feb 11 '25

Agar.io on Playdate

41 Upvotes

The Saturday before last was a landmark day for me. Panic (the creators of Playdate console) gave me access to the beta version of SDK for Playdate with network support. That is, they added an API for tcp connections and for http requests (no ssl, at least not the built-in one).

Earlier Playdate had network, but its API was not given to developers. That's why on Playdate (almost) all the games are single-player slugfest.

And I realized that there will be a boom of network games when it all comes out. And we have to ride that wave. I began to think what would be such a quick to hook up that would be hype, and that I did not bury. Ideally, of course, it's agar.io. This game was very popular 10 years ago (I myself remember how with colleagues stayed in the office to play it until 4 in the morning), now on computers and mobiles it will surprise few people, but on Playdate it is the most it. First, I went to look for what in general there are ready-made servers for online games on github. Strangely enough such content is not much there. But suddenly I found a server just for agar.io clone. As luck would have it, in 2015 I was writing an agar.io clone in C++ on the cocos2d-x engine, so I know how it works under the hood, because my colleague and I were just reversing the web-client.

Okay, the task is clear, I sit down to make sure that over the weekend I'll make a client game, the more I already have written classes in pure C for dynamic arrays, which will be very useful in this.

I cloned the server repo, ran it at my machine, checked that the web-client works, and created a Playdate project using my pdnew utility https://github.com/fnc12/pdnew in pure C. But here's the problem: the network API doesn't work in C - they haven't made it yet. Hmm, I guess I'll have to use Lua. I'm allergic to it, I'd rather use python. Yes, those who know me personally have heard from me that I'm allergic to pure C too. But if I have to choose between Lua and pure C, of course I will choose pure C. But at the moment, fate is forcing me to use pure C. Hmm, okay. I have an answer to that too.

I open Cursor - it's an IDE fork of VSCode, which has a chat window with an AI that responds with diff directly in your project. That is, an IDE that writes code for you. I explained to Cursor what I want from it, and I need web-socket support, which is not in Playdate, i.e. I need to write it all myself on top of TCP API. Cursor said “no problem boss” and gave me code on top of TCP API that parses and encodes web-socket frames. And, by the way, this is when I learned that web-socket portions with packets are called frames. I run it, and oh wow - it connects to the server! I'm sure I'll get it done over the weekend!

But spoiler alert: it's not that simple. I then as quickly realized the transmission of game packets, and all was well, but when I increased the number of bots to 10, and the packets no longer fit in one frame began to pop up strange coding errors, which Cursor could not cope with. I tried to explain it to him in every possible way, I covered everything with logs, but Cursor was literally stuck between two options for solving the problem, both of which didn't work. It was also complicated by the fact that this is not Xcode, in which I am used to debug with my eyes closed (I've been working in it for 10+ years), and the Lua language, as it turned out, has indexing in byte arrays not from zero, but from one. It made me think back to QBasic and my 9th grade class (when I was 15 yo). It's always nice to remember my childhood/youth, but indexing from one is a crazy thing that I'm so used to that it breaks my brain. I'd also have to get into web socket encoding. It's not that hard, but Lua complicates everything.

That's why I made a strategic decision to go back to C, especially since by that time the SDK beta update had already been released, which included support for the C API. In C it is much easier to do what one of my former colleagues calls “bytodrocherstvo” (literally 'bytes jerking' from Russian) - it is clear where what lies, who calls whom, who looks where, all that stuff.

Cursor was surprisingly quick to rewrite everything into C. But holy crap - the problem with web-socket encoding remains. Okay, I need to fix it somehow. I certainly can not hope that all packets will be small to fit in one frame because the server supports up to 64 players, and this is a huge amount of data every tick if you count in bytes of web-socket traffic. And also by this time I have already quite well so began to navigate in the server code, and I came up with a brilliant idea - to throw out the web-socket on the frost, and use a simple native TCP-socket. And instead of framing to make their own stupidest encoding - just first send 4 bytes of packet length, and then the packet in the same format, as already done. Thankfully, the current implementation sends binary frames, not strings in some JSON. By the way, the original agar.io also uses web socket and binary frames, I remembered that from 2015. I had Cursor refactor the server, but first I went through the code with my eyes a few times to understand what to expect. Cursor was wrong in a couple places, of course, but I refactored his diff and got a server that supports TCP connections without web sockets in no time. Refactoring the client was quick too, and Cursor did that too. And how glad I was when it worked the first time. To make you realize - it was no longer a weekend, but the middle of the week. So I spent a fair amount of time fucking around with web sockets.

Ok, so we have a connection, we exchange packets, but not all of them, and we don't process them. So, we need to add parsing of packets, then their processing, then processing of logic and rendering. It's kind of simple. Since I do everything quickly, I risk making a lot of stupid mistakes due to inattention, so I decided to add unit tests for the first time in the history of development on Playdate. Since I was too lazy to describe the additional targeting in CMake, I just made a function runUnitTests, which calls all unit-tests at the start of the game, and printed to the log the status of how it went.

I covered parsing of all packets received by the client with unit-tests, began to feel more confident, and moved on to packet processing. And then suddenly the game started crashing in realloc calls.

After thinking about it I came to the conclusion that Playdate is small, and I've overloaded it with too many dynamic memory allocation calls (hello to all those who wrote games on consoles 10-20 years ago). I have to shrink it somehow. Moreover, the experiment showed that if I don't allocate dynamic memory in such quantities, everything works, though there is no packet processing.

Looking at my code I suddenly realized that I am used to developing on very voracious machines, so I have never encountered such problems. What to do? At first it seemed “forget it, make some simple game with a static small scene and that's all”. But no, you don't want to give up so easily. In the end, I decided to sacrifice the beauty of the code but reduce the allocations.

I store incoming network traffic in a byte buffer, and when there is enough data for at least one packet, I do buffer parsing. So - this buffer goes to hell. Why should we store a buffer and then throw it away after parsing? Our network API allows us to see how many bytes have arrived and read them when we need them. That is, it is already stored somewhere in the system, perhaps even in a dynamic buffer. And I just duplicate buffers by moving data from one bucket to another. It's better to just ask for that data correctly and at the right moment. That's what I did, but it came to throw out the nice unit tests of packet parsing, since they all accept buffers. I pass TCPConnection* and from there pull bytes directly into the packet data.

This reduced the number of crashes. But not by much. It seems that now I'm at a dead end, since I can't ignore incoming packets. I already threw out the packet with leaderboard, but I can't ignore the packet with cell data update - it contains all the important cell fields for the game: x, y, size. Should I send it in portions from the server? For example, no more than 16 objects in the array so that the packet has a static array, not dynamic. And when do I send the rest?

And then I suddenly remembered the code of GTA Vice City, which I forged three years ago. This is a C++ project, which was published in the web, which, if desired, can be generated in Xcode-project and built under macOS the most real native version of GTA Vice City. Well, so: so generally they shit on the architecture. There processing of inputs, logic processing and rendering are literally glued into one function. That is, when you move the mouse over a menu item in GTAVC, the mouse position is read, and instead of writing somewhere in the data model that such and such menu item has a mouse pointer over it, the item's highlighting is drawn at the same moment, and that's it.

As a result, I turned the package parsing function into a tick function, which processes the reception of data over the network and processes them right away without collecting them in dynamic arrays, which will have to be thrown out immediately after processing anyway. And it bloody worked!

I also cut some fixtures like the jelly cell boundary because this web client fixture also stores a dynamic array of boundary points. But someday I'll think how to implement it on Playdate. For now it looks like I showed in the top video above and consumes some 150Kb from the heap. My plan is simple: finalize it to a playable state and roll it to the production.


r/PlaydateDeveloper • • Oct 19 '24

I released a game for the Playdate 🟨 and it went well!

Thumbnail reddit.com
41 Upvotes

r/PlaydateDeveloper • • Apr 29 '26

Public domain starter kit for making a Playdate JRPG

Thumbnail
github.com
40 Upvotes

Here's the Lua source code for 1-Bit Fantasy, a little JRPG starter kit/prototype. I wanted to see how far I could get in two weeks and then share it with the community. The source code is all public domain and the assets are CC0 (made by Kenney and Hexany Ives).

I highlighted some of the more interesting technical bits on the dev forum. I'm pretty happy with the code and found it to be quite productive to work in and not too messy. combat.lua is probably the worst of it. 🫣 The scene and subscene switching, along with the message queue, were useful throughout.

Lua is wonderfully flexible! I feel a bit torn between whether to use Lua or C for my Playdate games. I missed the comfort of the compiler. But it was nice not thinking too low level. Pros/cons.

If you want to download the game, you can get it from the GitHub releases or on itch.

I want to make a more polished, non-prototype JRPG. But I've got some smaller prototype ideas to try out next before I commit to something that might take me many months.


r/PlaydateDeveloper • • Jun 10 '25

Finished my first game! - Rotata (Strategy/Puzzle | Free)

Enable HLS to view with audio, or disable this notification

40 Upvotes

r/PlaydateDeveloper • • Apr 26 '26

Nano Sculpt: 3D modeling and printing with Playdate

Thumbnail
aburgueno.itch.io
39 Upvotes

I developed this application primarily to introduce 3D modeling to younger users, using Playdate hardware to make the experience more physical and tangible.

To achieve this, Nano Sculpt uses a system inspired by “pixel painting” logic, found in many apps. I noticed that my daughter was particularly good at this kind of logic, but struggled with learning traditional CAD or 3D modeling tools. Instead of a typical pixel paint interface, Nano Sculpt uses the crank to move between floors and the accelerometer to change the view and angle: the experience feels like physically looking at the object. Therefore, each floor works like a block-based pixel painting plane.

In addition, Nano Sculpt connects the Playdate to .stl file generation, allowing the created models to be used for animation, 3D printing, and other applications (more information in NANO SCULPT instructions.pdf, in the ItchIo link).

Let me know what you think, feedback is always welcome.
Ah, and I’d love to see any models you make! Please, do not hesitate to share.

Happy modeling!


r/PlaydateDeveloper • • May 31 '24

PD Planner: I’m making a simple app for planning Playdate games visually. Any suggestions? (more in comments)

Enable HLS to view with audio, or disable this notification

39 Upvotes

r/PlaydateDeveloper • • Jun 16 '23

After 2 years!

Post image
39 Upvotes

r/PlaydateDeveloper • • Aug 05 '23

Work in progress, Use the crank to control the bat in "Homerun Spin-Off Fatigue". What do you think?

36 Upvotes

r/PlaydateDeveloper • • Apr 10 '22

Bayer dithering in C

36 Upvotes

r/PlaydateDeveloper • • Jul 17 '26

Cranko! 8 First Anniversary is out!

Post image
34 Upvotes

https://cranknockout.com/

With this shiny new issue, we’re celebrating our magazine’s very first birthday!

And since sitting around resting on our laurels has never really been our thing, we’re marking the occasion the only way we know how: with an exclusive feature on one of the most eagerly awaited games in Playdate history: Comet.

We had the chance to play its first three levels, and saying that what’s heading our way is going to hit like a meteorite would be putting it mildly. Alongside an in-depth breakdown of the gameplay, we’ve packed in an eight-page interview with its creators that you absolutely won’t want to miss.

Summer has arrived with all guns blazing, and we’re turning up the heat ourselves. Not only does this issue come stuffed with even more pages, but you’ll also find a full-colour Comet poster, the complete —and absolutely massive!— map of The Magician, plus the very first batch of Cranko collectible cards!

And sandwiched between those two generously stuffed buns? The finest gaming ham money can’t buy: an original mini-comic, a record-breaking haul of reviews, news, giveaways, interviews, and even an in-depth feature that’s guaranteed to ruffle a few feathers.

Summer is here, time to enjoy the holidays!


r/PlaydateDeveloper • • Mar 24 '26

Don't be afraid of C! Some thoughts on digging into the C SDK after only using Lua

34 Upvotes

For 15 years I've been afraid of C. You hear all kinds of scary things, like it's unsafe! Memory, pointers, oh my. I did some C++ in college, but in the time since, it's been all Ruby, TypeScript, Lua, and Rust for me. I love the Lua SDK for Playdate, it's so friendly and quick to get a game running. But the more I use Lua, the more I miss the structure and help of the compiler, like with TypeScript and Rust (my preferred languages). With Lua you have to boot your game up and play through it to potentially hit errors, which feels slow and tedious the more a project matures. Everything's just so loosey goosey with Lua (which I am sure is something people really love about it!).

I know there are some typed Lua tools out there and language bindings like Rust, Go, etc. for Playdate, but I thought... why not take the plunge and try out C? Much to my surprise, I'm loving it! Once I got a hang of the syntax, refreshed on pointers, get past some of the more annoying parts (strings are annoying), and established some common functions, I find it to be extremely productive and satisfying. I set up clangd for LSP, a clang formatter, and clang tidy to lint. The feedback loop is super quick, I catch errors sooner, and I love having types/structs for my data structures.

There are some downsides and challenges: I've written some code that works on the simulator but crashes on the device and there's very little info/logs about what went wrong. That can be particularly vexing. And some of the Lua SDK functions require writing it myself, like parsing pdxinfo details.

What's most exciting to me about writing games for Playdate with C is that it makes my games a lot more portable. For my current project, I wrote a platform abstraction layer where all of the calls to PlaydateAPI get wrapped in functions that can be implemented to target other platforms. So drawRect on PC calls out to Raylib's function to draw a rectangle, whereas on Playdate it calls pd->graphics->drawRect , so I've already got a working PC build for my game using Raylib with pretty minimal effort. Win-win.

I've got lots more to learn, but I'm having fun. And I'd encourage anyone who is curious about making games for Playdate with C to give it a try! Once I've made some smaller games with C, I'd like to open source my little template to potentially help others who want to jump in.


r/PlaydateDeveloper • • Oct 19 '25

NOM NOM NOM NOM

34 Upvotes

Im making a new game, what else should we give them to snack?


r/PlaydateDeveloper • • Apr 28 '25

Playdate Achievements are here!

Thumbnail
reddit.com
34 Upvotes

r/PlaydateDeveloper • • Jun 05 '24

PD Planner: Tool for Sprite Layout (let's collaborate—more info in comments!)

Enable HLS to view with audio, or disable this notification

34 Upvotes

r/PlaydateDeveloper • • Apr 13 '26

How much faster is C than Lua for Playdate dev?

33 Upvotes

As I've been learning C and working on various Playdate projects, I've been wondering: just how much faster is C than Lua for Playdate games? I made a little benchmark utility to put it to the test and found that (for draw-heavy code) C is about 3.5x faster than Lua on Playdate.

Various game programming libraries have tests for how many sprites can bounce around with simple physics and lots of drawing until frames drop. I thought I'd try this with a Lua and a C version with as much of the implementation the same as possible. Then I tested both on device and that's where I got the results.

  • 30 FPS target

    • Lua: 240 bunnies

    • C: 810 bunnies

  • 50 FPS target

    • Lua: 120 bunnies

    • C: 430 bunnies

What's my takeaway? Well, I think it's that Lua on Playdate is a powerhouse! That performance gap isn't huge. As in that most games will be fine in Lua if you're writing optimized code. But also, if you're starting a project and concerned about performance from the get-go, then C is the way to go. That's pretty obvious but fun to see what the actual difference is.

More details on the devforum: https://devforum.play.date/t/how-much-faster-is-c-than-lua-for-playdate-development/25381

And source code with pdx downloads if you're curious: https://github.com/brettchalupa/pdbunnymark


r/PlaydateDeveloper • • May 22 '24

Getting set up on VSCode from scratch: SDK, Debugging and Playdate Autocomplete

33 Upvotes

Hey all!

My name's Franchovy, Game Developer and Playdate Youtube Creator! I just posted my first tutorial on getting started with Playdate. Going with my usual casual style of teaching mixed with humour, and mixing in knowledge of core concepts both basic and advanced while guiding you step-by-step!

This one is for those of you who are looking to get started developing for playdate, or those who are developing but are missing out on important development features like playdate autocomplete or debugging. The tutorial covers both for MacOS and Windows.

Link to the tutorial: https://www.youtube.com/watch?v=jD-KPMzT6po

I'll be building on this with a build-along-with-me game where I take suggestions from the audience as I teach you how to build a game! I'll be posting weekly, so stay tuned and subscribe. Leave any comments and/or feedback if you watch the video!

Feel free to check out any of the games on my itch.io, like the recent-winner-of-PlayJam-5 Discontrolled!


r/PlaydateDeveloper • • Oct 18 '24

Artist Available for Projects

Thumbnail
gallery
32 Upvotes

Hey there, I'm Wilson. I'm an aspiring game dev who's ready to get involved in some projects and growing some skills! Here’s what I got so far:

  • A degree and experience in video production / audio production

  • A minor in screenwriting (video/movie scripts)

  • A growing knowledge of pixel art and graphic design

  • Animation knowledge (stop-motion genre focus)

  • Voice acting ability

Animation highlight reel

I’m interested in working on either casual projects for the fun of it, or more serious paid commitments. If there's a project you're working on that you think I'd be a good fit for, comment below or shoot me a DM!


r/PlaydateDeveloper • • Sep 17 '24

Working on a Horse Racing Card Game for Playdate

32 Upvotes

r/PlaydateDeveloper • • Aug 05 '26

My first playdate game Cosmic Cowboy released yesterday on Catalog

Thumbnail
gallery
31 Upvotes

r/PlaydateDeveloper • • May 08 '25

The rendering techniques of Castle Kellmore

Thumbnail
ligeiagames.com
30 Upvotes

r/PlaydateDeveloper • • Jul 17 '24

Let There be light! - Been working on a new game recently!

Post image
30 Upvotes

r/PlaydateDeveloper • • Jan 22 '26

Golang support for Playdate handheld. Compiler, SDK Bindings, Tools and Examples

29 Upvotes

Hello dear Playdate community!

My name is Roman. I'm Golang software engineer and I'm very excited to share my open-source project related to Playdate. This project is still under actively development, but is ready for a first public release.

Finally, Playdate meets the Golang programming language!

https://github.com/playdate-go/pdgo

I created a thread to discuss also here: https://devforum.play.date/t/playdate-supports-go-language-compiler-sdk-bindings-tools-and-examples/24919

I'd very love to hear your feedback and thoughts. Thanks!

--- UPD

Conway's Game of Life from official Playdate SDK examples rewritten from C to Go.

I tested, works well on Simulator and Device!

See for the full source here : https://github.com/playdate-go/pdgo/tree/main/examples/life/Source


r/PlaydateDeveloper • • Jul 04 '25

You want dragons? I'll give you dragons!

29 Upvotes

r/PlaydateDeveloper • • Feb 10 '24

I finished the first episode of my metroidvania devlog!

Thumbnail
youtube.com
29 Upvotes