Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tps2015gh/70ea6ca8c90cdcae91fe51a02dca611f to your computer and use it in GitHub Desktop.
Save tps2015gh/70ea6ca8c90cdcae91fe51a02dca611f to your computer and use it in GitHub Desktop.

Very Basic Demo only

Love for Lua

//

Lua Programming Language

//

-- ===========================================================================
-- Author: Thitipong Samranvanich
-- Date: 2017-02-26
-- Describe: Demo of using Love with Lua
-- Display Line and Pic / Accept Mouse Input
--
-- ===========================================================================
-- REF class - http://lua-users.org/wiki/PointAndComplex
-- require 'class'
print ("Hello 1 ")
-- REF multiple file https://forums.coronalabs.com/topic/38127-how-to-call-a-function-from-another-lua-file/
-- REF class https://www.lua.org/manual/2.4/node36.html
local Locate = {x = 10 , y =10}
Locate.__index = Locate
--function Locate:new(self )
--
-- end
function Locate:moveto(self, x, y )
-- assert loc is Locate
self.x = x
self.y = y
end
loc = Locate({x=10,y=10})
function love.load()
loc:moveto(10,10)
luckme = love.graphics.newImage("luckme.png")
end
function love.draw()
-- print("Hello 2")
love.graphics.draw(luckme, loc.x, loc.y )
love.graphics.print("Hello World ก ข ค ", loc.x + 20 , loc.y +20 )
-- print("Hello 3")
love.graphics.setColor(255, 20, 0)
love.graphics.circle("line", loc.x , loc.y,20)
love.graphics.line(loc.x,loc.y, 400,50, 500,300, 100,300, loc.x, loc.y)
end
function love.mousemoved(x,y)
print("mouse move " , x , y )
loc.move(x,y)
love.draw()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment