Showing posts with label famjam. Show all posts
Showing posts with label famjam. Show all posts

Tuesday, March 2, 2021

Text Resources, Magic, and the 12th FamJam

On Sunday, Febrary 28, my family completed our 12th FamJam, marking one year of monthly jams. The result of the jam is Rescue Writer, a typing game designed by my third son. My wife put it well when she said that this game did not capture the family's imagination, but the two younger boys seem to enjoy it. Despite its being unexciting, there were some interesting happenings in the development, and hence, this post.

I wanted to have a word bank that anyone in the family could edit. Clearly, this could be expressed as an array of string literals, but that's an awful lot of wasteful quotation marks and commas. I wanted to just have a plain text file, but it wasn't clear to me how to do that. After some tinkering, I was able to get the WordBank script to behave as I wanted. I created a text resource file—res://assets/wordbank.tres—that is loaded by the script and processed line by line. I am pleased to report that it works well in the editor and when exported to HTML5.

The original version of that script ignored duplicates, which was fine when we had 30 words. As we kept working, though, different people added to the word bank, and duplicates were inevitable. My wife, who works downstairs from me during the jam, sent a message asking if the script removes duplicates. It didn't at the time, but I went ahead and added the lines to handle it: the script skipped over duplicates and printed a message to the console that a duplicate was found. My wife's response was, "That's like magic." 

This was really interesting to me, but I tried not to get distracted by it while actually working on the project. To me, identifying and ignoring duplicates while reading a text file is completely mundane. Indeed, I am having some difficulty articulating how completely uninteresting detecting duplicates is in my conception of software development. The difference in perspectives is fascinating to me. What other things do I take for granted that an outsider would consider magical? How does this impact my capacity to operate in the world or, perhaps, to teach novices? At one point, removing duplicates from a plain text file was likely impressive to me, but now it's just a thing that must be done in order to do something else.

Wednesday, January 13, 2021

Reflecting on almost a year of FamJams: What the family learned

I will be giving a presentation at GodotCon 2021 entitled, "(Almost) A Year of Fam Jams". The presentation will be a summary of how my family started doing game jams together and what we learned from the process. It draws liberally from my blog posts on the topic. The presentation is already recorded, and the conference organizers will set up a time that it streams, during which time I will be online to answer questions.

In preparing for the presentation, we had a family meeting in which I asked everyone what they learned over the past year and what advice they would give to someone who wanted to start fam jamming. This was an interesting exercise, and one thing that stood out to me was that some of them were happy to give advice that it wasn't clear they themselves had learned yet. "Do as I say, not as I do" is a powerful human capacity! I hope they understood when I pushed back on these points, because I wanted to make sure I distilled our true and best ideas for the presentation.

I took more notes from this meeting than I could fit into the presentation. This blog post gives me a chance to share my notes more exhaustively. I will start with the youngest family member and move up from there. I believe this order might be enjoyable and also demonstrate the differences in ability to form abstractions and conclusions. I have listed the items so that the first statement captures the essence of what the family member shared, and then I provide my commentary on that item after that.

#4 Son:

Put the game's name on the title screen. This was one of the first things anybody said in response to my question, and it made me laugh. He's right! We do always put the name on the title screen. Now, it's less clear to me that he understands the value of this in setting the expectations of the player or conveying the theme, but that will come.

Make sure everyone can work at the same time. That is, he recognizes that we don't want to be in a position where anyone is "busy-waiting", such as waiting for access to a particular machine or resource. Astute!

#3 Son:

Use the black keys when composing music. Readers may recall that this son is very interested in using LMMS to compose music for the games, and I showed him many months ago that he could avoid some dissonance by using only "the black keys" to get a pentatonic scale. He's latched on to that, and his compositions have been more ear-friendly for it.

Make the game's music match the theme of the game. This is a great observation, and I think it first came up in Get the Food. We definitely came back to this idea in other games, too, including Find the Ornaments, where we talked about what might make a song sound like the holidays. (Also, I don't think it only comes in games titled Verb the Noun, but more data may be required.)

#2 Son:

Have someone who can do everything that needs to be done. His point here is that you don't want to have three people who all want to write the music for the game and nobody who wants to do art. It's an interesting perspective, since I tend to think about it the other way: design the game such that it leverages the abilities and interests of the people involved. In fact, my wife brought up this point in response. Both sides are true, and I'm glad he brought it up.

Playtest with people who didn't program the game. He has noticed that if his older brother and I work on the programming, we might sometimes have blinders to things that are wrong or just feel bad. Again, this is a pretty astute observation. At first, I thought he meant people outside the family, but he really just meant that people inside the family should be giving feedback during the whole production process. 

Leading does not mean you tell people what to do and wait until they are done: it means you check in with them and give them advice. This is an amazing point, and I remember that he struggled a bit with it the first time he was creative director. I think it was something like his telling other people to work and then his sitting down with a book. He got the idea, though, and we worked through it. Now, he is much better about communication, negotiation, and critiquing. 

#1 Son:

Prototype the gameplay with blocks. That is, don't get caught up in producing and perfecting the minutiae before you get the big ideas working.

It's fun to make different kinds of games. I couldn't agree more!

This son also mentioned something that may seem pedestrian, but it's really not: how to use Godot Engine. He's become quite accomplished with it, to the point where he can navigate the documentation and forums and figure out pretty much anything he needs. Right now, he's looking into networked multiplayer games; we had a good talk about IP addresses on our family walk yesterday. 

Lovely Wife:

Do drawings in pen or marker—not pencil—for ease of cropping and scanning. She has spent a lot of time post-processing the kids' hand-drawn artwork, and this is a nice, easy pro-tip.

