Implemented function to get a field value
This commit is contained in:
parent
0c52da6714
commit
e8662451d4
2 changed files with 43 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue