first lines of code for the main game script

This commit is contained in:
2021-05-08 11:42:35 +02:00
parent f96a1e19ec
commit e5f96e9320

View File

@@ -0,0 +1,52 @@
-- Chuchu by Makaron
Boipus = require('deps.boipushy')
BF = require('deps.breezefield')
assets = require('deps.cargo').init('data')
local player = {
maxSpeed = {
x = 2,
y = 2
}
}
local magnet = {
x = 50,
y = 50
}
function love.load()
love.window.setMode(512, 512)
input = Boipus()
-- Controls
-- Keyboard and mouse
input:bind(love.keyboard.getKeyFromScancode('w'), 'moveUp')
input:bind(love.keyboard.getKeyFromScancode('a'), 'moveLeft')
input:bind(love.keyboard.getKeyFromScancode('d'), 'moveRight')
input:bind(love.keyboard.getKeyFromScancode('s'), 'moveDown')
-- Gamepad
--[[input:bind('dpup', 'moveUp')
input:bind('dpleft', 'moveLeft')
input:bind('dpright', 'moveRight')
input:bind('dpdown', 'moveDown')]]--
end
function love.update(dt)
-- controls(dt)
if input:down('moveUp') then magnet.y = magnet.y - player.maxSpeed.y end
if input:down('moveLeft') then magnet.x = magnet.x - player.maxSpeed.x end
if input:down('moveRight') then magnet.x = magnet.x + player.maxSpeed.x end
if input:down('moveDown') then magnet.y = magnet.y + player.maxSpeed.y end
end
function love.draw()
love.graphics.clear(255, 255, 255)
love.graphics.setColor(0, 0, 0, 1)
love.graphics.rectangle('line', magnet.x, magnet.y, 32, 32)
-- love.graphics.print('Key code: ' .. key)
--love.graphics.draw(assets.sprites.crane)
end