Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. -- Soda
  2.  
  3. displayMode(OVERLAY)
  4. displayMode(FULLSCREEN)
  5. -- Use this as a template for your projects that have Soda as a dependency.
  6.  
  7. function setup()
  8. saveProjectInfo("Description", "Soda v"..Soda.version)
  9. profiler.init()
  10. Soda.setup()
  11. parameter.watch("Soda.focus.title")
  12. --barracks{}
  13. listRax()
  14. --overview{}
  15. -- demo1() --do your setting up here
  16. local stats = Soda.Window{
  17. hidden = true,
  18. x = 0, y = -0.001, w = 200, h = 120,
  19. title = "Profiler\n\n\n", --will be overridden
  20. -- shapeArgs = {corners = 8},
  21. blurred = true, shadow = true,
  22. update = function(self) --update will be called every frame
  23. self.title = string.format("Profiler\n\nFPS: %.2f\nMem: %.2f", profiler.fps, profiler.mem)
  24. end
  25. }
  26.  
  27. Soda.Switch{ --a switch to toggle the profiler stats panel
  28. parent = buttonPanel,
  29. x = 20, y = -80,
  30. title = "Show profiler",
  31. callback = function() stats:show(LEFT) end,
  32. callbackOff = function() stats:hide(LEFT) end
  33. }
  34.  
  35. end
  36.  
  37. function draw()
  38. --do your updating here
  39. pushMatrix()
  40. Soda.camera()
  41. drawing()
  42. popMatrix()
  43. profiler.draw()
  44. end
  45.  
  46. function drawing(breakPoint)
  47. --in order for gaussian blur to work, do all your drawing here
  48.  
  49. sprite("Cargo Bot:Game Area", WIDTH*0.5, HEIGHT*0.5, WIDTH, HEIGHT)
  50. --pushStyle()noStroke()fill(40, 80, 50, 50)rectMode(CORNER)rect(0,0,WIDTH,HEIGHT)popStyle()
  51. Soda.draw(breakPoint)
  52. end
  53.  
  54. --user inputs:
  55.  
  56. function touched(touch)
  57. if Soda.touched(touch) then return end
  58. --your touch code goes here
  59. end
  60.  
  61. function keyboard(key)
  62. Soda.keyboard(key)
  63. end
  64.  
  65. function orientationChanged(ori)
  66. Soda.orientationChanged(ori)
  67. end
  68.  
  69. --measure performance:
  70.  
  71. profiler={}
  72.  
  73. function profiler.init(quiet)
  74. profiler.del=0
  75. profiler.c=0
  76. profiler.fps=0
  77. profiler.mem=0
  78. if not quiet then
  79. parameter.watch("profiler.fps")
  80. parameter.watch("profiler.mem")
  81. end
  82. end
  83.  
  84. function profiler.draw()
  85. profiler.del = profiler.del + DeltaTime
  86. profiler.c = profiler.c + 1
  87. if profiler.c==10 then
  88. profiler.fps=profiler.c/profiler.del
  89. profiler.del=0
  90. profiler.c=0
  91. profiler.mem=collectgarbage("count", 2)
  92. end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement