2024-12-13 11:47:39 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
type Vec2 struct {
|
|
|
|
X, Y int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Mult(by int64) Vec2 {
|
|
|
|
return Vec2{v.X * by, v.Y * by}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Add(a Vec2) Vec2 {
|
|
|
|
return Vec2{v.X + a.X, v.Y + a.Y}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Eq(a Vec2) bool {
|
|
|
|
return v.X == a.X && v.Y == a.Y
|
|
|
|
}
|
2024-12-16 21:10:13 +00:00
|
|
|
|
|
|
|
func (v Vec2) Up() Vec2 {
|
|
|
|
return v.Add(Vec2{0, -1})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Down() Vec2 {
|
|
|
|
return v.Add(Vec2{0, 1})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Left() Vec2 {
|
|
|
|
return v.Add(Vec2{-1, 0})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v Vec2) Right() Vec2 {
|
|
|
|
return v.Add(Vec2{1, 0})
|
|
|
|
}
|