浏览代码

Changed from int64 to int

This allows the code to be more 32 bit capable rather than hard dependency on 64 bit.

This should allow Point to use less space when it doesn't need 64 bit sized integers. (Exception is when you're using Distance it will always use float64
David Thielemann 1 年之前
父节点
当前提交
7b288bca28
共有 1 个文件被更改,包括 11 次插入11 次删除
  1. 11 11
      point.go

+ 11 - 11
point.go

@@ -7,8 +7,8 @@ import (
 
 // A Point 2D
 type Point struct {
-	X int64 // X Axis (Horizontal)
-	Y int64 // Y Axis (Vertical)
+	X int // X Axis (Horizontal)
+	Y int // Y Axis (Vertical)
 }
 
 // Creates a new point at (0, 0)
@@ -17,7 +17,7 @@ func NewPoint() *Point {
 }
 
 // Creates a new point given 1-2 integers (more integers are ignored)
-func AsPoint(to ...int64) *Point {
+func AsPoint(to ...int) *Point {
 	var p *Point = &Point{}
 	if len(to) == 1 {
 		p.X = to[0]
@@ -30,7 +30,7 @@ func AsPoint(to ...int64) *Point {
 }
 
 // Assignment by 1-2 integers (more integers are ignored)
-func (p *Point) Set(to ...int64) *Point {
+func (p *Point) Set(to ...int) *Point {
 	if len(to) == 1 {
 		p.X = to[0]
 		p.Y = to[0]
@@ -49,7 +49,7 @@ func (p *Point) SetTo(o *Point) *Point {
 }
 
 // Translate by 1-2 integers (more integers are ignored)
-func (p *Point) Move(by ...int64) *Point {
+func (p *Point) Move(by ...int) *Point {
 	if len(by) == 1 {
 		p.X += by[0]
 		p.Y += by[0]
@@ -108,17 +108,17 @@ func (p *Point) IsZero() bool {
 }
 
 // Compares if the Point's X is the same as given X axis
-func (p *Point) IsX(x int64) bool {
+func (p *Point) IsX(x int) bool {
 	return p.X == x
 }
 
 // Compares if the Point's Y is the same as given Y axis
-func (p *Point) IsY(y int64) bool {
+func (p *Point) IsY(y int) bool {
 	return p.Y == y
 }
 
 // Compares if the Point is equal to the 1-2 integers (more integers are ignored)
-func (p *Point) Equal(to ...int64) bool {
+func (p *Point) Equal(to ...int) bool {
 	if len(to) == 1 {
 		return p.X == to[0] && p.Y == to[0]
 	} else if len(to) >= 2 {
@@ -133,7 +133,7 @@ func (p *Point) EqualTo(o *Point) bool {
 }
 
 // Compares the Point against 1-2 integers (more integers are ignored)
-func (p *Point) Less(than ...int64) bool {
+func (p *Point) Less(than ...int) bool {
 	if len(than) == 1 {
 		return p.X <= than[0] && p.Y <= than[0]
 	} else if len(than) >= 2 {
@@ -148,7 +148,7 @@ func (p *Point) LessThan(o *Point) bool {
 }
 
 // Compares the Point against 1-2 integers (more integers are ignored)
-func (p *Point) Greater(than ...int64) bool {
+func (p *Point) Greater(than ...int) bool {
 	if len(than) == 1 {
 		return p.X >= than[0] && p.Y >= than[0]
 	} else if len(than) >= 2 {
@@ -180,7 +180,7 @@ func (p *Point) Within(topLeft, botRight *Point) bool {
 }
 
 // The distance from the Point to the assumed location
-func (p *Point) Distance(x, y int64) int {
+func (p *Point) Distance(x, y int) int {
 	a := float64(p.X - x)
 	b := float64(p.Y - y)
 	return int(math.Max(math.Abs(a), math.Abs(b)))