func displayPickUpChoice() []entity.ID { var str *C.char C.clear() C.move(0, 0) str = C.CString("Pick up what?\n") C.addstr(str) C.free(unsafe.Pointer(str)) px, py := currentLevel.EntityLocation(player.EntityID()) itemsAvailable := currentLevel.ItemsAt(px, py) for i, eid := range itemsAvailable { C.addch(C.chtype(inventoryChar(byte(i)))) str = C.CString(" - ") C.addstr(str) C.free(unsafe.Pointer(str)) str = C.CString(currentLevel.EntityByID(eid).EntityName()) C.addstr(str) C.free(unsafe.Pointer(str)) } itemsChosen := make([]bool, len(itemsAvailable)) for { ch := C.getch() if ch == C.KEY_ENTER || ch == ' ' || ch == '\n' { break } if ch > C.int(255) { continue } if i := inventoryIndex(byte(ch)); (int(i) < len(itemsChosen)) && (i != 255) { if itemsChosen[i] { itemsChosen[i] = false C.mvaddch(C.int(i+1), 2, C.chtype('-')) } else { itemsChosen[i] = true C.mvaddch(C.int(i+1), 2, C.chtype('+')) } } } result := make([]entity.ID, 0, len(itemsAvailable)) for i, v := range itemsChosen { if v { result = append(result, itemsAvailable[i]) } } return result }
func displayInventory() { var str *C.char C.clear() C.move(0, 0) str = C.CString("Inventory contents:\n") C.addstr(str) C.free(unsafe.Pointer(str)) for i, v := range inventory { if inventory[i] != nil { C.addch(C.chtype(inventoryChar(byte(i)))) str = C.CString(" - ") C.addstr(str) C.free(unsafe.Pointer(str)) str = C.CString(v.name) C.addstr(str) C.free(unsafe.Pointer(str)) C.addch(C.chtype('\n')) } } }
func Move(x, y int) { x, y = real2raw(x, y) C.move(C.int(x), C.int(y)) }
func Move(y int, x int) { C.move(C.int(y), C.int(x)) }