Implemented function to get a field value

This commit is contained in:
Julien Dessaux 2021-09-19 01:14:58 +02:00
parent 0c52da6714
commit e8662451d4
2 changed files with 43 additions and 0 deletions

View file

@ -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
}