PROCJAM / 7DFPS 2018, Day 5

PROCJAM, 7DFPS

Day 1, Day 2, Day 3, Day 4

Unity uses two programming languages:  C# and JavaScript.  I use C# because I like strongly-typed languages.  I want to see as many mistakes at compile-time as possible. But Tracery (which I used to generate Burning Man Camp names) is written in JavaScript. Can I just copy the files in to my project’s directory structure? No! Unity finds several errors in files that work just fine in a web browser.  Searching online reveals two people that ported Tracery to C# specifically for use in Unity.  Both authors caution that these ports are completely unsupported, but that’s good enough for me.  I assign a name to each city block, but displaying that name to the user requires learning how to use Unity’s UI features.  I don’t want to deal with that hassle, so I switch tasks!

The Temple was a giant blank cylinder, and the Man was standing on a similarly boring box. I create a Lathe algorithm to replace both.  The Lathe draws some line segments from bottom to top, then rotates that outline around the Y-axis, kinda like a vase.  This is quite-low-level compared to most of what I’ve built.  I’m not using built-in primitives or importing meshes I built in a 3D editor.  I’m creating the object one piece at a time while the game is running. Not only do I have to write nested loops to place each vertex, I have to remember what order I created them, because the triangles are one giant list of references to the one giant list of vertices.  Speed is important at this level, so I don’t get the luxury of a big tree structure of objects. After writing some triangles backwards, and forgetting a few numbers, I get a shape!

What is this? The light acts like it’s completely flat!  I had missed two things.

  1. Unity stores only one normal per vertex, so if two triangles share a vertex, Unity will smooth the join between those triangles.  I want the angular, low-poly look, so I don’t want any triangles to share vertexes.  A quick sketch shows that each vertex borders six triangles, so I have to edit my vertex generation loop so it creates six times as many verticex!  Now the triangle creation loop needs to use each of those vertices exactly once.  Yikes!
  2. The second step is to call the RecalculateNormals() function.  Much easier!

So much better!  You’ll notice that this temple is spikier than a vase.  That’s “star mode.”  I bring a piece of code over from my bodypaint generator that reduces  the radius of every other vertical row of vertices.

After finishing this project, I am ready to tackle some UI work. People won’t enjoy even the coolest game if they don’t know how to play, so I need to explain myself.  I add a title screen with a list of controls and a bit of story.  This is a game about copying photo.s. The original code name was “Art Fraud” But now i’m having second thoughts.  Taking photos in a magical, beautiful place seems so joyful and positive. Do I really want to flavor it as theft and subterfuge? As a compromise, I let the user select Light or Dark stories. There’s no mechanical difference, but the little paragraph re-contextualizes why one has these photos, and why one wants to re-create them.