Now Reading
Gameplay Loop – Mars After Midnight by dukope

Gameplay Loop – Mars After Midnight by dukope

2023-03-07 10:34:55

I simply completed a vertical slice of the sport and it appears to be like like this:

  1. Work the door to confess martians matching some standards.
  2. Everybody makes an enormous mess of the FREE refreshments, which you must clear up.
  3. Repeat 1 & 2 a bunch of instances till you’ve got sufficient martians.
  4. Select the subsequent day’s occasion, the place to put it up for sale, and which refreshments to serve.
  5. Repeat from 1.

Every little thing right here is alpha degree at finest, which suggests I count on some or all of it to alter earlier than closing. Nonetheless, there was a sale on gifs so let’s not waste the chance.

There is a knock on the door. Flip the crank as much as elevate the window and take a look. Press the A button to open the entire door and admit the entrant or shut the window to reject them.


Panning round with the D-PAD reveals extra of the face, and a few satisfying parallax.


I experimented with utilizing the Playdate’s accelerometer to regulate wanting round however,

  1. The accelerometer is oriented for holding the machine flat on its again. You are wanting by way of a vertical window right here so the metaphor would not maintain. There is a lacking axis that precludes vertically-oriented readings.
  2. The display screen, whereas lovely, is pretty delicate to viewing angle on the subject of illumination. Tilting it round means the brightness is consistently shifting. It is not a typical viewing angle downside, extra of a frontlighting-is-best-from-this-one-angle factor.
  3. I choose the express management of a D-PAD over wobbly gyro controls.

The 3D impact on the window panel is completed by pre-scaling the 2D texture in extensive strips and drawing the proper ones based mostly on some perspective 1/z calculations. Tough however ok.

 Texture strips on the window panel

This window motion was my authentic wafer-thin idea for utilizing the Playdate’s crank in a novel manner. I threw collectively the sport code and procedural martian era fairly rapidly nearly two years (!) in the past. Flipping the window open and seeing some random martian is enjoyable. Typically even humorous. Job completed on this half.

Sadly the wafer was too skinny right here. A kind of “nice the place’s the remainder” ideas that I did not really feel the true shallowness of till it was applied. Working the door at evening on Mars is a cool thought however for what? A bar? Health club? On line casino? Retailer? Hairdresser? And as soon as they’re inside, then what? One thing cool? Nothing? Perhaps extra occurs on the window? Are you able to shoot issues? I not often do fight so most likely not. The martian faces are procedurally generated, if there’s extra gaming past the window, how far past the face do I have to go? Not far please.

Anyhow, some potential however nonetheless so much lacking. As a part of my technique to simply preserve trucking on random shit till an thought involves me, I put collectively an exterior scene of the bar/fitness center/restaurant/no matter.

 Exterior, simply earlier than midnight

To tell the participant of their present bouncer guidelines, I made a giant signal and crammed it with textual content.

 Massive signal, high

“Cyclops Anger Administration” sounded good and that was sufficient to determine that this could be screening for neighborhood help periods — remedy on this case. I figured there have been quite a lot of methods to make visually attention-grabbing standards to match totally different sorts of assist periods. Okay, so it is not a bar or a on line casino, it is a neighborhood help middle.

 Massive signal, backside

On the backside of the signal, I added “Refreshments Supplied” to essentially pack the place. Who can resist free refreshments? This phrase by some means unfurled in my thoughts and grew to outline the sport’s core mechanic. What if refreshments are literally supplied? What would an offended cyclops on Mars eat, and the way?

 Martians eat like this

Martians are slobs and so they love their dune bug pie. You let ’em in, they see your properly ready unfold of scrumptious refreshments, and so they desecrate it. If the meals fits them, they will toss you a number of credit.

 Thanks I assume

Every customer expects a spotless desk, so you may want to wash it up afterwards to arrange for the subsequent one.



Our tolerant lead

To wash the desk, the sport makes use of a comparatively easy stack manipulation mechanic with the slight novelty that you would be able to elevate two stacks directly however the left and proper arms/tentacles transfer collectively. The D-PAD adjusts the place, the B button lifts/drops with the left tentacle, and the A button lifts/drops with the proper tentacle. These controls take some getting used to.

 Cleansing up the stacks a bit

