2015-02-17 19:17:09 +00:00
|
|
|
require "global"
|
|
|
|
require "tiled"
|
|
|
|
require "anim"
|
|
|
|
require "ninja"
|
2017-06-25 08:43:05 +00:00
|
|
|
require "obake"
|
2015-02-17 19:17:09 +00:00
|
|
|
|
|
|
|
function lutro.conf(t)
|
|
|
|
t.width = SCREEN_WIDTH
|
|
|
|
t.height = SCREEN_HEIGHT
|
|
|
|
end
|
|
|
|
|
|
|
|
local add_entity_from_map = function(object)
|
|
|
|
if object.type == "ground" then
|
|
|
|
table.insert(entities, object)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function lutro.load()
|
2015-08-21 04:21:36 +00:00
|
|
|
camera_x = 0
|
|
|
|
camera_y = 0
|
2015-02-23 00:14:37 +00:00
|
|
|
lutro.graphics.setBackgroundColor(0, 0, 0)
|
|
|
|
bg1 = lutro.graphics.newImage("assets/forestbackground.png")
|
|
|
|
bg2 = lutro.graphics.newImage("assets/foresttrees.png")
|
|
|
|
font = lutro.graphics.newImageFont("assets/font.png",
|
2015-02-19 16:37:26 +00:00
|
|
|
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/")
|
2015-02-23 00:14:37 +00:00
|
|
|
lutro.graphics.setFont(font)
|
|
|
|
map = tiled_load("assets/pagode.json")
|
2015-02-17 19:17:09 +00:00
|
|
|
tiled_load_objects(map, add_entity_from_map)
|
2017-06-25 08:43:05 +00:00
|
|
|
ninja = newNinja()
|
|
|
|
table.insert(entities, ninja)
|
|
|
|
table.insert(entities, newObake())
|
2015-02-17 19:17:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function lutro.update(dt)
|
|
|
|
for i=1, #entities do
|
|
|
|
if entities[i].update then
|
|
|
|
entities[i]:update(dt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
detect_collisions()
|
|
|
|
end
|
|
|
|
|
|
|
|
function lutro.draw()
|
2015-02-23 00:14:37 +00:00
|
|
|
lutro.graphics.clear()
|
2015-02-17 19:56:16 +00:00
|
|
|
|
2015-08-21 04:21:36 +00:00
|
|
|
for i=0, 4 do
|
|
|
|
lutro.graphics.draw(bg1, i*bg1:getWidth() + camera_x / 6, 0)
|
|
|
|
lutro.graphics.draw(bg2, i*bg2:getWidth() + camera_x / 3, 0)
|
2015-02-17 19:56:16 +00:00
|
|
|
end
|
|
|
|
|
2015-08-24 22:46:57 +00:00
|
|
|
lutro.graphics.push()
|
|
|
|
|
2015-08-21 04:21:36 +00:00
|
|
|
lutro.graphics.translate(camera_x, camera_y)
|
|
|
|
|
2015-02-17 19:17:09 +00:00
|
|
|
tiled_draw_layer(map.layers[1])
|
|
|
|
for i=1, #entities do
|
|
|
|
if entities[i].draw then
|
|
|
|
entities[i]:draw(dt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tiled_draw_layer(map.layers[2])
|
2015-02-19 16:37:26 +00:00
|
|
|
|
2015-08-24 22:46:57 +00:00
|
|
|
lutro.graphics.pop()
|
2015-08-21 04:21:36 +00:00
|
|
|
|
2015-02-23 00:14:37 +00:00
|
|
|
lutro.graphics.print("Hello world!", 3, 1)
|
2015-02-17 19:17:09 +00:00
|
|
|
end
|