6
btn
JailDoctor edited this page 2022-02-18 19:23:42 +01:00

btn(tecla)

Aquesta funció torna true o false segons la tecla que s'especifica com a paràmetre estiga polsada o no. Aquesta funció tornarà true tot el temps que la tecla es mantinga polsada. La funció germana, btnp, torna true només just al pulsar la tecla.

Paràmetres

tecla Una de les constants asociades al teclat.

Exemple

function init()
    x,y = 10,7
    mode(2)
end

function update()
    cls()
    if btn(KEY_UP) then
        y = mid(0,y-1,14)
    elseif btn(KEY_DOWN) then
        y = mid(0,y+1,14)
    end
    if btn(KEY_LEFT) then
        x = mid(0,x-1,19)
    elseif btn(KEY_RIGHT) then
        x = mid(0,x+1,19)
    end
    color(COLOR_YELLOW,COLOR_BLACK)
    print("\224", x, y)
end

Vore també