22 lines
377 B
Go
22 lines
377 B
Go
|
package soko
|
||
|
|
||
|
import (
|
||
|
"opslag.de/schobers/geom"
|
||
|
)
|
||
|
|
||
|
type Level struct {
|
||
|
Width int
|
||
|
Height int
|
||
|
Tiles []Tile
|
||
|
Entities []EntityType
|
||
|
}
|
||
|
|
||
|
func (l Level) IdxToPos(i int) geom.Point { return geom.Pt(i%l.Width, i/l.Width) }
|
||
|
|
||
|
func (l Level) PosToIdx(p geom.Point) int {
|
||
|
if p.X < 0 || p.Y < 0 || p.X >= l.Width || p.Y >= l.Height {
|
||
|
return -1
|
||
|
}
|
||
|
return p.Y*l.Width + p.X
|
||
|
}
|