You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 4 година
пре 1 година
пре 4 година
пре 1 година
пре 4 година
пре 1 година
пре 4 година
пре 1 година
пре 4 година
пре 1 година
пре 1 година
пре 4 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. VIRTUAL_WIDTH = 1280
  2. VIRTUAL_HEIGHT = 720
  3. WINDOW_WIDTH = 1280
  4. WINDOW_HEIGHT = 720
  5. Class = require 'class'
  6. require 'simpleScale'
  7. require 'life'
  8. require 'edible'
  9. bugs = {}
  10. edibles = {}
  11. rules = {}
  12. function love.load()
  13. math.randomseed(os.time())
  14. smallfont = love.graphics.newFont("font.ttf", 15)
  15. smallestfont = love.graphics.newFont("font.ttf", 5)
  16. love.keyboard.setKeyRepeat(true)
  17. simpleScale.setWindow(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
  18. table.insert(bugs, life(VIRTUAL_HEIGHT/2, VIRTUAL_WIDTH/2, 10, 159))
  19. table.insert(edibles, edible(20, VIRTUAL_WIDTH/2+5, 4))
  20. rules["abundantFood"] = false
  21. end
  22. function love.update(dt)
  23. love.window.setTitle(#bugs)
  24. for i, bug in ipairs(bugs) do
  25. bug:update(dt)
  26. end
  27. regulator()
  28. end
  29. function regulator()
  30. for i, bug in ipairs(bugs) do
  31. if bug.dead then
  32. table.insert(edibles, edible(bug.y, bug.x, bug.fat))
  33. table.remove(bugs, i)
  34. end
  35. end
  36. if #bugs == 0 then
  37. table.insert(bugs, life(VIRTUAL_HEIGHT/2, VIRTUAL_WIDTH/2, 10, 159))
  38. end
  39. if #edibles < #bugs/3 and rules["abundantFood"] then
  40. table.insert(edibles, edible(math.random(0, VIRTUAL_HEIGHT), math.random(0, VIRTUAL_WIDTH), 10))
  41. elseif #edibles <= 10 then
  42. table.insert(edibles, edible(math.random(0, VIRTUAL_HEIGHT), math.random(0, VIRTUAL_WIDTH), 10))
  43. end
  44. end
  45. function love.draw()
  46. simpleScale.set()
  47. love.graphics.clear(0,0,0,1)
  48. for i, bug in ipairs(bugs) do
  49. bug:render(dt)
  50. end
  51. for i, edible in ipairs(edibles) do
  52. edible:render(dt)
  53. end
  54. love.graphics.setColor(1,1,1,1)
  55. love.graphics.setFont(smallfont)
  56. simpleScale.unSet()
  57. end