From 46170dd5b70588c9b1c6f4aa5aaea2649d8c74f0 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 20 Sep 2021 01:23:39 +0200 Subject: Began implementing the Instruction Pointer --- pkg/pointer/pointer.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkg/pointer/pointer.go (limited to 'pkg/pointer/pointer.go') diff --git a/pkg/pointer/pointer.go b/pkg/pointer/pointer.go new file mode 100644 index 0000000..5b4b860 --- /dev/null +++ b/pkg/pointer/pointer.go @@ -0,0 +1,21 @@ +package pointer + +import "git.adyxax.org/adyxax/gofunge/pkg/field" + +type Pointer struct { + x int + y int + delta *Delta +} + +func NewPointer() *Pointer { + return &Pointer{delta: NewDelta(1, 0)} +} + +func (p Pointer) ForkPointer() *Pointer { + return &p // p is already a copy +} + +func (p *Pointer) Step(f field.Field) { + p.x, p.y = f.Step(p.x, p.y, p.delta.x, p.delta.y) +} -- cgit v1.2.3