aboutsummaryrefslogtreecommitdiff
path: root/pkg/field/step.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-19 01:10:52 +0200
committerJulien Dessaux2021-09-19 01:10:52 +0200
commit0c52da671406d7881226ce28b29fe4eb0b36c8bc (patch)
tree71bf9c875e7a4bb447e7a0dbb829752f30e9a010 /pkg/field/step.go
parentAdded function to calculate a next pointer step on the field (diff)
downloadgofunge98-0c52da671406d7881226ce28b29fe4eb0b36c8bc.tar.gz
gofunge98-0c52da671406d7881226ce28b29fe4eb0b36c8bc.tar.bz2
gofunge98-0c52da671406d7881226ce28b29fe4eb0b36c8bc.zip
Moved isIn function to a util file
Diffstat (limited to 'pkg/field/step.go')
-rw-r--r--pkg/field/step.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/pkg/field/step.go b/pkg/field/step.go
index 50147d2..eee6f95 100644
--- a/pkg/field/step.go
+++ b/pkg/field/step.go
@@ -2,19 +2,15 @@ package field
func (f Field) Step(x, y, dx, dy int) (int, int) {
x2, y2 := x+dx, y+dy
- if f.IsIn(x2, y2) {
+ if f.isIn(x2, y2) {
return x2, y2
}
// We are stepping outside, we need to wrap the Lahey-space
for {
x2, y2 := x-dx, y-dy
- if !f.IsIn(x2, y2) {
+ if !f.isIn(x2, y2) {
return x, y
}
x, y = x2, y2
}
}
-
-func (f Field) IsIn(x, y int) bool {
- return x >= f.x && x < f.x+f.lx && y >= f.y && y < f.y+f.ly
-}