Even though each game is different, there are certain things that you always need, such as fonts. I sometimes forget that, coming into it, my wife really had no idea how video games were made. That is, just because someone is smart and my age and played some video games doesn't actually mean they know what goes into the engineering of them. Now, she sees the patterns that I took for granted, like the idea that there are certain elements that you always expect to be on the to-do list.

We face challenges sharing workstations, and it's better to have each person have easy access to their own machine. She and I have tried to manage the proliferation of devices in the household, and we don't have a one-laptop-per-child policy. We have Old Lappy and New Lappy. Sometimes, this is not quite enough, and we're still trying to figure out the best way to manage all the technology needs and desires.

It is useful to follow genre conventions. Our first game was designed by a five-year-old and defies expectations, but after that, we moved more into conventional forms. This has been helpful for allowing everyone to imagine what the end product might be. It also has become easier as we have learned more about the tools themselves, since the tools are designed to help with common problems.

Determine your screen-size early. We had some mismatched expectations in our early jams about how to manage the size of screens, in part because the programmers saw this as flexible but the art production required it to be fixed. Now, we set the screen size early on, which means the prototype programming matches the expected final look, and the art comes in without needing to be resized multiple times.

Use drawing templates for young artists. As of The Flying Planes, we have been focused on trying to get more art into the games. In theory, this is simple: if we can put in one plane, then we can put in several. In practice, the kids drew them in all different shapes and sizes, which made it hard to get them all to fit and look right. Now, if we know something is to be mass-produced, she provides the kids with a rectangular template, which is really the bounding box. This makes it easier to scan and process as well as to integrate into the game itself. 

Determine a palette early. This is a standard graphic design idea of course, though it's not something most kids (or maybe anyone?) thinks of. The games that have had constrained palettes are certainly easier on the eyes. Maybe this would be a fun area for us to grow with the kids, allowing them to explore palette creation and see how they affect the look and feel of the game.

Final Thoughts

It was fun to go back through these notes. If you got here from watching the GodotCon video, in which I acknowledge that I would probably have to write a blog post to get all my notes together, I hope you enjoyed it! As always, please feel free to leave a comment, especially if you have some tip of your own to share with the community.

Tuesday, December 22, 2020

Find the Ornaments: Thoughts about the December 2020 Fam Jam

My family has continued to pick a day each month for a Fam Jam, although I have not written a blog post about it since June. Yesterday, we completed the December entry, Find the Ornaments. The ten-year-old was the Creative Director, and over breakfast he expressed his idea primarily in terms of mechanics: he wanted an endless runner with collectibles. His original sketch included sharks and water, but our discussion turned it into a more holiday-themed game. Whereas some of the more recent games have been fairly straightforward in their implementations, this one required my learning some new tricks, and so it seems like the right time to gather some learnings here on the blog.

We knew we wanted to do long jump or short jumps depending on how long the jump button was held down, but neither I nor my 13-year-old had ever programmed this before. We started by trying to simply puzzle it out from first principles, but when it become clear that this was trickier than we initially expected, we turned to the 2D Platformer Demo for inspiration. The code here is strange, as it contains what should be good ideas (like functional decomposition) but expressed in such a way that make it very hard to follow. For example, at one point, the instance variable _velocity is assigned the result of calling calculate_move_velocity, sending _velocity itself as a parameter. Within the implementation of that method, the formal parameter name becomes linear_velocity, while there is local variable velocity that is used to build a solution. So, we use the velocity to compute the move velocity by sending the velocity to the linear velocity which returns the velocity. Not ideal.

I was also puzzled by the fact that I could not figure out where gravity was being applied. Clearly, something had to be pulling downward on the kinematic body of the player character, but where was it? My son pointed out that it was in the superclass script: it had a one-line _physics_process implementation that adjusted _velocity.y downward by gravity * delta. I pointed out that this could not be the code that was doing it because the Player class' implementation of _physics_process was not calling the superclass implementation. He looked puzzled and repeated that the superclass implementation was doing it, and so that was doing it. After searching online, I discovered that this is explained in the documentation, at the end of the "Inheritance" section, but not with anything like enough of a caveat as a seasoned OO programmer would expect. It turns out that overriding a method has two different semantics depending on what is overridden: if the method is an engine callback, then all superclass' implementations are called automatically; if the method is a custom method, then superclass methods are not called unless invoked explicitly in the subclass using dot notation. That is weird. It boggles my mind to think that the GDScript designers thought this was a good idea. I also wonder what kind of expectations it builds in the minds of people like my son who program primarily in GDScript but who will likely explore other languages later.

Coming back to the problem of short and long jumps, once I got my head around the semantics and the awkward program structure, I was able to see the pattern in how the demo solved the problem. It is an interesting inversion of my expectations. In our first, from-scratch implementation, I had been thinking of the character as going up while the jump button is pressed, but to a determined zenith, such that releasing the jump button would result in the zenith's coming sooner. The demo's approach was rather to launch the player at a predetermined speed upward, and then if the jump button is released, to apply a one-time decay to the upward velocity. This approach is much simpler than what I had considered because it fits neatly into the idea that each actor manages its velocity, rather than trying to determine a target location and solving for the necessary velocity on each tick. We implemented this approach and it worked great.

