Code: Select all
function KanaColumn(sprite,xpos,ypos,kanalist)
kana = ''
local sprh = sprite:getHeight()
local sprw = sprite:getWidth()
if mouseX >= xpos-(sprw/2) and mouseX <= xpos+(sprw/2) then
if mouseY >= ypos-(sprh/2) and mouseY <= (ypos-(sprh/2))+32 then kana = kanalist[1] end
if mouseY >= (ypos-(sprh/2))+33 and mouseY <= (ypos-(sprh/2))+64 then kana = kanalist[2] end
if mouseY >= (ypos-(sprh/2))+65 and mouseY <= (ypos-(sprh/2))+96 then kana = kanalist[3] end
if mouseY >= (ypos-(sprh/2))+97 and mouseY <= (ypos-(sprh/2))+128 then kana = kanalist[4] end
if mouseY >= (ypos-(sprh/2))+129 and mouseY <= (ypos-(sprh/2))+160 then kana = kanalist[5] end
end
end
function load()
--Images
bg = love.graphics.newImage("bg.png")
hira1 = love.graphics.newImage("hira_vowels.png")
hira2 = love.graphics.newImage("hira_k.png")
--Text
font = love.graphics.newFont(love.default_font, 24)
love.graphics.setFont(font)
love.graphics.setColor(0,0,0)
--Word Arrays
hira_vowels = {"a","e","i","o","u"}
hira_ks = {"ka","ke","ki","ko","ku"}
end
function update(dt)
mouseX = love.mouse.getX()
mouseY = love.mouse.getY()
KanaColumn(hira1,100,240,hira_vowels)
KanaColumn(hira2,132,240,hira_ks)
end
function draw()
love.graphics.draw(bg, 320, 240)
love.graphics.draw(hira1, 100, 240)
love.graphics.draw(hira2, 132, 240)
love.graphics.draw(kana, 320,100)
end