Working on the next chapter


1. Thank you players!

Before starting to chat about the progress I’ve made, I would like to thank those who bought the game in early access and gave it a try! I’m looking forward to their feedback and I hope everyone is having a great time with the game! (insert reminder that the price will go up as I release more and more chapters) If you want to play Weirdlab Inc the homepage is here :)

2. What’s in the works ?

So it has been a fantastic launch week! People played the game and seem to greatly enjoy it and apparently no game-breaking bug in view (so far)! With the first two chapters 95% done (some lore might change) I started to work on the 3rd chapter.

The theme for this chapter is (spoiler alert) LASERS!

Lasers are cool and are a staple of sci-fi games since the first years of gaming (space invaders, asteroids, etc…).

My approach on Weirdlab Inc has always been to maximize a physics-like behavior since this is what most of my favorite games make heavy use of physics.

Making physics, however, is pretty hard and especially on the Playdate’s hardware even though the SDK massively helps.

3. Figuring out physics

Figuring out physics took some maths (and this is why you stay in school).

The first thing was to create a line (raycast) and draw it which is harder than previously thought since playdate’s sprites draw in rectangle spaces but after some ugly code I ended up using what I call an “overlay sprite” that covers the whole screen and has a custom draw function that translates the laser segments into actual segments on screen.

Making the laser stop on terrain was relatively easy ; using the querySpriteInfoAlongLine function and iterating on the results to check if the sprite collided is supposed to be solid (using a custom variable system) and then creating a final segment that starts at where the laser is shot and ends where the raycast hits a solid object.

Then came mirrors…

Please respect mirrors

Mirrors are surprisingly complex objects especially when you have to program them. After many failed attempts and with heavy debugging help from Remi (thanks remi) I boiled the logic down to roughly this ;

  • Mirrors have an angle, a collision box and a “surface” segment.
  • When the raycast detects a mirror, it calls a function to figure out where the line is actually suppose to end
  • This function also calculates the dot product and based on a formula, calculates the “reflection” vector of our initial segment’s vector
  • based on the reflection vector, we create another segment for our laser system and run calculations based on it.

This might not be very well explained on text but this should give some starting ground for those trying to follow my steps in this risky endeavour. Mirrors took some time and fiddling to get right but I’m happy with the results, pictured with the following GIF : testing mirrors

Mandatory Lua complain time

Did you know Lua doesn’t have a continue keyword to skip the rest of a for loop’s logic so you have to use a dirty goto

Creating the light detector

This was pretty easy appart from my first visual glitch with playdate’s sprite rotation which deleted a black outlne for some reason…. I used roughly the same surface trick from the mirror system to make the line look good and the activation is just a matter of calling a sprite’s function. light detector in game

4. Expectations for next weeks

I went in vacation right after releasing the game in early access (production on friday isn’t good I know, but I got lucky) and i’m still in vacation so don’t expect a big game update until at least end of August but I’ll update you regularly on my progress using itch.io’s devlog system.

I won’t spoil level solutions or lore don’t worry and I hope you enjoy me sharing the technical side behind making playdate games even though I keep it at a high level. I have strong hopes that someday I’ll be able to show my code at a playdate gamedev conference and say “this part was where I learned how to use Lua and this part was where I started to understand” or something along those lines.

If you have any questions be sure to mention me on Playdate Squad’s server or on the game’s server and if I’m online I’ll probably answer same day. If you want to experience my game it’s here thanks for reading and thanks again to the early players!

Get Weirdlab Inc

Buy Now$2.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.