Getting The Gist

Some butter-makers just want to see the world churn.

Friendshape - TOJAM 9

Friendshape is cooperative physics platformer. The two characters are bound together and you have to help each other complete the levels. It’s really cute and turned out pretty fun.

Kyle Johnston – Audio
Tanner Rogalsky – Code
Ryan Wang – Graphics

SPORTBALL - Global Game Jam 2014

It was the Global Game Jam this past weekend which meant that most of Toronto’s fantastic game dev scene came out, formed teams and made game over the course of a weekend. It was, as always, so amazing to see 300 people come together and build a community as well as some kick-ass games in 48 hours. A million thanks to Troy Darc and Randy Orenstein and their supporting cast for making TGGJ happen and making it feel as good as it does.

This weekend, I made a game called Sportball. It’s a multiplayer game where you try to coerce a lot of coloured units into pushing a ball into your coloured net. The game was made with gamepads in mind but it can also be played with WASD and arrows keys on a keyboard. It’s very easy to lose your units but they are constantly respawning so you just need to make sure you don’t lose as many as your opponent while you’re trying to score a goalpoint.

The concept was inspired by the Double Cherry item in Super Mario 3D World. It duplicates the character you’re controlling and I thought it was so fun that I wanted to make a game where that was the main mechanic. My team on this project was Erica Gregory for art and Maggie McLean for music. They both did a fantastic job and this game wouldn’t be nearly as good without them.

Screenshots

Downloads:

One thing I’m trying is to distribute this game (at least initially) through StackMachine. It’s a very clever little website that packages, updates and gives error reports on your game. If you make anything using the Love2D framework, I recommended checking it out.

Grab a friend and try out some Sportball!

Stop Searching Through Lua Tables

I had this conversation with someone on reddit the other day and thought it might make a useful blog post.

tl;dr stop searching through Lua tables. There are very few instances where you should be using a for loop to look for a particular element in a Lua table. Instead, you should be using some kind of identifying information as the key and element as the value in the table.

For example, in LÖVE, the physics collision callbacks return three things: 2 fixtures (physics elements) and a contact (an object representing containing collision information). Lets say you’ve set up your physics and your collision callbacks and everything is working. But fixtures probably aren’t the object you want to operate on when there’s a collision happening. You probably want the body that owns that fixture or maybe even some other table that owns that body! You now have three options:

1) You can loop through every body in your game and check its fixtures until you find the ones you’ve just had collide. This is simple and easy to understand but it’s going to get pretty slow when you’ve got a lot of object colliding often. You probably need something speedier.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function on_collide(fixture_a, fixture_b, contact)
  local body_a, body_b = nil, nil

  for _, body in ipairs(World:getBodyList()) do
    for _, fixture in ipairs(body:getFixtureList()) do
      if fixture == fixture_a then
        body_a = body
      elseif fixture == fixture_b then
        body_b = body
      end
    end

    if body_a ~= nil and body_b ~= nil then
      break
    end
  end
end

2) You can use Fixture:setUserData and set the user data as whatever parent element you want. This is a fast solution but it’s not a pattern that we can follow everywhere and it’s not immediately obvious that fixture user data should always be physics bodies. This is good but we can do better.

1
2
3
4
function on_collide(fixture_a, fixture_b, contact)
  local body_a = fixture_a:getUserData()
  local body_b = fixture_b:getUserData()
end

3) The best way is have another table that uses the fixtures as the key and a parent element as the value. You’ll have to manually clean up these references if you destroy the fixture but it’s fast and something that you have complete control over, unlike the user data method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local objects = {}

function createObj()
     local object = {}
     object.body = love.physics.newBody(world, x, y, "dynamic")
     object.shape = love.physics.newRectangleShape(x,y)
     object.fixture = love.physics.newFixture(object.body, object.shape)
     object.otherinfo = 123
     object.otherinfo2 = 321
     objects[object.fixture] = object
end

function on_collide(fixture_a, fixture_b, contact)
  local object_a = objects[fixture_a]
  local object_b = objects[fixture_b]
end

This type of pattern is something that you can use everywhere and generally cuts down your operation complexity from O(n) to O(1). The only time you can’t use this is if you absolutely need the elements to be ordered or if you need to know the size of the list. Every other time you should strongly consider using a hash in this pattern.

TOJam 2013 - Where?House

Sokoban is a Japanese word that translates to “warehouse keeper.” It’s a termed used for a genre of games that involve pushing blocks around to solve puzzles. You’ve probably played games that do this. Think Zelda-style rock pushing puzzles or Chip’s Challenge.

Non-euclidean geometry is a subset of geometry that disregards certain principles about the way that space works. You might have experienced this in games like Portal or Antichamber.

Over the weekend, at TOJam 2013, a group of friends and I made a non-euclidean sokoban game called Where?House. It has 17 levels of progressing difficulty, fantastic graphics and sounds. I’m really proud of how it came out. Thanks to everyone who helped out as well as TOJam for organizing the event.

Andrew Glisinski – Art
Chris Baragar – Level Design
Kyle Johnston – Music & SFX
Maggie McLean – SFX
Tanner Rogalsky – Code

Here are some download links.

If you don’t care about the specifics of how this was done, feel free to stop reading now.

Essentially, each level is a 2D grid made up of tiles. By default, each tile has four siblings: one in each cardinal direction. However, it’s not necessary that any given sibling be a direct neighbor to the tile. Heading North from a tile may send you across the map whereas heading East may put you just to the right of where you were.

Rendering these transitions consistently is something that I’m really pleased with. When you’re static, we draw you once in the tile that you exist in. When you’re moving, we draw you twice: first, we draw you tweening in the direction you requested to move. We also clip the rendering to your tile of origin. Second, we draw you tweening into the sibling tile while clipping the rendering to the sibling tile. We do this whether the sibling you’re moving to is a euclidean one or not and it works because the tweens sync up and it creates the illusion of a single render. It really helps to communicate what’s happening and ensure that players don’t think it’s just a bug.

TGGJ13 - Electric Boobaloo

I’m a serial game jammer. I love it: the community, the productivity, the whole shebang. I do them as often as I can. But this year’s Toronto Global Game Jam took it up a notch. Troy Morrissey and Randy Orenstein did an amazing job organizing and running the event. The atmosphere of the entire weekend was sublime.

I also worked with an amazing team this year: Noreen Rana did visuals and Maggie McLean did audio. They’re both fantastic.

One thing we did this jam that I haven’t really done (at least not explicitly) was really leveraged the fact that we’re surrounded by brilliant and creative people for a weekend. Almost all of the sound effects that you’ll hear in the game were recorded from jam participants during the weekend. It was a great way to meet fellow jammers and have a lot of fun in the process. I’ll definitely try to find a way to integrate more of my peers into my games in future jams.

Without further ado:

Linux users should download the source and the appropriate Love2D binary for their distro. It requires version 0.8.0. Compiling Love2D from source is also really easy on Linux but I feel like you’re sort of making your life harder than it needs to be.

Colors and Metatables

Love2D, like any good framework built for Lua, keeps it simple and to the point. So there are some things you can either implement yourself or use a third party library. If you’re down with the latter, you might be interested in my color index built with metatables.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local COLORS
do
  local rgb = function(color) return color.r, color.g, color.b end
  local rgba = function(color) return color.r, color.g, color.b, color.a end
  COLORS = setmetatable({},
    {__newindex = function(t, k, v)
      v.rgb = rgb
      v.rgba = rgba
      rawset(t, k, v)
    end,

    __index = function(t, k)
      return rawget(t, k:upper())
    end})
end
COLORS.RED =    {r = 255, g = 0,   b = 0,   a = 255}
COLORS.GREEN =  {r = 0,   g = 255, b = 0,   a = 255}
COLORS.BLUE =   {r = 0,   g = 0,   b = 255, a = 255}
COLORS.WHITE =  {r = 255, g = 255, b = 255, a = 255}
COLORS.BLACK =  {r = 0,   g = 0,   b = 0,   a = 255}
COLORS.YELLOW = {r = 0,   g = 255, b = 255, a = 255}
COLORS.PURPLE = {r = 255, g = 0,   b = 255, a = 255}

Usage is like so:

1
2
love.graphics.setColor(COLORS.GREEN:rgb())
love.graphics.setColor(COLORS.GREEN:rgba())

You can also use either upper or lower cases (or a combination) to specify color names (i.e. COLORS.GREEN:rgb == COLORS.green:rgb). A full explanation of the code follows. It’s mostly an explanation of Lua metatables.

My Favourite Lua Libraries

I really like a Lua as a programming language for a variety of reasons. It is probably my favourite language for prototyping and just messing around with. However one of the pain points I hear people talk about often is the minimal standard library that comes with the interpreter. Perhaps to alleviate some of that frustration but mostly just to talk about some libraries that I think are really cool, I wanted to put together a list of my favourite 5 Lua libs. Many of them are very general but some of them are more geared toward game development since that tends to be what I use Lua for.

TOJam 2012 - [GRIDPHREAK]

This past weekend I participated in the largest gamejam Toronto has ever seen. Over four hundred people got together, each trying to make a video game in 48 hours. Last year’s TOJam was the first gamejam I’d ever gone to and I credit the hardwork of Rob, Em, Jim, their compatriots, and all the jammers with making TOJam such an amazing atmosphere to work in. I will do this jam every year it is hosted; it’s the best.

This year I made a game that I’ve had in my head for a while. It’s a top-down schmup (shoot-em-up) like Crimsonland, Smash TV or Asteroids. Where it differs from each of those games is that it also has dynamic lighting: you can’t necessarily see the enemies on the screen unless you or someone else shines light on them. The controls are very simple and are right on the game menu when you open it up.

Graphics were done by Derian McCrea and myself. Code and concept are mine.

Downloads:

Linux users should download the source and the appropriate Love2D binary for their distro. It requires version 0.8.0. Compiling Love2D from source is also really easy on Linux but I feel like you’re sort of making your life harder than it needs to be.

I’m happy enough with how it turned out that I do plan on continuing to work on it. Any further updates will come with a blog post until a more suitable update method can be established.

Let me know if there are any problems with the downloads or, you know, if anything is really cool. I’ll follow up with some of the more interesting technical aspects of this game in the next few days.

Control Maps in Love2D

In games with even moderately complicated control schemes, evaluating keypress events can easily become a large, unwieldy case or if/else statement. What we need is a way to simplify that code, compartmentalize it so that we can easily switch control schemes with player state as necessary and minimize the amount of evaluations we need to do.

Molyjam 2012

This past weekend, I participated in Molyjam where I make a game based (loosely) on the tweet, “You play a hole, you must move around an environment making certain elements fall into correct targets at the right time.” It sort of evolved from that into a two person game.

One person plays Man. Man’s goal is to collect lamps to get point. Only man can collect lamps. The other person plays the Djinn. The Djinn’s goal is to make Man fall. When man falls, the player’s switch roles (but not keyboard positions!). Both players can collect power ups. Power ups let the man double jump and let the Djinn make more holes.

Darin Walsh made the graphical art, Kyle Johnston made the music and I, Tanner Rogalsky, coded it.

Downloads:

Linux users should download the source and the appropriate Love2D binary for their distro. Compiling Love2D from source is also really easy on Linux but I feel like you’re sort of making your life harder than it needs to be.

Let me know if there are any problems with the downloads or, you know, if anything is really cool.