The latest update, 0.9, is a doozy. It takes the project from a demo to a game, and is actually pretty fun to play, and challenging depending on some RNG. Check out all the gameplay details here.
A serious issue arose as I closed out this update: after adding a ton of visual improvements, about 12 new cards, new art, and making alterations to the draw functions (to avoid using "while" when possible), it looked great on the web emulator.
It caused a full system crash on the Playdate. The crashlog was a bunch of text about the "random" math function not having a second variable (as in, it was "random 1,..."). This was obviously not the case when I wrote the code and ran it in the emulator, so I had no idea what to do.
It only happened on the second and later card-select screens, never on the first one and never during a round of gameplay. I ultimately had to hunt down every random function I was using on each of the card-select screens and remove/replace them. I shifted the randomization functions to other parts of the code, and I tried to front-load the randomization (like a randomizing seed) in case it had something to do with running random after already calling so many variables.
Ultimately, I also cleaned out a bunch of leftover code that came about from copying rooms that served different purposes. The card-select screen had a bunch of events related to combat (which doesn't happen on the card-select screen), and it had "shuffle deck" written into the "enter" event. I left that originally because it doesn't hurt to shuffle the deck before adding new cards, but it wasn't necessary either. The extra uncalled events were similarly unnecessary but (in theory) harmless.
Between rewriting my randomization and removing those leftover lines of code, the problem was fixed. Unfortunately, the current version has shuffled rather than random card pools (meaning no card can show up twice at the same time), but the game runs.
I still have no idea what caused the issue; every line of code that I removed from the second card-select room was also present in the first card-select room, which never caused a crash. The borked copy of the code (before I restructured it) is attached, if anyone wants to take a look. Again, this runs fine in the web emulator, but crashes on the playdate (and refuses to compile if pulpmilled, and sometimes throws errors in the desktop simulator).
Playcees-mod-0.9_20220803005341.zip (197.7 KB)
The big lesson I learned is: test on device as frequently as possible, so you can quickly identify which version introduces strange errors like this.