Skip to content

Level creation guide

NimbusBP1729 edited this page Mar 29, 2013 · 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 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 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: 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.

Block Layer

If your level has an object layer named block, all objects in that layer, regardless of type, will be considered blocks. Characters can walk on blocks, but cannot jump through them.

Platform Layer (2D levels only)

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.

Floorspace Layer (2.5D levels only)

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 37 pixels high, simply add a property with the name of "height" and value of "37"

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

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>

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