In between programming tasks, I worked with another son on the soundtrack. My wife had encouraged him to try transcribing one of the Christmas songs from his piano book into LMMS rather than starting from scratch. He gave me a thumb drive with the result, and I had to laugh. I assumed he had made grievous errors in transcription, so I sidled up next to him and the laptop to review and help him see what he did wrong... but aside from lacking measure alignments, it looked correct! That is, the phrases drifted from the beginnings of measures, in part because of a discussion earlier that morning, when I encouraged him in his own compositions to think about pauses between phrases, but the pitches of "Jingle Bells" actually looked fine. Puzzled, we started a new project and put in the opening phrase using a different sample, and this worked fine. The problem turned out to be the e_piano_accord01 sample that he was using, not the transcription. Now that's unexpected! This morning, I searched a bit and found a discussion on the LMMS forums in which it is pointed out that several samples have the wrong pitches. This actually helps explain some of the other audio strangeness in his past compositions: he might not have the sensitivity to know when he doesn't have just dissonance but actual out-of-tune samples... and I'm pretty sure e_piano_accord01 has been one of his go-to samples. I am not sure the best way to help him out with this on future projects. I could print that discussion and ask him not to use those particular samples, or perhaps I could download for him a MIDI soundfont and encourage him to use that instead.

The next major programming challenge was to implement the generation of tiles for endless running. We had made an endless runner before, but it had a simple, continuous ground with randomly generated obstacles; that approach would not work when making sequences of ground tiles that can have holes in them. For yesterday's jam, my son started on the feature by implementing a timer that would dump out tiles at a fixed interval, but I did not care for this implementation because this interval would then have undocumented dependencies on the speed of the character and the difficulty of the level. He had a Zoom meeting to attend, so I took this over and redesigned it, but I stumbled onto some other missteps as well. These were rooted in the fact that, from the beginning, we decided to have the character static and the tiles move past him; the more I worked with this, the more troublesome it was, in part because the math was all based on trickery. That is, in the narrative of the game, the elf is running forward, but in the code, we had the world moving past him. The first major improvement I was able to make that I felt good about, then, was to change that around and have the elf move forward in game space. This allowed me to align generated tiles with specific, integer coordinates instead of pulling shenanigans with floats and deltas.

To generate tiles lazily, I remembered a technique from a UE4 Endless Runner tutorial series in which triggers were used on each tile to tell the game to generate a further tile. This is a nice approach since it should scale indefinitely, or at least until the representational limits of floating-point coordinates. It is the approach that I took then. The logic for handling passing these tile-triggers was also easily able to be repurposed for the generation of ornaments.

The next technical challenge I faced was to place the collected ornaments onto the Christmas tree at the end of the game. I drew the outline of the tree as an irregular quadrilateral using a hidden Polygon2D. Then, the problem was to generate a random point inside this polygon. I could neither find nor think of a clever way to do this, but a clear brute-force method appeared before me: generate random points anywhere on the screen until one happens to fall in the tree's bounds. This simplifies the problem to one of determining whether a given point is within a polygon. Surely, there is an easy way to do that in the engine, right? Every search I did took me to discussions like this one, where the answer was either to do an awkward snapshot of the physics engine state space or implement a complete raycasting algorithm. I was quite frustrated and shouted out more than once that we should just do something different and easier. Near the end of my rope, I did something like this at a time when my son, working nearby in my office, had finished his own train of thought, and he said, "There is a method to determine if there's a point in a triangle." My response was, I believe, "What." He insisted he had seen it, and once we looked together, we found the Geometry class, which contains the method point_is_inside_triangle and, more importantly, is_point_in_polygon. (Note again the awkwardness of inconsistent naming conventions!) Of course, these methods do exactly what I needed, so that the hour of working on this feature only actually took five minutes of meaningful effort. What really puzzles me, though, is why searching for any related combination of words fails to find any reference to these useful utility methods. Maybe I can break ten readers on this blog post and help some other poor folks who end up in my situation.

Those were all the interesting technical problems that arose in the development of Find the Ornaments yesterday. It is always frustrating to spend more time on a feature than one thinks it merits, but on the other hand, each such adventure leads to more tools on the toolbelt. For example, when working on the parallax scrolling yesterday, I started by just trying to remember the right combination of settings, but then it was much easier to just pull up The Flying Planes from two months ago and see how we did it. Incidentally, if you do take a look at that game and this game, and compare them to some of our older efforts, you'll see some of the amazing tricks my wife has learned in Inkscape to make beautiful vector graphics backgrounds.

Thanks for reading! I hope you enjoy the game. 

Sunday, June 28, 2020

Fam Jam #4: Get the Food (and a few words about #3)

I will start with a few updates. We did do a Fam Jam in May, but I did not write a blog post about it. #2 Son surprised us by wanting to create a game around mechanisms of practicing arithmetic, and the result is Math Traps. It was a fun jam, but perhaps the most interesting part is how excited #3 Son was to make the soundtrack using LMMS. I also recently put together a public-facing page for the family's github organization. http://the-g-force.github.io/ shows all of our fam jam games.

Now, though, I turn to the main focus of this post: your June Fam Jam.

The Jam was yesterday, and we all worked together to create Get the Food. The game was the second one for which my youngest son (5) served as creative director, his first being Joe Johnson Gets Captured from our first jam. We decided to give him the reins once more rather than moving up in age order, since my oldest son is really already capable of building pretty much anything he can imagine.

It was a kind of difficult to get the youngest to focus in on an idea during our morning meeting in the living room. He started by describing a guy who goes through a magic portal to a campground, and he has to avoid the traps in the tents. Then he gets on a motorcycle and goes somewhere, I cannot remember. Also, he's fighting bad guys, and also he fishes. I'm pretty sure he just unwittingly designed a Zelda game. In any case, we tried to encourage him to rein it in, to focus in on one idea that we could all get behind. The fishing idea seemed to get some traction from the family, and in the course of the discussion, it changed from fishing to being a fish.

#2 Son was excited to apply his recently-developed skills with Piskel to create pixel art. His first fish was created before we settled in on the right screen size, and it was a frustrating conversation to point out that we had our cart before our horse. Once we got the screen size sorted, he made all three animated fish that are in the game.

