O'Reilly logo

Corona SDK HOTSHOT by Nevin Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting costs for neighboring tiles

The other piece of information that we need to know about each neighboring tile is how hard, compared to other tiles, it is to take the step into that tile from the one we are considering. We'll add this information to the terrain engine and attach it to the spaces to make it easy to find.

Getting ready

Open the forest.lua file in the terrain folder.

Getting on with it

This model will keep things simple, basing costs to enter a space solely on the type of space being entered. This means we can use a simple table.

Providing cost assignments

Add a new local table near the top of forest.lua:

local forest = {}
local entryCosts = {
}
function forest:Expand(kind)

Add values for the basic terrain types found in the map: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required