|
- -- world module
- local world = require("world")
- -- entities module
- local entities = require("entities")
-
- -- love's load function
- function love.load()
- -- set the overall map offset
- offset = {
- x = 304,
- y = 48
- }
-
- -- generate the world and load the files
- world.new(20, 20, 3)
- world.generate()
- world.loadTiles()
-
- -- entities initialization
- entities.init()
- entities.loadSprites()
- entities.newStatic(7, 7, 3, "town")
- end
-
- -- love's update function
- function love.update(dt)
-
- end
-
- -- love's key press funciton
- function love.keypressed(key, scanCode, isRepeat)
- -- arrow keys for moving offset
- if key == "left" then
- offset.x = offset.x + 16
- end
-
- if key == "right" then
- offset.x = offset.x - 16
- end
-
- if key == "up" then
- offset.y = offset.y + 16
- end
-
- if key == "down" then
- offset.y = offset.y - 16
- end
-
- if key == "escape" then
- love.event.quit(0)
- end
- end
-
- -- love's draw function
- function love.draw()
- -- clear the window
- love.graphics.clear()
-
- -- draw the map
- world.render(offset)
-
- -- draw the entities
- entities.render(offset)
- end
|