#3 Son was very happy to work on the soundtrack. His first pass was very busy, with a lot of pasted blocks between tracks. That is, he would lay down something like a bass track and then copy that to the drum track and another bass track, just playing them at different times. It's not all bad, but it's very busy. I worked with him more yesterday than in the past, trying to help him understand a little bit more about composition. In particular, I tried to show him that most instruments just hit one note at a time, especially things like the bass. At one point, I pulled together a simple set of five tracks and challenged him to write something where none of them hit more than one note at a time. Somehow, however, he lost this file or something, since when I came back to where he was working, he was doing something completely different, with some instrument patches I would not have chosen for an underwater game. We worked a bit more, with me trying to encourage him to move notes just to the white notes, in hopes we could at least get something in C Major. It was during this process that I had an epiphany: instead of encouraging him to put everything on the white notes in the piano roll, why not encourage him to use only the black notes? The result would be a pentatonic scale, with significantly less opportunity for dissonance than without this constraint. We were both happy with this result. If you listen to the main theme of the game that plays in the background of gameplay, it is all pentatonics (after I helped him move a few errant tones to the black keys). The theme that plays on the title screen is an excerpt from the first piece he wrote that morning.

#1 Son, as mentioned earlier, has become fairly adept with Godot Engine. The code that he writes is still pretty messy, though, with names that don't always match functionality. He also makes amateur mistakes of perspective. We had an interesting conversation around the relationship between the player-controlled fish and the aquarium scene. I suggested that, instead of having the Aquarium script manually move the player fish around, instead we just have it tell the fish where the player touched. He said, "That sounds complicated." I responded that his perspective was upside-down. Coupling the player-controlled fish to the aquarium was complicated, but putting the fish's behavior into its own script was simpler. There's a sense in which we are both right, and it's just a matter of experience and its concomitant wisdom. Using my approach, though, I explained how we could then reuse this fish behavior in our enemy AI: both the player-controlled and AI-controlled fish had behavior determined by having a destination specified, but it was only a difference of who specified the destination.

We ran into a strange problem late in the game development. #1 Son and I had set up what we thought was a robust approach that would allow for easy adding of different kinds of enemy fish. However, when we got the new art from #2 son for the second enemy fish, it was a different size than the other. This meant that it needed its own collision shape, so we ended up making it a subclass of the original enemy fish. It felt to me at the time like switching to a delegation rather than inheritance approach would be better, but it wasn't clear that we could make this change fast enough for a jam. This approach worked, but we also had trouble that I still don't completely understand. The second fish was not detecting the flakes, but it seemed to have to do with its proximity to the bottom of the tank. We never did figure it out, but #1 Son came up with a workaround that involved using multiple physics layers and masks. Honestly, I struggle to think through the layers and masks system—it is not intuitive to me, so I was grateful that he was able to come up with a workable solution.

I hope you enjoy the game. We went for a nice family walk when we were done. Everyone shared something they learned during the day, and then I also asked each person to share either a question they had or something they wanted to try next. It was a fun, casual reflection session. I also mentioned to them that we could try a different jam format, such as giving everybody the same assets and seeing what they can make with it. #1 Son is adept with Godot Engine, and #2 and #3 can both use Construct. #4 Son and my wife would be left with paper prototyping perhaps. The big idea, anyway, is that I think they're excited to keep making things together, and maybe to try some different modes. Of course, I think #3 is just waiting for his chance to be in charge again so he can draw from his love of rockets and enjoyment of Totally Reliable Delivery Service.

Sunday, April 26, 2020

Fam Jam #2: Rocket and UFO Game

After the March Fam Jam, the boys were clamoring to do it again. "We should do one a month," they shout, because shout is the default volume level with four boys in the house. I love their enthusiasm and that the joy they get from the experience overrides both the essential and the accidental frustrations.

TL;DR: We had fun making a game, and you can play it online right now (as long as you have a keyboard). Here's a gameplay video for those who cannot play it directly:


The night before the jam, I did a little bit of prep work. I knew we would end up using Godot Engine since that's what #1 Son has been spending a lot of time with. I set up a repository on GitHub, copying over some of the structure and utilities from Canning Heroes Special Edition. I completed that project since the last Fam Jam, and in so doing, learned more about best practices for Godot Engine projects and how to script builds and deployments. Whereas Joe Johnson Gets Captured used the repository docs folder to publish on GitHub Pages, and hence had the problem that pushing and deploying to master were the same process, Rocket and UFO Game takes a more elegant approach of using the gh-pages branch.

Around 7:30 in the morning, with my morning cup of tea, we set a deadline of 8PM to finish the jam. We formally assigned #3 Son to be the Creative Director. He had been asking for days—maybe weeks—if he would be in charge next. I cautioned him that we had to have modest scope, as we only had one day. He asked if we could extend the deadline—this kid has already learned something about estimation! I reminded him that we had just set the 8PM deadline, and #1 Son commented that the deadline is a crucial part of the jam process; he has done a few jams now and clearly has gotten his head into what it's all about.

Our Creative Director paused as he tried to simplify his design ideas, and then he said he wanted a game in which you control a rocket that is always moving forward, with a force field, who shoots UFOs that drop chickens. Makes sense to me! I expected his design to include more technical details of rocketry, since this is the kid who devours any information about NASA, the Apollo missions, rockets, and so on. He's currently saving up his allowance money to buy a fancy Saturn V model kit. I am glad he chose something a bit more modest and conventional.

I dug into some of the rocket controls while my wife and #1 Son made some delicious sourdough pancakes for breakfast. They used sourdough starter that is literally older than I am, gifted to us from a family friend. In my first pass, I kept track of velocities and changed the position of the rocket on each tick, but then something I read reminded of the built-in move_and_X methods. Using move_and_collide instead clearly was the best option, and so that's how I approached the rest of the pieces.

After breakfast, we made a more formal plan of who was working on what, and the day proceeded with excitement and creativity. Here are a few vignettes:

