Love2D:ゲームエンジンその4
元記事
これも良いサンプル
キーの受け取り、移動ができるようになります。
main.lua
-- tutorial #1
-- the 3 golden love function, lua tables, keyboard input, draw circle
function love.load()
hero = {} -- new table for the hero
hero.x = 300 -- x,y coordinates of the hero
hero.y = 450
hero.speed = 100
end
function love.update(dt)
if love.keyboard.isDown("left") then
hero.x = hero.x - hero.speed*dt
elseif love.keyboard.isDown("right") then
hero.x = hero.x + hero.speed*dt
end
end
function love.draw()
-- let's draw some ground
love.graphics.setColor(0,255,0,255)
love.graphics.rectangle("fill", 0,465,800,150)
-- let's draw our hero
love.graphics.setColor(255,255,0,255)
love.graphics.rectangle("fill", hero.x,hero.y, 30,15)
end
Zip
作業ディレクトリで以下コマンド発行
zip -r ../${PWD##*/}.love *
Run
Author And Source
この問題について(Love2D:ゲームエンジンその4), 我々は、より多くの情報をここで見つけました https://qiita.com/ggggnonaka/items/47d0b3ada99796ddae42著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .