diff options
author | Julien Dessaux | 2021-09-19 01:14:58 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-09-19 01:14:58 +0200 |
commit | e8662451d43c8c1f33ab4b921f9fa442ce4f0ead (patch) | |
tree | 8ac8201578380d7262a7fa82d197cc45d8244071 /pkg/field/utils.go | |
parent | Moved isIn function to a util file (diff) | |
download | gofunge98-e8662451d43c8c1f33ab4b921f9fa442ce4f0ead.tar.gz gofunge98-e8662451d43c8c1f33ab4b921f9fa442ce4f0ead.tar.bz2 gofunge98-e8662451d43c8c1f33ab4b921f9fa442ce4f0ead.zip |
Implemented function to get a field value
Diffstat (limited to '')
-rw-r--r-- | pkg/field/utils.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/field/utils.go b/pkg/field/utils.go index 79a191b..769af37 100644 --- a/pkg/field/utils.go +++ b/pkg/field/utils.go @@ -1,5 +1,15 @@ package field +func (f Field) Get(x, y int) int { + if y >= f.y && y < f.y+f.ly { + l := f.lines[y-f.y] + if x >= l.x && x < l.x+l.l { + return l.columns[x-l.x] + } + } + return ' ' +} + 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 } |