游戏模式

如果你需要标题屏幕或结束游戏屏幕,请考虑设置模式切换机制:

function _init()
  mode = 1
end

function _update()
  if (mode == 1) then
    if (btnp(5)) mode = 2
  elseif (mode == 2) then
    if (btnp(5)) mode = 3
  end
end

function _draw()
  cls()
  if (mode == 1) then
    title()
  elseif (mode == 2) then
    print("press 'x' to win")
  else
    end_screen()
  end 
end

function title()
  print("press 'x' to start game")
end

function end_screen()
  print("a winner is you")
end