Skip to content

Level creation guide

starcitsura edited this page Sep 26, 2012 · 16 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 are non-interactive and create the look and feel of the level. Object layers define abritrary interactive objects, such as doors.

A level can have any number of layers, but it must have one object layers named nodes

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 tilset, you'll need to make one from sprites found on the Sprite Spreadsheet.

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: Path to audio file to play, should be 'audio/file.ogg'
  • title: Title shown on the overworld map
  • warpin: If set, the player will warp in when starting the level

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.

Wall Layer

If your level has an object layer named wall, all objects in that layer, regardless of type, will be considered walls.

Floor Layer

If your level has an object layer named floor, all objects in that layer, regardless of type, will be considered floors. Characters cannot jump or walk through floors.

Platform Layer

If your level has an object layer named platform, all objects in that layer, regardless of type, will be considered platforms. Platforms are very similar to floor nodes, except that characters can jump up through platforms.

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).

floor

Players can jump through floors, but they cannot fall through them. Floor nodes have no properties

wall

Players can't jump through walls. Wall nodes have no properties.

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

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

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

Make sure your level is being loaded in src/main.lua.

function love.load()
    ...
    Gamestate.load('studyroom', Level.new('mylevel.tmx'))
    ...
end

Make sure to load it as the studyroom. This is the first level in the game, so it will make testing easier.

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

Select a character and hit return. On the world map, select the studyroom. Your new level should now be loaded.

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

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

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.