There are a number of fundamental stacking guidelines like plates should be aligned, and narrower objects cannot help wider ones, however we’re not fairly Tower Of Hanoi right here. Every mess solely takes a number of seconds to wash up.

To remind you it is a Playdate recreation, there’s additionally a crank-controlled desk sweeper to suck up the crumbs. All of the objects on the desk must be lifted directly to get a full sweep.

 Sweeping crumbs

Implementing this desk cleansing half was principally simple, with a handful of edge instances. Design-wise it is simply stacking stuff so there aren’t particularly advanced mechanics that have to be rigorously defined or aligned with participant expectations. Nonetheless:

  • The tentacles transfer in discrete steps, which feels a bit odd at first however this is not a full physics simulation so I believe it is okay.
  • It is not all the time completely clear which merchandise you may choose up with A/B — there is no spotlight, plate stacks are fairly tight vertically, and the tentacles are wiggly. It is not laborious to get used to however I could handle this later.

Additionally, I used to be a bit caught on learn how to illustrate the “clear” state that you could restore the desk to, and ended up with two imperfect methods:

 Marked spots on the desk.

The desk has marks to point the place objects needs to be positioned: open circle for plates, closed circle for pie, triangle for knife, sq. for observe. By no means defined in-game, not nice.

 Thought bubble

A thought bubble that seems after idling for a number of seconds to indicate the right association. Additionally not nice. I ought to most likely simply stick a observe on the again wall as an alternative.

Issues have been a bit trickier with efficiency. I’ve acquired extra about this under however the transient model right here is that a few of the drawing features have been written in C (many of the recreation is in Lua) in an effort to keep 30fps.

After admitting sufficient martians, feeding them, and cleansing up their mess, the assistance session fills up and kicks off. Since you are not a licensed therapist no matter occurs within the assembly room is out of sight. Another person handles that I assume.

 Don’t enter

When the session finishes, you’ll be able to see the outcomes. First, martians that have been helped by the subject pays out a bonus. A cheerful two-eyed martian will not get a lot out of “Cyclops Anger Administration” as an example, so it is necessary to confess the proper ones from the beginning.

 Submit-session bonuses

Subsequent, your progress is proven within the context of all the settlement.

 Sobering progress to date


At this level you could lay out the plan for tomorrow. Select the subject, the place to advertise the session, and which meals to serve. Every selection is made in opposition to a map of the settlement, exhibiting martians that need assistance.

1 // Session Matter

 Selecting session subject

Most matters are free to host however a number of require paid equipment. I have never labored out the precise particulars for all of the periods and equipment. One instance is a “Evening Glowers” subject, which requires putting in a swap to chop the lights and examine if the martians are appropriately glowing or not.

 Mild swap accent

Equipment are activated with the B button whereas working the door, and are solely accessible if the session requires it. Theoretically. I have never applied any but.

2 // Regional Promotion


After deciding on a subject, you may have to put it up for sale within the areas the place affected martians dwell. The settlement on Mars is break up into massive districts, the place the value of promoting varies barely. Failing to advertise in a district that accommodates your goal group means they will not know concerning the session and will not present up tomorrow.

3 // Refreshments

 Meals alternatives

See Also

And at last, you could order the refreshments. Some meals are extra common than others in sure areas. Totally different meals have to be dealt with and cleaned in barely alternative ways. Soup, for instance, might spill if moved too rapidly. Martians pays larger refreshment bonuses for meals they like.

4 // Checkout

As soon as the planning is completed, you pay and the day ends.


If working the door was the catchy-but-shallow idea to get this venture going, and cleansing the desk was including meat to the core loop, this planning section is meant to tie all the pieces collectively into a whole recreation with high-level targets, narrative, and gradual progress. Perhaps it’s going to work.

I had a hell of a time designing the presentation and move for this planning section. Even now it is most likely not closing. The mix of unfamiliar activity, small display screen dimension, lengthy textual content record navigation, and map show is all a bit a lot. Tilting the map again in 3D gave me sufficient area to indicate an inventory under, and I attempted to whittle the displayed data right down to the minimal. A part of me thinks I am nonetheless attempting to do an excessive amount of right here.

