Пример #1
0
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
}
Пример #2
0
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'))
		}
	}
}
Пример #3
0
func Clear() {
	C.clear()
}
Пример #4
0
// Clears the console.
func Clear() int {
	return int(C.clear())
}
Пример #5
0
func (Cv *Canvas) Clear() {
	//I.Lock()
	C.clear(Cv.Cv)
	//I.Unlock()
}
Пример #6
0
func (Cv *Canvas) Create() {
	//I.Lock()
	Cv.Cv = C.create()
	C.clear(Cv.Cv)
	//I.Unlock()
}
Пример #7
0
func (r *FullscreenRenderer) Clear() {
	C.clear()
	C.endwin()
}
Пример #8
0
func Clear() {
	C.clear()
	C.endwin()
}