mouse
возвращает координаты и состояние нажатия мыши/касания
mouse() ->x, y, pressed
Описание:
Функция возвращает координаты мыши и состояние нажатия.
Для использования этой функции в метаданных картриджа должно быть прописано -- input: mouse
.
Будьте внимательны, включение поддержки мыши отключит джойстики.
Пример:
Запустить или скачать картридж примера.
-- title: mouse demo
-- author: Raidez
-- desc:
-- script: lua
-- input: mouse
t=0
x=104
y=24
function TIC()
mx,my,md=mouse() --get x,y and pressed
if md then
x=mx
y=my
end
cls(12)
spr(1+(t%60)/30,x,y,-1,4)
t=t+1
end
Запустить или скачать картридж примера.
-- title: mouse demo
-- author: Raidez
-- desc:
-- script: moon
-- input: mouse
t=0
x=104
y=24
export TIC=->
mx,my,md=mouse() --get x,y and pressed
if md
x=mx
y=my
cls 12
spr 1+(t%60)/30,x,y,-1,4
t=t+1
// title: mouse demo
// author: Raidez
// desc:
// script: js
// input: mouse
var t = 0
var x = 104
var y = 24
function TIC() {
var m = mouse()
var mx = m[0] //get x,y and pressed
var my = m[1]
var md = m[2]
if (md) {
x = mx
y = my
}
cls(12)
spr(1 + (t % 60) / 30, x, y, -1, 4)
t++
}
Пример:
Запустить или скачать картридж примера.
-- title: mouse demo
-- author: Filippo
-- desc:
-- script: lua
-- input: mouse
-- pal: DB16
r=0
function TIC()
cls(0)
--get mouse info
x,y,p=mouse()
--if pressed
if p then r=r+2 end r=r-1
r=math.max(0, math.min(32, r))
--draw stuff
line(x,0,x,136,11)
line(0,y,240,y,11)
circ(x,y,r,11)
--show coordinates
c=string.format('(%03i,%03i)',x,y)
print(c,0,0,15,1)
end
Запустить или скачать картридж примера.
-- title: mouse demo
-- author: Filippo
-- desc:
-- script: moon
-- input: mouse
-- pal: DB16
r=0
export TIC=->
cls 0
--get mouse info
x,y,p=mouse()
--if pressed
if p then r=r+2
r-=1
r=math.max(0, math.min(32, r))
--draw stuff
line x,0,x,136,11
line 0,y,240,y,11
circ x,y,r,11
--show coordinates
c=string.format '(%03i,%03i)',x,y
print c,0,0,15,1
// title: mouse demo
// author: Filippo
// desc:
// script: js
// input: mouse
r = 0
function TIC() {
cls(0)
//get mouse info
var m = mouse()
var x = m[0]
var y = m[1]
var p = m[2]
//if pressed
if (p) r = r + 2
r = r - 1
r = Math.max(0, Math.min(32, r))
//draw stuff
line(x, 0, x, 136, 11)
line(0, y, 240, y, 11)
circ(x, y, r, 11)
//show coordinates
c = "(" + x + "," + y + ")"
print(c, 0, 0, 15, 1)
}