Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

In this new approach, I still have the location stashed in a field, I still have the indicator in a canvas (as a reference), and I have a single canvas for rendering the map and obtaining click events.

In the card's view event handler, I need to figure out the appropriate coordinates for drawing the indicator dot by centering it within some grid cell, based on the dimensions of the map canvas:

on view do
  cell:map.size/4
  loc:"%i,%i" parse location.text
  map.clear[]
  map.paste[indicator.copy[] (cell*loc)+(0.5*cell-indicator.size)]
end

Then in the canvas click event handler, I make sure that the cell the player clicked ("here") is exactly one cell away from the current location ("loc") by calculating the magnitude of their difference:

on click pos do
  cell:map.size/4
  loc :"%i,%i" parse location.text
  here:floor pos/cell
  if 1~mag loc-here
   location.text:"%i,%i" format here
   view[]
   # ... navigate to another card, etc...
  end
end