main2.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. graphics=require("graphics")
  2. matrix=require("matrix")
  3. quat=require("quat")
  4. vector=require("vector")
  5. loadobj=require("obj")
  6. posteffect=require("posteffect")
  7. keycode,keyname=table.unpack(require("keys"))
  8. gui=require("gui")
  9. errfunc=function(str)
  10. print(str)
  11. end
  12. w=graphics.window.new(1366,748,"title",errfunc)
  13. dt=graphics:timedelta()
  14. width,height,t=0,0,1
  15. font=w:font("fonts/mplus-1m-regular.ttf",16)
  16. g=gui.init(w)
  17. render=function(...)
  18. while not w:shouldclose() do
  19. dt=graphics:timedelta()
  20. t=t+dt
  21. width,height=w:getsize()
  22. w:viewport(0,0,width,height)
  23. w:clearcolor(0.1,0.1,0.1,1.0)
  24. local mx,my=w:mousegetpos()
  25. g:draw(mx+10,my,200,150,{0.0,0.0,0.0,0.5})
  26. font:draw(mx+10,my+16,200,150,"Hello, World!!!!\nqwertyuiop[](){}\'\""..tostring(t),{1.0,0.7,0.0,1.0})
  27. w:swap()
  28. graphics.pollevents()
  29. end
  30. w:close()
  31. --closetask(id)
  32. --closetask(id2)
  33. collectgarbage()
  34. end
  35. keycb=function(win,key,scancode,action,mods)
  36. print("key "..tostring(key))
  37. end
  38. --w:keycallback(keycb,errfunc)
  39. qwe=function(tt,...)
  40. local num=0
  41. --tt=1.3
  42. while true do
  43. if t>tt*num then
  44. print("num"..tostring(num))
  45. num=num+1
  46. end
  47. --coroutine.yield()
  48. end
  49. end
  50. --id2=newtask(qwe,errfunc,1.1,"q","w","e","r","t","y")
  51. --id=newtask(qwe,errfunc,1.3)
  52. newtask(render,errfunc,1,2,3,4,5)