(direction Direction)
| 60 | type Direction = int |
| 61 | |
| 62 | func (p *Player) move(direction Direction) bool { |
| 63 | switch direction { |
| 64 | case DirUp: |
| 65 | if p.Y == 0 { |
| 66 | return false |
| 67 | } |
| 68 | p.Y-- |
| 69 | case DirDown: |
| 70 | if p.Y == p.Geo.Height-1 { |
| 71 | return false |
| 72 | } |
| 73 | p.Y++ |
| 74 | case DirLeft: |
| 75 | if p.X == 0 { |
| 76 | return false |
| 77 | } |
| 78 | p.X-- |
| 79 | case DirRight: |
| 80 | if p.X == p.Geo.Width-1 { |
| 81 | return false |
| 82 | } |
| 83 | p.X++ |
| 84 | } |
| 85 | |
| 86 | return true |
| 87 | } |
| 88 | |
| 89 | type GardenOptions struct { |
| 90 | HttpClient func() (*http.Client, error) |