aboutsummaryrefslogtreecommitdiff
path: root/go/game/pos.go
blob: 133f599b736bf8d5a852b60676809f2814681694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package game

import (
	"fmt"
)

type Position struct {
	X int
	Y int
}

const POSITION_FMT = "(%d, %d)"

func (p Position) String() string {
	if p == INVALID_POSITION() {
		return "INVALID_POSITION"
	}

	return fmt.Sprintf(POSITION_FMT, p.X, p.Y)
}

func INVALID_POSITION() Position {
	return Position{-1, -1}
}