Skip to content

Level creation guide

Caleb John edited this page May 29, 2015 · 26 revisions

Getting Started

To create a level, you'll first need to fork and clone this repository.

All levels in Journey to the Center of Hawkthorne are created using Tiled, a tile map editor. Levels are saved as .tmx files and located in the src/maps directory. Once you've downloaded and installed Tiled, you should be able to open up the maps and look around.

Anatomy of a Level

Levels are broken into object layers and tile layers. Tile layers create the look and feel of the level as well as define where the player can stand (level collisions). Object layers define arbitrary interactive objects, such as doors.

A level can have any number of layers, but it must have one object layer named nodes and one tile layer named collision.

Tilesets

Tilesets are images that are a collection of 24x24 images. These sets are how you design your levels. If the level you're working on doesn't have a tileset, you'll need to make one from our game sprites

See the Tileset Creation Guide to learn how to make these images.

Properties

Each level has certain properties that can change it's behavior. To edit these properties, go to Map > Map Properties

  • red: Background color, red part
  • green: Background color, green part
  • blue: Background color, blue part
  • offset: Number of tiles to move in the y-direction when displaying the level
  • soundtrack: Audio file name
  • overworldName: Title shown on the overworld map

Collision Layer

A collision tile is any tile from the collisions tileset. These tiles come in 5 different colors blue, pink, green, light blue, and red.

  • Blue is the block tile, this tile blocks the player in all directions, and is the often used for floors.
  • Pink tiles are platforms, the player can stand on these but otherwise does not interact with them, while standing on top of a pink tile the player can double tap the down key to drop through the platform.
  • Green tiles are non-dropping platforms, they are identical to pink tile platforms but you cannot drop through them, these are typically used when dropping would result in the players death.
  • Light Blue is the ice block, these are identical to blue blocks but they are "slippery".
  • Red tiles should never be used, they denote breakable blocks and are placed by the breakable_block node.

Node Layer

A node is an object that will be placed in the level. It can interact with the player, move around, and draw itself to the screen. Sprites, enemies, walls, floors and NPCs are represented as nodes.

A node's type determines it's behavior.

Floorspace Layer (2.5D levels only)

Objects you may need:

  • a primary floorspace
  • additional floorspace object
  • sprites that correspond to floorspace objects

If your level has an object layer named floorspace it must be a 2.5D level like the Tavern or the Blacksmith's House.

To make a functioning floorspace you need to have exactly one large polygon representing the bounds of the floor. Once you've created it, right click it and add a property with name of "primary" with a value of "true". This indicates that this is the primary floorspace for the floor.

If there are no obstacles in the room, you don't have to do anything else with the floorspace.

Otherwise you need to add more objects to the floorspace. To make a table you can stand on you first draw a polygon in the floorspace layer. This should represent the base of the table(i.e. where the legs would touch). To make the table 27 pixels high, simply add a property with the name of "height" and value of "27"

But now when you try out your level, there will be an obstacle, but absolutely nothing visually to indicate it. So what do we do? We add a sprite to the "nodes" layer with a property of "depth" and a value indicating how far back it extends when the player is standing on it. This value can be determined empirically.

Nodes

The game has a few builtin node types that should be enough to get you started

sprite

A sprite is an animated series of images. A sprite node needs the following object properties

  • image: path to the sprite sheet, relative to the src directory (Ex images/bartender.png)
  • width: the width of individual sprites inside the full image
  • height: the height of individual sprites inside the full image
  • animation: x,y where x and y can be grid values. To five frame in a row, the value would be '1-3, 1'. This value means that the animation consists of grid (1,1), (1,2) and (1,3).

door

  • level: name of the level to go to. Must have been loaded in main.lua
  • instant: if set, the player will enter the door as soon as they touch it
  • renter: if set, the player will reenter the level at the last point, not start at the beginning

breakable_block

  • crack: whether or not to display a crack while breaking
  • dying_animation: the name of the animation to use while breaking
  • hp: the amount of damage the block can take before breaking
  • sound: the name of the sound effect to use when this block is destroyed
  • sprite: the name of the sprite that this block will show when unbroken
  • tile_id: a number between 104 and 129 denoting which collision tile to use

*note when determining which tile_id to use, take a look at the collision tileset, the leftmost block is #104 (the default) and the rest increase by one for each tile.

API Reference

Creating your own nodes is easy. Create a .lua file in the /src/nodes directory. This file must return a module that implements the following interface.

Node.new(tiled_object, collider)
Node:update(dt, player)
Node:keypressed(key)
Node:draw()
Node:collide(player, dt, wtv_x, wtv_y)
Node:collide_end(player, dt, wtv_x, wtv_y)

A good example of a node is either door.lua and sprite.lua

Additionally we also have a template for creating a node

Choosing a Level

If you'd like to work on a level, take a look in the Level To Do Spreadsheet and sign up for a level.

Testing Levels

Run the game using the following command based on your OS

$ love C:\games\hawkthorne/src                    # Windows
$ love /home/path/to/hawkthorne/src               # Linux
$ /Applications/love.app/Contents/MacOS/love src  # OS X

To test a specific level, you can pass it as the second argument on the command line

$ love src --level=<level-name>

For examples of everything described above take a look at the test level, it can be found in src/maps/test-level.tmx. To play around in it just type this in on the command line.

$ love src --level=test-level

Submitting Levels

Unlike costumes and characters, levels can't be submitted to the subreddit. Feel free to submit an image to show off your work, but a pull request is the way to get levels accepted into the game.

Clone this wiki locally