Develop #4
+16
-10
@@ -1,11 +1,9 @@
|
||||
local arrows = {}
|
||||
|
||||
local padding = 10
|
||||
local local_canvas = {}
|
||||
local camera = nil
|
||||
|
||||
function arrows.load(game, camera)
|
||||
|
||||
function arrows.load(game, stage, camera)
|
||||
arrows.img_left = love.graphics.newImage('assets/sprites/arrows/left.png')
|
||||
arrows.left_x = padding
|
||||
arrows.left_y = (game.canvas.height / 2) - (arrows.img_left:getHeight() /2)
|
||||
@@ -13,8 +11,7 @@ function arrows.load(game, camera)
|
||||
arrows.img_rigth = love.graphics.newImage('assets/sprites/arrows/rigth.png')
|
||||
arrows.rigth_x = (game.canvas.width - arrows.img_rigth:getWidth()) - padding
|
||||
arrows.rigth_y = (game.canvas.height / 2) - (arrows.img_left:getHeight() /2)
|
||||
local_canvas = game.canvas
|
||||
camera = camera
|
||||
arrows.game = game
|
||||
end
|
||||
|
||||
function arrows.update(dt, game)
|
||||
@@ -22,22 +19,31 @@ function arrows.update(dt, game)
|
||||
end
|
||||
|
||||
function arrows.draw()
|
||||
if arrows.game.level > 1 then
|
||||
love.graphics.draw(arrows.img_left, arrows.left_x, arrows.left_y)
|
||||
end
|
||||
if arrows.game.level ~= arrows.game.end_level then
|
||||
love.graphics.draw(arrows.img_rigth, arrows.rigth_x, arrows.rigth_y)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.mousepressed(mx, my, button)
|
||||
x1,y1,x2,y2,x3,y3,x4,y4 = camera.gcam:getVisibleCorners()
|
||||
wl, wt, ww, wh = camera.gcam:getWorld()
|
||||
if button == 1 then
|
||||
if x1 <= arrows.left_x + arrows.img_left:getWidth() then
|
||||
if mx >= arrows.left_x and mx < arrows.left_x + arrows.img_left:getWidth() then
|
||||
if my >= arrows.left_y and my < arrows.left_y + arrows.img_left:getHeight() then
|
||||
print 'Image Click Left'
|
||||
arrows.game:prevLevel()
|
||||
end
|
||||
end
|
||||
print(camera)
|
||||
if mx >= arrows.rigth_x and mx < (arrows.rigth_x + arrows.img_rigth:getWidth() - (local_canvas.width - 2280)) then
|
||||
print 'fix'
|
||||
end
|
||||
if x2 >= (ww - arrows.img_rigth:getWidth()) then
|
||||
if mx >= (ww - x1 - arrows.img_rigth:getWidth()) and mx < (ww - arrows.img_rigth:getWidth()) then
|
||||
if my >= arrows.rigth_y and my < arrows.rigth_y + arrows.img_rigth:getHeight() then
|
||||
print 'Image Click Rigth'
|
||||
arrows.game:nextLevel()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,15 +18,20 @@ function controls.update(dt, game)
|
||||
control_left = true
|
||||
end
|
||||
if love.keyboard.isDown('up') then
|
||||
|
||||
control_up = true
|
||||
end
|
||||
-- Mouse
|
||||
if control_left then
|
||||
if game.canvas.x > game.window.width / 2 then
|
||||
game.canvas.x = game.canvas.x - limit
|
||||
end
|
||||
end
|
||||
if control_right then
|
||||
if game.canvas.x <= game.canvas.width - (game.window.width/2) then
|
||||
game.canvas.x = game.canvas.x + limit
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
+19
-1
@@ -1,13 +1,15 @@
|
||||
local game = {}
|
||||
local gamera = require 'assets/scripts/vendor/gamera'
|
||||
|
||||
function game.load()
|
||||
|
||||
-- Configuration
|
||||
math.randomseed(os.time())
|
||||
local width, height = 1280, 720
|
||||
local canvas_width, canvas_height = 2280, 720
|
||||
game.window = { width = width , height = height }
|
||||
game.canvas = { x = width / 2, y= 0, width = canvas_width, height = canvas_height }
|
||||
game.level = 1
|
||||
game.end_level = 2
|
||||
|
||||
love.window.setMode(game.window.width, game.window.height)
|
||||
|
||||
@@ -21,4 +23,20 @@ function game.load()
|
||||
bells_enable = true
|
||||
end
|
||||
|
||||
function game:nextLevel()
|
||||
game.level = game.level + 1
|
||||
end
|
||||
|
||||
function game:prevLevel()
|
||||
game.level = game.level - 1
|
||||
end
|
||||
|
||||
function game:setNewSizeWorld(canvas_width, canvas_height)
|
||||
local width, height = 1280, 720
|
||||
game.window = { width = width , height = height }
|
||||
game.canvas = { x = width / 2, y= 0, width = canvas_width, height = canvas_height }
|
||||
camera.gcam = gamera.new(0, 0, game.window.width, game.window.height)
|
||||
camera.gcam:setWorld(0, 0, game.canvas.width, game.canvas.height)
|
||||
end
|
||||
|
||||
return game
|
||||
|
||||
@@ -6,8 +6,11 @@ local stage1 = {}
|
||||
local image
|
||||
|
||||
function stage1.load(game, camera)
|
||||
stage1.world = { w = 2560, h= 720}
|
||||
game:setNewSizeWorld(stage1.world.w, stage1.world.h)
|
||||
image = love.graphics.newImage('assets/sprites/background/bg.jpg')
|
||||
arrows.load(game, camera)
|
||||
arrows.load(game, stage1, camera)
|
||||
game.canvas.x = game.window.width
|
||||
end
|
||||
|
||||
function stage1.update(dt, game)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
local anim8 = require 'assets/scripts/vendor/anim8'
|
||||
local tools = require 'assets/scripts/tools'
|
||||
local arrows = require 'assets/scripts/arrows'
|
||||
|
||||
local stage2 = {}
|
||||
local image
|
||||
|
||||
function stage2.load(game, camera)
|
||||
stage2.world = { w = 2280, h= 720}
|
||||
game:setNewSizeWorld(stage2.world.w, stage2.world.h)
|
||||
image = love.graphics.newImage('assets/sprites/background/bg2.jpg')
|
||||
arrows.load(game, stage2, camera)
|
||||
game.canvas.x = game.canvas.width / 2
|
||||
end
|
||||
|
||||
function stage2.update(dt, game)
|
||||
arrows.update(dt)
|
||||
end
|
||||
|
||||
function stage2.draw()
|
||||
love.graphics.draw(image)
|
||||
arrows.draw()
|
||||
end
|
||||
|
||||
return stage2
|
||||
@@ -0,0 +1,31 @@
|
||||
local anim8 = require 'assets/scripts/vendor/anim8'
|
||||
local stage1 = require 'assets/scripts/stage1'
|
||||
local stage2 = require 'assets/scripts/stage2'
|
||||
local dynamic_stage = nil
|
||||
|
||||
local stages = {}
|
||||
local image
|
||||
local currentLevel = 1
|
||||
|
||||
function stages.load(game, camera)
|
||||
currentLevel = game.level
|
||||
dynamic_stage = require("assets/scripts/stage"..currentLevel)
|
||||
dynamic_stage.load(game, camera)
|
||||
end
|
||||
|
||||
function stages.update(dt, game, camera)
|
||||
if game.level ~= currentLevel then
|
||||
currentLevel = game.level
|
||||
dynamic_stage = require("assets/scripts/stage"..currentLevel)
|
||||
dynamic_stage.load(game, camera)
|
||||
dynamic_stage.update(dt, game)
|
||||
else
|
||||
dynamic_stage.update(dt, game)
|
||||
end
|
||||
end
|
||||
|
||||
function stages.draw()
|
||||
dynamic_stage.draw()
|
||||
end
|
||||
|
||||
return stages
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 81 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
@@ -1,14 +1,15 @@
|
||||
local game = require 'assets/scripts/game'
|
||||
local stage1 = require 'assets/scripts/stage1'
|
||||
local stages = require 'assets/scripts/stages'
|
||||
local controls = require 'assets/scripts/controls'
|
||||
local bells = require 'assets/scripts/bells'
|
||||
local camera = require 'assets/scripts/camera'
|
||||
|
||||
|
||||
-- LOAD
|
||||
function love.load()
|
||||
game.load()
|
||||
camera.load(game)
|
||||
stage1.load(game, camera)
|
||||
stages.load(game, camera)
|
||||
bells.load(game, camera.gcam)
|
||||
controls.load(game)
|
||||
end
|
||||
@@ -16,7 +17,7 @@ end
|
||||
-- UPDATE
|
||||
function love.update(dt)
|
||||
game.world:update(dt)
|
||||
stage1.update(dt)
|
||||
stages.update(dt, game, camera)
|
||||
camera.update(game)
|
||||
bells.update(dt)
|
||||
controls.update(dt, game)
|
||||
@@ -26,7 +27,7 @@ end
|
||||
function love.draw()
|
||||
camera.gcam:draw(
|
||||
function(l,t,w,h)
|
||||
stage1.draw()
|
||||
stages.draw()
|
||||
bells.draw(game)
|
||||
end
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user