added the crates and the crate object plus making them joint
This commit is contained in:
13
main.lua
13
main.lua
@@ -3,6 +3,9 @@ Boipus = require('deps.boipushy')
|
||||
Physics = require('deps.physics')
|
||||
assets = require('deps.cargo').init('data')
|
||||
|
||||
-- my own libs
|
||||
crates = require('crate')
|
||||
|
||||
local CONST_GRAVITY = 512
|
||||
local CONST_SIDES = {
|
||||
LEFT = {
|
||||
@@ -22,8 +25,6 @@ local player = {
|
||||
}
|
||||
|
||||
local magnet = {
|
||||
x = 50,
|
||||
y = 50,
|
||||
w = 50,
|
||||
h = 50,
|
||||
collider = nil,
|
||||
@@ -44,9 +45,10 @@ function love.load()
|
||||
world = Physics(0, 0)
|
||||
world:addClass('Player')
|
||||
world:addClass('Side')
|
||||
world:addClass('Crate')
|
||||
side.left = world:addChain(true, CONST_SIDES.LEFT):setClass('Side')
|
||||
side.right = world:addChain(true, CONST_SIDES.RIGHT):setClass('Side')
|
||||
magnet.collider = world:addRectangle(magnet.x, magnet.y, magnet.w, magnet.h):setClass('Player')
|
||||
magnet.collider = world:addRectangle(50, 50, magnet.w, magnet.h):setClass('Player')
|
||||
magnet.collider:setRestitution(0)
|
||||
|
||||
input = Boipus()
|
||||
@@ -58,6 +60,10 @@ function love.load()
|
||||
input:bind(love.keyboard.getKeyFromScancode('s'), 'moveDown')
|
||||
input:bind(love.keyboard.getKeyFromScancode('space'), 'switch')
|
||||
|
||||
crates:init(world, magnet)
|
||||
crates:spawn(120, 400)
|
||||
crates:spawn(150, 400)
|
||||
|
||||
-- Gamepad
|
||||
--[[input:bind('dpup', 'moveUp')
|
||||
input:bind('dpleft', 'moveLeft')
|
||||
@@ -67,6 +73,7 @@ end
|
||||
|
||||
function love.update(dt)
|
||||
world:update(dt)
|
||||
crates:update(dt)
|
||||
|
||||
--[[ if input:down('moveUp') then magnet.collider:applyLinearImpulse(0, -player.maxSpeed.y) end
|
||||
if input:down('moveLeft') then magnet.collider:applyLinearImpulse(-player.maxSpeed.x, 0) end
|
||||
|
||||
Reference in New Issue
Block a user