I wanted an infinite scrolling field, but we could not sort out how to make that work, and so we ended up just bounding space. I would like to investigate how a background could be infinitely scrolled under a camera, since it seems to me it must be possible.

#2 Son had a blast using bfxr to make the sound effects. He also made a song for the game in LMMS, but when we put it in, the intensity of the music crowded out the sound effects, and it was hard to tell what was going on. We moved that song to the title screen instead.

I wrote a short loop for the main gameplay, with the idea that I'd hand it over to #2 Son to add some leads, but clearly we were having a mismatch. I think I assumed he had a bit more savvy around how music and songs were structured than he does, so I just took this over. Ironically, then, my first song was terrible. It was in Dm, and that was just wrong for a game with space chickens. I threw that away and did a similarly-voiced song in E major. The B part of the song was, again, terrible, so in the interest of time, I tossed it, and we're left with a 12-bar loop that is similar in tone and repetitiousness as Goofball's.

It may seem like a small thing, but I think the flames that come from the rocket are wonderful. #2 Son took a stop-motion animation class with BSU animation professor Brad Condie last Fall, and one of the most interesting things I saw him do was make a crackling campfire. I had never really thought about anything like that before: he insisted it was relatively easy, but like so many things, it's all about knowing the tools of the trade. I encouraged him to work with #4 son to collaboratively draw a few frames of flame animation for the rocket. We got those scanned and put into the game, and I think they are great.

I disagreement with my wife in the morning which made me reflect on how she was too peripheral to the process, so I did what any loving husband would do: I taught her to use git. We set her up with ssh keys and a GitHub account and downloaded Godot Engine onto her machine. I gave her a primer on how to interact with the version control system, and in no time, she was able to not just make content, but integrate and test it herself. Once she got her sea legs, I explained to her that in my multidisciplinary game studio classes, my rockstar artists will make sense of version control, which empowers them to be first-rate creative contributors to the project, whereas my timid members will avoid learning about version control and, as a result, only ever be on the periphery of the project.

Incidentally, I (re-)learned two important facts about git during this process:

  • Using git pull --rebase will avoid those annoying merge commits.
  • git clean -n and git clean -f will clean out junk such as post-merge detritus from a repository.
Later in the day, my wife wanted to approach the title screens by designing them in Inkscape and then exporting them as images, as she had done in the March FamJam. I explained how parts like the instructions should really be done in-engine so that we can change the text easily, and how even the logo of the game, if it is only plain text, could also be done in-engine. Both of these reduce iteration time, which happened to be the concept that sparked our little disagreement in the morning. She had already become proficient with git and could run the game herself, so I gave her a quick tutorial on how to design a UI within Godot Engine. She has a lot of experience and talent with desktop publishing applications, and so she took to it like a fish to water. Later in the day, she even tried to copy some of the scripts that my son and I had in place to drive the menu system, in an attempt to integrate the credits screen herself. We had to help a bit here because of the unintuitive signals system, but I give her credit for the confidence.

It was exciting to see how #1 Son was an essential developer on this project. He's been doing jams with me for a few years now, but he has often been something of a legitimate peripheral participant. The last few weeks, he has been excitedly working on some side projects in Godot—projects I have been mostly outside of, aside from the occasional bugfixing tip. For Rocket and UFO Game, he handled a lot of the code himself. Some of this was a bit awkward, such a his first attempt at programming the UFOs. He knew he wanted them to follow a path, so he made them into PathFollow2D objects themselves, with Sprite children. This meant that the UFO scene started with a compiler warning, since PathFollow2D nodes need to be children of Path2D nodes. He was unconcerned but also could not think of another way to do it. I showed him how, instead, we could make the UFO into a plain old Area2D node, allowing it to be tested independently, and then programmatically create the PathFollow2D node as a parent of the UFO when it is spawned. We plan on doing a code review later today to see if there are other places where he can learn some new ideas.

By supper, we had everything in place except for the force fields. I was concerned that, with only about two hours until our deadline, we should probably focus on some balance and polish issues. The rest of the team really wanted to put in force fields, and so we decided to go for it. #1 Son really did all the development on this feature, while I fought with a frustrating bug in the sound system. The takeaway on that one is to make sure you use AudioStreamPlayer and not AudioStreamPlayer2D for your music. That's the kind of kick-self-in-pants idea that is obvious only after spending an hour trying to track down the bug.

We pushed the final version of the game to GitHub at 7:58PM, coming in just under our self-imposed 8PM deadline. We played a few rounds, the high score being, I think, 24 chickens. After that, it was time to get the littler ones to bed, and the rest of us played our worst game of Just One that we've ever done. I think we were all tired and, perhaps, had used up our luck for the day.

That's the story of Rocket and UFO Game. I hope you enjoyed reading about the experience. I definitely encourage you to try something like this with your friends and family. One thing that has struck me is that it's much more fun to make something in a tight timebox than to start something more grandiose and fizzle out. I'm not sure yet what that means for my summer, since I'm still having a hard time getting my head around the impact of my constraints. In any case, thanks for reading, and enjoy Rocket and UFO Game. All the source code is available on GitHub under the GPL v3, so feel free to study it, tinker with it, and learn from it. 

Sunday, March 22, 2020

Fam Jam #1: Joe Johnson Gets Captured

I've been talking to my friend Ian Schreiber off and on for a long time about "fam jamming", or running a game jam with families. I've never actually done one; it always seemed like something else would come up. Now that everyone's stuck at home to stop the spread of COVID-19, it seemed like a great time to try it. Ian's primary advice was twofold: first, he advises to put a kid in charge of the vision while parents do what the kid says. This inverts the usual control structure, empowering the child and fruitfully humbling the parents. Second, he recognizes the different "superpowers" of the two classes: children are endlessly creative, and adults know how to get stuff done. Leverage these powers and use them for good.

