gofunge98/pkg/field/step.go

17 lines
282 B
Go
Raw Normal View History

package field
func (f Field) Step(x, y, dx, dy int) (int, int) {
x2, y2 := x+dx, y+dy
2021-09-19 01:10:52 +02:00
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
2021-09-19 01:10:52 +02:00
if !f.isIn(x2, y2) {
return x, y
}
x, y = x2, y2
}
}