Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

元記事

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

ggggnonaka
業務系SEなのに、ゲームプログラム、Webを教えてます。そろそろ本業だけにしとくかなぁ。僕はもう疲れたよ。教育なんてさ...
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away