david-pfx / PuzzleScriptNext

A direct successor to PuzzleScript, building on the work of PuzzleScript Plus, Pattern:Script and others.
http://www.puzzlescriptnext.polyomino.com
MIT License
12 stars 5 forks source link

Non-orthoganal grids #120

Open rolopogo opened 2 hours ago

rolopogo commented 2 hours ago

Check ([ ] -> [x]) all that apply, then describe the issue below:

Allow grid cell position to be offset per row and per column

Grid offsets could be used by games that use fake perspective, Grid offsets could also be used to create isometric tiles, hexagonal tiles more easily than creating split sprites that span multiple tiles

Implementation: Add grid_offset_per_row and grid_offset_per_col to allow grids to be transformed into different layouts

In graphics.js getDrawPos, modify offs.x and offs.y by some factor of ij.y and ij.x respectively e.g.

const offs= {
x: obj.spriteoffset.x +  (state.grid_offset_per_row*ij.y),
y: obj.spriteoffset.x +  (state.grid_offset_per_col*ij.x)
}

Large offsets will change the total grid proportions, so adjustments should also be made to sections computing world bounds.

rolopogo commented 2 hours ago

For hexagonal grids we would need to negate the grid offset every other row. Not sure how best to handle this in config. Maybe something like defining a pattern grid_offset_per_row 4,-4

david-pfx commented 2 hours ago

I'll look into it.

But hexagonal is another thing entirely.