Coding this recreation in Lua has been an expertise. That is the primary time I’ve used Lua and I am unable to say I am an enormous fan. It has some good stuff like php-style do-everything collections, first-class features, and… effectively I am struggling to complete a triumvirate right here however I assume I can say that the 1-indexing is not that unhealthy. Wait no, I bear in mind a correct third: coroutines are nice and allow a form of concurrent programming that may work effectively to interchange state machines and different finicky patterns.

I might get alongside higher with Lua if it was just a bit extra performant. I actually miss issues like true consts, macros, inlines, and different fundamental performance-focused options. Total it feels very very similar to scripting extension for a core compiled system and utilizing it to construct a complete recreation, even on the comparatively excessive degree I am working at, is past the spec.

A couple of different complaints:

  • Lua documentation is bizarre. The official docs are written like a wordy ebook with chapters and stuff and I nonetheless have not discovered a transparent, medical, versioned language+API reference for the factor.
  • Options which are handy are sometimes sluggish, or have poorly-defined efficiency. Iterating a desk, as an example, may be completed in a number of methods and the straightforward Lua manner is sort of all the time slower.
  • I exploit Visible Studio Code for all the pieces and the Lua step-debugging would not work proper for me. Again to print() debugging.
  • The standard issues with dynamic languages: no static type-checking, no compiler to catch fundamental errors, plus an additional sprint of wonky/costly error dealing with.

Fortunately, the Playdate SDK additionally consists of strong C help. If one thing’s too sluggish in Lua, it is comparatively simple to maneuver that logic to C. A couple of of the issues I am doing in C:

// Line-drawing

The Playdate API has built-in line-drawing help however since I am filling the display screen with strains in some instances, I wrote my very own barely sooner features in C. That is used for the wiggly fonts and pictograms in all places.

// Bezier spline code

The tentacles use some auto-tangent calculation code I’ve dragged round with me over time and that is the precise form of factor you do not wish to do in Lua.

// Optimized picture drawing

1-bit is good for saving reminiscence however an enormous ache within the ass for picture manipulation. Each pixel write to a buffer additionally requires a learn, so there is a a lot larger value to even easy draw operations. Calculating bit offsets may be painful too. Playdate already has nice picture drawing features however I added a number of optimized ones for my particular use instances.

  • Pre-shifted picture plotting. This works just like the previous ZX Spectrum trick of saving 8 pre-shifted copies of every picture so it may be pasted rapidly on the byte-level as an alternative of the bit-level. Buying and selling reminiscence for pace.
  • Sweeper rendering. Drawing the desk sweeper requires sufficient math, strains, and fills that simply porting the logic to C is far, a lot sooner.
  • Tentacle rendering. This makes use of the bezier code and pre-shifted filled-circle photographs to get the tentacles drawing at an honest pace.
  • Shadow rendering. The tabletop shadows are particular sufficient — spaced horizontal black strains — that customized drawing features in C gave me a number of body speedup on {hardware}.

// Silhouette rendering

When working with the Playdate {hardware}, an early shock was attempting to scale/rotate/rework photographs in realtime. Principally, you’ll be able to’t — it is too sluggish. In nearly each case it is higher to precompute the reworked picture offline or throughout masses.

When admitting a martian, I actually needed them to enter the room, strolling in from exterior. To avoid wasting me from having to make extra artwork, that is proven from the again, in silhouette. The scene is drawn with depth so they should begin massive and shrink whereas strolling into the display screen.


Doing this the naive manner, by drawing the pictures scaled and rotated is both a slide present or requires gobs of pre-compute time and reminiscence. My answer was to divide the silhouette into 8×8 patches and rotate/scale the place of every patch as an alternative of every pixel. I name it a tarp and it really works okay.

 Visualizing the tarp patches

Rotating an excessive amount of will expose seams and cutting down an excessive amount of appears to be like fairly tough. Overlapping the patches barely and conserving the size inside protected ranges provides a pleasant natural look that is even higher imo than correct transformations on this slender case.

At this level I have to take care of some long-pending upkeep for Papers, Please and Obra Dinn. As soon as that is dealt with I will get again on this to fill out all of the session matters, equipment, and meals — just one subject and one meals is at present applied. I estimate a minimum of a number of months of labor and my estimates are all the time a joke.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top