an unnamed video game
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.

64 lines
1.2 KiB

  1. -- world module
  2. local world = require("world")
  3. -- entities module
  4. local entities = require("entities")
  5. -- love's load function
  6. function love.load()
  7. -- set the overall map offset
  8. offset = {
  9. x = 304,
  10. y = 48
  11. }
  12. -- generate the world and load the files
  13. world.new(20, 20, 3)
  14. world.generate()
  15. world.loadTiles()
  16. -- entities initialization
  17. entities.init()
  18. entities.loadSprites()
  19. entities.newStatic(7, 7, 3, "town")
  20. end
  21. -- love's update function
  22. function love.update(dt)
  23. end
  24. -- love's key press funciton
  25. function love.keypressed(key, scanCode, isRepeat)
  26. -- arrow keys for moving offset
  27. if key == "left" then
  28. offset.x = offset.x + 16
  29. end
  30. if key == "right" then
  31. offset.x = offset.x - 16
  32. end
  33. if key == "up" then
  34. offset.y = offset.y + 16
  35. end
  36. if key == "down" then
  37. offset.y = offset.y - 16
  38. end
  39. if key == "escape" then
  40. love.event.quit(0)
  41. end
  42. end
  43. -- love's draw function
  44. function love.draw()
  45. -- clear the window
  46. love.graphics.clear()
  47. -- draw the map
  48. world.render(offset)
  49. -- draw the entities
  50. entities.render(offset)
  51. end