Lua Mouse input


Example

Although it's not officially supported, you can use mouse input in your games:

function _update60()
  x = stat(32)
  y = stat(33)
  
  if (x>0 and x<=128 and
      y>0 and y<=128) 
  then
     
    -- left button
    if (band(stat(34),1)==1) then
      ball_x=x
      ball_y=y
    end
  end
    
  -- right button
  if (band(stat(34),2)==2) then
    ball_c+=1
    ball_c%=16
  end
  
  -- middle button
  if (band(stat(34),4)==4) then
    ball_r+=1
    ball_r%=64
  end
end

function _init()
  ball_x=63
  ball_y=63
  ball_c=10
  ball_r=1
end

function _draw()
  cls()
  print(stat(34),1,1)
  circ(ball_x,ball_y,ball_r,ball_c)
  pset(x,y,7) -- white
end