Refactor the Tile to a full Atlas
This atlas is a set of chunks and supports resizing
This commit is contained in:
parent
8586bdabd7
commit
ceca4eb7fa
6 changed files with 300 additions and 28 deletions
|
@ -6,6 +6,27 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// Abs gets the absolute value of an int
|
||||
func Abs(x int) int {
|
||||
if x < 0 {
|
||||
return -x
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
// pmod is a mositive modulo
|
||||
// golang's % is a "remainder" function si misbehaves for negative modulus inputs
|
||||
func Pmod(x, d int) int {
|
||||
x = x % d
|
||||
if x >= 0 {
|
||||
return x
|
||||
} else if d < 0 {
|
||||
return x - d
|
||||
} else {
|
||||
return x + d
|
||||
}
|
||||
}
|
||||
|
||||
// Vector desribes a 3D vector
|
||||
type Vector struct {
|
||||
X int `json:"x"`
|
||||
|
@ -45,6 +66,11 @@ func (v Vector) Multiplied(val int) Vector {
|
|||
return Vector{v.X * val, v.Y * val}
|
||||
}
|
||||
|
||||
// Divided returns the vector divided by an int
|
||||
func (v Vector) Divided(val int) Vector {
|
||||
return Vector{v.X / val, v.Y / val}
|
||||
}
|
||||
|
||||
// Direction describes a compass direction
|
||||
type Direction int
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue