Began implementing the Instruction Pointer
This commit is contained in:
parent
ae7f4d5acf
commit
46170dd5b7
3 changed files with 72 additions and 0 deletions
21
pkg/pointer/pointer.go
Normal file
21
pkg/pointer/pointer.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue