Develop #4
+21
-15
@@ -1,11 +1,9 @@
|
|||||||
local arrows = {}
|
local arrows = {}
|
||||||
|
|
||||||
local padding = 10
|
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.img_left = love.graphics.newImage('assets/sprites/arrows/left.png')
|
||||||
arrows.left_x = padding
|
arrows.left_x = padding
|
||||||
arrows.left_y = (game.canvas.height / 2) - (arrows.img_left:getHeight() /2)
|
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.img_rigth = love.graphics.newImage('assets/sprites/arrows/rigth.png')
|
||||||
arrows.rigth_x = (game.canvas.width - arrows.img_rigth:getWidth()) - padding
|
arrows.rigth_x = (game.canvas.width - arrows.img_rigth:getWidth()) - padding
|
||||||
arrows.rigth_y = (game.canvas.height / 2) - (arrows.img_left:getHeight() /2)
|
arrows.rigth_y = (game.canvas.height / 2) - (arrows.img_left:getHeight() /2)
|
||||||
local_canvas = game.canvas
|
arrows.game = game
|
||||||
camera = camera
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function arrows.update(dt, game)
|
function arrows.update(dt, game)
|
||||||
@@ -22,22 +19,31 @@ function arrows.update(dt, game)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function arrows.draw()
|
function arrows.draw()
|
||||||
love.graphics.draw(arrows.img_left, arrows.left_x, arrows.left_y)
|
if arrows.game.level > 1 then
|
||||||
love.graphics.draw(arrows.img_rigth, arrows.rigth_x, arrows.rigth_y)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
function love.mousepressed(mx, my, button)
|
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 button == 1 then
|
||||||
if mx >= arrows.left_x and mx < arrows.left_x + arrows.img_left:getWidth() then
|
if x1 <= arrows.left_x + arrows.img_left:getWidth() then
|
||||||
if my >= arrows.left_y and my < arrows.left_y + arrows.img_left:getHeight() then
|
if mx >= arrows.left_x and mx < arrows.left_x + arrows.img_left:getWidth() then
|
||||||
print 'Image Click Left'
|
if my >= arrows.left_y and my < arrows.left_y + arrows.img_left:getHeight() then
|
||||||
|
arrows.game:prevLevel()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print(camera)
|
if x2 >= (ww - arrows.img_rigth:getWidth()) then
|
||||||
if mx >= arrows.rigth_x and mx < (arrows.rigth_x + arrows.img_rigth:getWidth() - (local_canvas.width - 2280)) then
|
if mx >= (ww - x1 - arrows.img_rigth:getWidth()) and mx < (ww - arrows.img_rigth:getWidth()) then
|
||||||
print 'fix'
|
if my >= arrows.rigth_y and my < arrows.rigth_y + arrows.img_rigth:getHeight() then
|
||||||
if my >= arrows.rigth_y and my < arrows.rigth_y + arrows.img_rigth:getHeight() then
|
arrows.game:nextLevel()
|
||||||
print 'Image Click Rigth'
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,24 +8,29 @@ end
|
|||||||
|
|
||||||
function controls.update(dt, game)
|
function controls.update(dt, game)
|
||||||
control_up, control_right, control_left, control_quit = false, false, false, false
|
control_up, control_right, control_left, control_quit = false, false, false, false
|
||||||
-- Keyboard
|
-- Keyboard
|
||||||
if love.keyboard.isDown('escape') or love.keyboard.isDown('q') then
|
if love.keyboard.isDown('escape') or love.keyboard.isDown('q') then
|
||||||
control_quit = true
|
control_quit = true
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown('right') then
|
if love.keyboard.isDown('right') then
|
||||||
control_right = true
|
control_right = true
|
||||||
elseif love.keyboard.isDown('left') then
|
elseif love.keyboard.isDown('left') then
|
||||||
control_left = true
|
control_left = true
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown('up') then
|
if love.keyboard.isDown('up') then
|
||||||
|
|
||||||
control_up = true
|
control_up = true
|
||||||
end
|
end
|
||||||
-- Mouse
|
-- Mouse
|
||||||
if control_left then
|
if control_left then
|
||||||
game.canvas.x = game.canvas.x - limit
|
if game.canvas.x > game.window.width / 2 then
|
||||||
|
game.canvas.x = game.canvas.x - limit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if control_right then
|
if control_right then
|
||||||
game.canvas.x = game.canvas.x + limit
|
if game.canvas.x <= game.canvas.width - (game.window.width/2) then
|
||||||
|
game.canvas.x = game.canvas.x + limit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+19
-1
@@ -1,13 +1,15 @@
|
|||||||
local game = {}
|
local game = {}
|
||||||
|
local gamera = require 'assets/scripts/vendor/gamera'
|
||||||
|
|
||||||
function game.load()
|
function game.load()
|
||||||
|
|
||||||
-- Configuration
|
-- Configuration
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
local width, height = 1280, 720
|
local width, height = 1280, 720
|
||||||
local canvas_width, canvas_height = 2280, 720
|
local canvas_width, canvas_height = 2280, 720
|
||||||
game.window = { width = width , height = height }
|
game.window = { width = width , height = height }
|
||||||
game.canvas = { x = width / 2, y= 0, width = canvas_width, height = canvas_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)
|
love.window.setMode(game.window.width, game.window.height)
|
||||||
|
|
||||||
@@ -21,4 +23,20 @@ function game.load()
|
|||||||
bells_enable = true
|
bells_enable = true
|
||||||
end
|
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
|
return game
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ local stage1 = {}
|
|||||||
local image
|
local image
|
||||||
|
|
||||||
function stage1.load(game, camera)
|
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')
|
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
|
end
|
||||||
|
|
||||||
function stage1.update(dt, game)
|
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 game = require 'assets/scripts/game'
|
||||||
local stage1 = require 'assets/scripts/stage1'
|
local stages = require 'assets/scripts/stages'
|
||||||
local controls = require 'assets/scripts/controls'
|
local controls = require 'assets/scripts/controls'
|
||||||
local bells = require 'assets/scripts/bells'
|
local bells = require 'assets/scripts/bells'
|
||||||
local camera = require 'assets/scripts/camera'
|
local camera = require 'assets/scripts/camera'
|
||||||
|
|
||||||
|
|
||||||
-- LOAD
|
-- LOAD
|
||||||
function love.load()
|
function love.load()
|
||||||
game.load()
|
game.load()
|
||||||
camera.load(game)
|
camera.load(game)
|
||||||
stage1.load(game, camera)
|
stages.load(game, camera)
|
||||||
bells.load(game, camera.gcam)
|
bells.load(game, camera.gcam)
|
||||||
controls.load(game)
|
controls.load(game)
|
||||||
end
|
end
|
||||||
@@ -16,7 +17,7 @@ end
|
|||||||
-- UPDATE
|
-- UPDATE
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
game.world:update(dt)
|
game.world:update(dt)
|
||||||
stage1.update(dt)
|
stages.update(dt, game, camera)
|
||||||
camera.update(game)
|
camera.update(game)
|
||||||
bells.update(dt)
|
bells.update(dt)
|
||||||
controls.update(dt, game)
|
controls.update(dt, game)
|
||||||
@@ -26,7 +27,7 @@ end
|
|||||||
function love.draw()
|
function love.draw()
|
||||||
camera.gcam:draw(
|
camera.gcam:draw(
|
||||||
function(l,t,w,h)
|
function(l,t,w,h)
|
||||||
stage1.draw()
|
stages.draw()
|
||||||
bells.draw(game)
|
bells.draw(game)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user