Early yesterday morning, I surprised the family by saying we'd be doing a one-day family jam, and that #4 Son (who is five years old) would be in charge. Perhaps I shouldn't have surprised my wife with this; I had mentioned it to her in passing but she didn't know to plan on it for Saturday. However, once again we have the benefit of not really being able to go anywhere else. I encouraged #4 son to take a few minutes to sketch out some ideas, so he left to the crafting table and came back almost immediately with an idea about a mushroom and a turtle who are underwater and shoot at each other. The mushroom's attack shots are blocked by the turtle's block shots and vice versa. That more or less makes sense. Then he told us how after defeating the turtle, there is a crate you have to smash with a chainsaw in order to save Joe Johnson. Well now, this suddenly got much more interesting. I have no idea where Joe Johnson came from, but it was clear that we had to save him.

During this phase, I tried to ask some probing questions to understand what he was expressing. One of the other boys tried pushing toward something he wanted to make, so I jumped in and explained that #4 was the creative director: we could ask questions, but it was only to understand what he wanted us to do. This is a funny spin on Ian's advice for bigger families, since it's not like the other son lacks creativity or is particularly good at getting things done. However, he was very respectful and understood the exercise, and I think that itself was a small blessing from this project.

The original concept art for Joe Johnson Gets Captured
In the center of the image above is the original concept art for the game, showing a mushroom man who shoots circles and a turtle who shoots triangles. It was explained that they are in the water, standing on the ground, and the sky and sun are above them. The seahorse was added later. Around that original rectangle, you can see some of the other pieces that were added as the discussion went forward. On the left center is Joe Johnson, who is wearing a pink dress. In my work, I tended to refer to her as Jo Johnson because of the dress, but the rest seemed happy to have him be Joe Johnson. Fine by me, as the important thing is saving him. In the upper left, you see a "chainsaw", which the careful observer will notice is actually a hacksaw. I wonder if this was inspired by peering over my shoulder as I've been exploring One Finger Death Punch 2. (Wholesome family entertainment.) Across the top right are the original drawings of the triangular turtle bullets and the round player bullets, with an annotation about which button on the controller would fire them.

We talked briefly about platforms and tools. I am most productive with Unreal Engine 4, and my oldest son has some experience with it (such as at Global Game Jam). However, it is tuned for native delivery, and Epic recently removed the capacity for HTML5 export, which means that the artifacts are harder to share with distant family and friends. One can rebuild the engine from source to support HTML5 export, but that was definitely out of scope for a one-day jam. My two older sons have built some lightweight games using the free version of Construct 2, which is great for letting them explore ideas. I have relatively little experience with it, however, and honestly I don't have a lot of incentive to learn it. On the other hand, I have been increasingly curious about Godot Engine and I can see a lot of benefit to learning it. Games from Scratch has been singing its praises (although I know this more from reading the titles of videos than watching them), and I recently talked to Mike Sellers about how it is used in IU's Game Design courses. The whole engine is released under the MIT License, which is also very attractive. In preparation for the fam jam, I had built a very small tech demo the previous day in Godot Engine, before only ever having tinkered with it once to work through one of the stock tutorials with my oldest son. The tech demo was enough to get my head around some of the core ideas and validate how easy the HTML5 export was. I could see that this would probably be enough to go in mostly-blind to build a one-day project designed by a five-year-old. This established, we settled on Godot.

