1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Love2D:ゲームエンジンその4

Posted at

###元記事
http://www.headchant.com/2010/11/27/love2d-tutorial-part-1-invaders-must-die/

これも良いサンプル
キーの受け取り、移動ができるようになります。

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
はい出来ました。
スクリーンショット 2014-12-22 19.17.35.png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?