func (tb *towerBuilder) Build(control game.PlayerControls, name string) error { row := tb.row col := tb.col assending := tb.assending if int(row) >= stage.Grass_Rows+stage.Spawn_Size { return AtEndErr } if assending { col++ } else { col-- } // if were at the start and want to goto the next // you must move down if col == 0 && !assending { row += 2 col -= 1 tb.row = row tb.col = col tb.assending = !assending err := tb.Build(control, name) if err != nil { return err } return nil } // if were at the start and want to goto the next // you must move down if int(col) == stage.Grass_Cols-1 && assending { row += 2 col += 1 tb.row = row tb.col = col tb.assending = !assending err := tb.Build(control, name) if err != nil { return err } return nil } tb.row = row tb.col = col err := control.BuyTower(name, uint16(row), uint16(col)) if err != nil { return err } return nil }