made compatible with 0.10.x
This commit is contained in:
147
src/main.lua
147
src/main.lua
@@ -5,6 +5,19 @@ local insert = table.insert
|
|||||||
local lg = love.graphics
|
local lg = love.graphics
|
||||||
local lm = love.mouse
|
local lm = love.mouse
|
||||||
|
|
||||||
|
local LEFT_MOUSE, RIGHT_MOUSE
|
||||||
|
|
||||||
|
if love.getVersion then
|
||||||
|
local _, minor = love.getVersion()
|
||||||
|
if minor == 10 then
|
||||||
|
LEFT_MOUSE = 1
|
||||||
|
RIGHT_MOUSE = 2
|
||||||
|
else
|
||||||
|
LEFT_MOUSE = "l"
|
||||||
|
RIGHT_MOUSE = "r"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local inspect = require "lib.inspect" --NOTE DEBUG
|
local inspect = require "lib.inspect" --NOTE DEBUG
|
||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
@@ -113,10 +126,83 @@ function love.draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not love.getVersion then
|
||||||
|
lg.print("This toy is probably not compatible with the version of LOVE you are using!!", 2, 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function wheelUP(x, y)
|
||||||
|
if not holding then
|
||||||
|
for i=#items,1,-1 do --ABSTRACT THIS FOR, I DO IT TOO MUCH ?
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
--items[i]:shuffleCards() -- now we pick it up instead!
|
||||||
|
holding = table.remove(items, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif holding:isInstanceOf(Card) then
|
||||||
|
for i=#items,1,-1 do
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
items[i]:placeCardsOn(holding)
|
||||||
|
holding = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif holding:isInstanceOf(Deck) then
|
||||||
|
for i=#items,1,-1 do
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
items[i]:placeCardsOn(holding:getCards())
|
||||||
|
holding = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if holding then --if we didn't just get rid of it...
|
||||||
|
holding:shuffleCards()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function wheelDOWN(x, y)
|
||||||
|
if not holding then
|
||||||
|
for i=#items,1,-1 do
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
items[i]:shuffleCards()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif holding:isInstanceOf(Card) then
|
||||||
|
for i=#items,1,-1 do
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
items[i]:placeCardsUnder(holding)
|
||||||
|
holding = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif holding:isInstanceOf(Deck) then
|
||||||
|
for i=#items,1,-1 do
|
||||||
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
|
items[i]:placeCardsUnder(holding:getCards())
|
||||||
|
holding = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if holding then --if we didn't just get rid of it...
|
||||||
|
holding:shuffleCards()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.wheelmoved(x, y)
|
||||||
|
if y > 0 then
|
||||||
|
wheelUP(love.mouse.getX(), love.mouse.getY())
|
||||||
|
elseif y < 0 then
|
||||||
|
wheelDOWN(love.mouse.getX(), love.mouse.getY())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button)
|
function love.mousepressed(x, y, button)
|
||||||
if button == "l" then
|
if button == LEFT_MOUSE then
|
||||||
if not holding then
|
if not holding then
|
||||||
for i=#items,1,-1 do
|
for i=#items,1,-1 do
|
||||||
if isOnItem(x, y, items[i]) then
|
if isOnItem(x, y, items[i]) then
|
||||||
@@ -172,63 +258,10 @@ function love.mousepressed(x, y, button)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif button == "wu" then --WU AND WD ARE ALMOST IDENTICAL, COLLAPSE THEM INTO ONE WHERE POSSIBLE
|
elseif button == "wu" then --WU AND WD ARE ALMOST IDENTICAL, COLLAPSE THEM INTO ONE WHERE POSSIBLE
|
||||||
if not holding then
|
wheelUP(x, y)
|
||||||
for i=#items,1,-1 do --ABSTRACT THIS FOR, I DO IT TOO MUCH ?
|
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
--items[i]:shuffleCards() -- now we pick it up instead!
|
|
||||||
holding = table.remove(items, i)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif holding:isInstanceOf(Card) then
|
|
||||||
for i=#items,1,-1 do
|
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
items[i]:placeCardsOn(holding)
|
|
||||||
holding = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif holding:isInstanceOf(Deck) then
|
|
||||||
for i=#items,1,-1 do
|
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
items[i]:placeCardsOn(holding:getCards())
|
|
||||||
holding = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if holding then --if we didn't just get rid of it...
|
|
||||||
holding:shuffleCards()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif button == "wd" then
|
elseif button == "wd" then
|
||||||
if not holding then
|
wheelDOWN(x, y)
|
||||||
for i=#items,1,-1 do
|
elseif button == RIGHT_MOUSE then
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
items[i]:shuffleCards()
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif holding:isInstanceOf(Card) then
|
|
||||||
for i=#items,1,-1 do
|
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
items[i]:placeCardsUnder(holding)
|
|
||||||
holding = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif holding:isInstanceOf(Deck) then
|
|
||||||
for i=#items,1,-1 do
|
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
|
||||||
items[i]:placeCardsUnder(holding:getCards())
|
|
||||||
holding = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if holding then --if we didn't just get rid of it...
|
|
||||||
holding:shuffleCards()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif button == "r" then
|
|
||||||
if holding then
|
if holding then
|
||||||
holding:flip()
|
holding:flip()
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user