So as not to bury the lede (maybe it's too late for that...), you can play the game online or check out the source code via GitHub. It was a few hours in that we asked the lead designer what to call the game, and he offhandedly came up with Joe Johnson Gets Captured. It's catchy. The result, well, it looks like it was designed by a five-year old, but we're all pretty happy with it.

What I'd like to do next in the blog is provide a few vignettes about the day, rather than continue in a chronological fashion.

Title Screen

Production

One of the major challenges I faced was trying to fulfill the role of a producer on a five-person team with such varying levels of skills. At the beginning of the day, #3 son asked what to work on, and I suggested storyboards... which of course he had never heard of, so I had to provide some guidance. This poor guy was caught in between ages, not being quite advanced enough to do some of the technical work, and not being the youngest one who was sharing vision and giving feedback. My oldest son and I did the technical and integration work from my upstairs home office, while my wife worked in her downstairs home office. Even just this small physical separation kept us out of sync, where we didn't know where things were, and she didn't know what integrated work looked like. #1 son and I used git to share our work, but oh how I miss the asset locking that's so easy in UE4 with Perforce. Also, there seems to be known troubles with working across Linux and Windows machines in Godot because of line ending problems. Seriously, in 2020, in release 3.x of a popular game engine, this is still a problem. Still, between GitHub and Google Drive, spread out across three rooms and four computers of the house, we were able to bring everything together before 9PM.

I'm not entirely sure what I would do differently next time. It would be nice if we could all work together in one room, but I am sure neither my wife nor I want to give up our dual-monitor setups. I think we could get #2 Son at least more actively into Godot Engine in a future project, especially in the post-project exploration I've done of some of the tools as discussed below. I also need to remember to look carefully at that link I shared above to make sure I'm taking the best possible precautions against the silly line-ending problem, which caused us a lot of unnecessary headaches yesterday.

Music

A few weeks ago, I came across this video about using LMMS to make music for games, and my second son happened to watch it with me. He became interested, so we installed it onto the family laptop and he tinkered around a bit. For this fam jam, we put him in charge of the soundtrack. The truth, though, is that he doesn't have the musical knowledge to quite know how to structure a song: common rhythms, intervals, chords, etc. His first original composition is actually used in the loss screen of the game: it's actually a perfect fit for this part of the game, though musically, it's pretty clearly the result of kind of aimless messing around with LMMS.

Our lead designer said that he wanted the game to sound like Istanbul (Not Constantinople), which is a family favorite. I had written out a simple arrangement of that song, and I encouraged #2 son to transcribe the bassline into LMMS as a starting point. He wasn't really sure about this either, in part because I don't think he sees the isomorphism between staff and piano roll representations. I laid down the 1-1-1-5 bassline for him, and then I showed how I would approach the rhythm, setting up separate tracks for a bass drum on the downbeats and a high hat on the upbeats. He got that it sounded good, but maybe still doesn't quite know what to do with that knowledge. We found a lead tone (flute), and I showed how I'd layer a melody on top of these other ones by laying down a simple two-bar line. My son took the next little while to play with adding and removing the tracks, making some modifications to the melody. At one point, he accidentally copied the bass drum line to the highhat; this actually gave a good variation where all the rhythm was on the downbeat, though he didn't actually recognize that he did it. In our last session together, we got rid of the grating flute sound and replaced it with a synth. He had a spot where the drums dropped out, which was a good variation in tone, and I added in a kind of silly furious highhat tapping to bring the drums back in, which is still my favorite part of the song. The result is a fine little loop that runs through most of the game. For the title screen music, I once again laid down a few simple lines that he rearranged into a short loop that sets the tone for the game.

Maybe that's more detail about the music than you cared to hear about. There are very few things I've been doing longer than I've been programming, but playing and writing music is one of them. I'm hoping that perhaps this experience can be a good hook to encourage my son (and perhaps the others) to think some more about how music works and to try to start copying some of those ideas and playing with them. I am reminded of all the hours I spent as a kid copying songs from my piano lessons book or from my imagination into the C64 Music Maker software. I like to think that time wasn't just wasted!

Sound Effects

Fairly late in the project, as we had the core functionality in place, I sat down with the three younger boys to show them how to record sound effects on the family laptop using Audacity. I was surprised how quickly they caught on, not only to the recording, but also how to deal with multiple takes, exporting the selected audio tracks, and uploading them to Drive so we could put them into the game. I told them that this was how I made all the sounds for Kaiju Kaboom, and how pitch shifting could be used for very simple transformations. They put together a suite of sound effects which, truly, are not at all what I had in mind, but which certainly add to the aesthetics of the game.

Spoiler: When you win the game, there is a bit of spoken dialog that is tricky to catch. It's a combination of young kids talking into a laptop microphone and also adopting funny voices. The actual spoken words are: "You saved me, man." "No problemo."

The Mushroom Man and the Turtle in Action

Godot Engine

Let me start with my criticisms. Programming in Godot Engine reminds me in many ways of the things I hated most about programming in Unity ten years ago. The reliance on strings as signals, as method names, as node paths, and as resource paths strikes me as inexcusably fragile. Refactoring anything in Godot is an exercise in frustration. While it's true that one should minimize dependencies, one of the few truisms in programming is that code always changes. Tools without built-in refactoring support make me feel like we lost all the gains the agile software development movement made to modern IDEs. Worse, the reliance on literal strings throughout the architecture inculcates programmers into the idea that this is a good idea. That's really dangerous when compared to tools and processes which encourage constant improvement and refactoring. There's a rule of thumb: if refactoring is hard, people won't do it. On the positive side, this criticism makes me think about potential research opportunities for how to measure or change the environment to promote best practices. 

Another criticism, which should go without saying, is that whitespace should not be significant in a programming language. You cannot see it, so it should not be meaningful. Now, if you're really good, you'll appreciate the irony that this goes without saying. Why should it go without saying? Well, show me your whitespace. Also, if you cannot deal with line break characters properly, maybe you should not rely on whitespace for meaning. 

The node system has grown on me. I am glad I took the time the previous day to understand the relationship between areas, collision shapes, and their shapes, because that did not click for me right away. Now, I have a better appreciation for what I believe is the intended mental model. 

One of the most powerful notions in Godot Engine is instancing scenes. The nomenclature is terrible, however, since a "scene" is actually a class, in the object-oriented programming sense. The documentation even points this out. A "scene" in English has a connotation that is not at all implemented in Godot Engine, but if you think "class of objects" or "blueprint" instead, you get a better understanding. Ignoring the nomenclature for now, the idea that you can instance a scene into another is a powerful way to think about composition: while other parts of the engine encourage bad behavior, this one gives you a way to think about decomposing functionality and responsibilities in a very nice way.

Toward the end of the project, we ran into the classic problem where we wanted one song to play throughout multiple scenes.  The classic problem has a documented solution that we were able to incorporate before shipping: using autoloaded singleton scenes to manage shared state. With a few changes to where we put our songs and responsibilities, we were able to get the music behavior properly. (Well, except for a bug I noticed late last night on mobile, where, depending on where you first tap the screen, you can end up with two songs playing at once.) There is a problem again here though, and it also is mentioned in the documentation: these aren't singletons. The primary point of the design patterns movement was to introduce vocabulary to describe common solution strategies to categories of problems. It's not clear to me why the Godot Engine documentation writers would chose to use the term "singleton" for something that is not a singleton, not when one could just as well use a different word. Still, it's good technique to know, reminiscent of using GameInstance in UE4 to manage information that persists between levels.

We didn't use many advanced feature of Godot Engine. My son and I talked about it this morning, how the first time you use a tool like this, you sort of meander around, building and testing mental models. It's not until after you've built something that you can then really understand some of the other pieces, because then you understand not just the terminology but also the rationale for them. This morning and late last night, I did some reading that revealed some great features that I suppose we could have used, but now I see them as fun and powerful ideas to explore in future projects. These include the Tween node, the animation player, and cutout animation. The first two of those represent things I know how to do readily in UE4—things that add juice that our one-day build is clearly lacking. The cutout animation feature though is really special. I'm already thinking about it enables some of the ideas that have been kicking around to perhaps become more attainable. That is, rather than just seeing how to apply what I know from one tool to another, it's showing me a new way to do new things.

A Story of Code Quality

I'll take a brief aside to share a story that illustrates one of my points above and one of my son's reflections below. My eldest son was responsible for the cooldown timer on the player's mushroom man. Keep in mind that the player can shoot either attack or defense shots, and that these share a cooldown timer. His original implementation looked a bit like this:
 # Shooting attack bullet    
 if cooldown==false:  
   ....
   cooldown = true  
   yield(get_tree().create_timer(.5), 'timeout')  
   cooldown = false  
 # Shooting defense bullet  
 if cooldown==false:  
   ...
   cooldown = true  
   yield(get_tree().create_timer(.5), 'timeout')  
   cooldown = false  

This is the approach encouraged by the tutorial I mentioned earlier that we had worked through. I told him it's not the approach I would have taken, but we left it in. I did ask him, if we wanted to change the cooldown duration, how many places he would have to change it; he recognized that problem and then he replaced the literal 0.5 with a variable.

Originally, we just had input via the keyboard, but later we added the on-screen buttons. We wanted to make the game playable on mobile web browsers without keyboards or gamepads, so he worked on this feature, too. His original implementation, then, simply copied both of those blocks of text into the scripts attached to the buttons. However, the buttons were not connected to the player but to a separate UI, and so they had their own cooldown variable. The result was that, when using keyboard input, the experience was fine, or when using the buttons, the experience was fine, but when mixing the two, one could fire faster than we wanted to allow.

He understood the problem, and I suggested that a simple solution would be to have the buttons watch the player and, each tick, check if shooting is enabled. Their enabled state then could be matched to the player's shooting ability. He acknowledged this but said he had a different approach. His solution was to use signals: the player would emit signals when its shooting ability was enabled or disabled, and the buttons would listen for those signals to update their own state. Did you get that? He deployed the Observer design pattern. Proud Dad moment.

Family Reflection

I made omelettes for lunch today, and as I was preparing them, I told the family that I would ask everyone to share something they learned from yesterday's jam. I've written enough about what I learned, so let's hear what they wanted to share. For simplicity, I'll list the kids by age instead of ordinally.

5-year-old: The way he put it was, "I learned how to draw a computer." Digging more carefully into it, he meant that he learned to draw concept art—to draw something as he would like it to appear on a screen. He didn't have much else to offer besides what we tried to prompt from him, but you know, he's five. He clearly had a great time.

7-year-old: He mentioned storyboarding and recording audio in Audacity. He could not remember the terms for either, but he has brought up both multiple times, so clearly this was impactful. As I mentioned above, he's the one who I think got a bit shorted by the production plan, but he also clearly had a great time.

10-year-old: He also mentioned using Audacity, but he added that he learned how to share the files with the rest of us. My wife was a bit surprised at this, but that's because that whole process was physically and technically hidden from her: I clarified that he had not only recorded the audio, but also exported it and uploaded it to Drive for me to incorporate into the game. This gave me a good opportunity to talk about how a more mature process would be for everyone to have access to Godot Engine so that they could integrate and test their own work, but that I didn't think we would be able to recoup the overhead of that within a one-day jam. It would have required getting at least my wife and the 10-year-old into the engine and, more importantly, acclimated to using git from the command-line (which, incidentally, the 13-year-old did really well with after a brief tutorial).

This son also mentioned that he learned something about the division of windows in LMMS, but we had a hard time sorting it out: it had to do with the relationship between the song editor, the track editor, and the piano roll, but when I tried to assemble these things to see if I understood him, I kept getting it wrong. I need to sit with him and LMMS to see what it really ways. He also interrupted my wife's responses to throw in, "I learned that we should do family game jams more often!"

13-year-old: He learned about how collision handling works in Godot Engine, which was something that was dogging him on a side project. I asked him if he also learned anything about code quality, and emphatically affirmed that he had. In particular, he said that he learned that, to make a change in the behavior, you shouldn't have to change it in many different places. I explained that this was the essence of the DRY principle.

Wife (age withheld): The first thing she mentioned was that it's important to choose a palette at the start of a project. She had attempted a lot of color correction and postprocessing on the boys' hand-drawn images, and she realized that establishing a palette would have made this a lot easier. She also learned how to better use tools like Inkscape. In fact, she was working on processing images and layouts well past when we were done yesterday, and she spent several more hours working on pieces this morning. Later, I may go in and add her revisions and see if I can trap that aforementioned audio bug. Finally, she also noticed how important communication was and how difficult it was, even though we were all in the same building. Better communication would have meant an improved product and less confusion.

Concluding Thoughts

The family was all very excited, and while there were some tense times (mostly when people were asking me for things while I was trying to track down an elusive bug), it was a great day. Everyone is proud of our work, and they should be: together, we went from an idea in the morning to a playable, complete game in the evening. The only thing that we couldn't incorporate was a midday feature request that, when you save Joe, it becomes nighttime. During the day, #3 Son asked if we would do at again soon (I think he wanted to do it today) and if we would be going up in age order as lead designer. All the other boys agreed that they would love to do it again. The older two already spent time this morning tweaking some of their old projects based on what they learned or were excited by in Saturday's jam.

For me, it was a good break from a stressful time at work. In addition to all the stresses brought about by the coronavirus, I also have a major writing project that is due on Wednesday, and I'm not feeling confident about it. Rather than fret about it over the weekend, we took Saturday to make, and that's just about the best thing to do. 

Thanks for reading. I think you'll be hearing about Fam Jam #2 before too long, and I wish you the best in your own game-making adventures.