love2d尝试
目录
love2d 轻量到我不敢想象,安装后只需要一个 lua 脚本就可以运行
这样就实现了一个简单的可以移动的窗口
lua
function love.load()
x = 100
y = 100
text = ''
end
function love.update(dt)
if love.keyboard.isDown('w') then
y = y - 100 * dt
text = 'w'
end
if love.keyboard.isDown('s') then
y = y + 100 * dt
text = 's'
end
if love.keyboard.isDown('a') then
x = x - 100 * dt
text = 'a'
end
if love.keyboard.isDown('d') then
x = x + 100 * dt
text = 'd'
end
end
function love.draw()
love.graphics.rectangle("line", x, y, 50, 50)
love.graphics.print(text, x + 20, y + 20)
end
function love.keypressed(key, scancode, isrepeat)
if key == "escape" then
love.event.quit()
end
end
love2d 把一个游戏引擎最重要的几个东西做出来了
love.load() 负责加载变量 love.draw() 在每次调用的时候绘制画面 love.update() 用来写游戏逻辑 love.keypressed() 监听键盘按键
其他包括图片和音乐什么的都 有了
做一个小游戏什么的会非常方便