I DON'T KNOW HOW THIS IS BROKEN BUT IT IS

This commit is contained in:
Paul Liverman
2015-12-05 23:53:38 -08:00
parent 345bd58b3b
commit 072322f1d7
4 changed files with 26 additions and 3 deletions

View File

@@ -61,6 +61,10 @@ function Card:moveTo(x, y, r)
self.r = r or self.r
end
function Card:getPosition()
return self.x, self.y, self.r
end
function Card:flip()
if self.face == "down" then
self.face = "up"

View File

@@ -12,6 +12,7 @@ Deck.static.height = 89*2
function Deck:initialize(cards)
self.cards = cards or {}
print(self.cards) --NOTE DEBUG
self.x = 0
self.y = 0
self.r = 0
@@ -45,6 +46,10 @@ function Deck:moveTo(x, y, r)
self.r = r or self.r
end
function Deck:getPosition()
return self.x, self.y, self.r
end
function Deck:flip()
if self.face == "down" then
self.face = "up"
@@ -74,8 +79,10 @@ function Deck:drawCards(count)
if count and (count > 1) then
local new = {}
while (count > 1) and (#self.cards > 1) do
insert(new, remove(self.cards))
while (count > 1) and (#self.cards > 0) do
local card = remove(self.cards)
card.face = self.face
insert(new, card)
end
self:update()
@@ -83,6 +90,7 @@ function Deck:drawCards(count)
return Deck(new)
else
local card = remove(self.cards)
card.face = self.face
self:update()

View File

@@ -1,3 +1,9 @@
function love.conf(t)
t.identity = "52cards"
t.console = true
t.window.title = "52 Cards"
t.window.width = 960
t.window.height = 540
t.window.resizeable = true
end

View File

@@ -5,8 +5,9 @@ local insert = table.insert
local lg = love.graphics
local lm = love.mouse
local items = {}
local inspect = require "lib.inspect"
local items = {}
local function makeDeck(jokers)
local cards = {}
@@ -120,6 +121,7 @@ function love.mousepressed(x, y, button)
holding = table.remove(items, i)
else
holding = items[i]:drawCards(1)
end
break
end
end
@@ -154,6 +156,9 @@ function love.mousepressed(x, y, button)
elseif items[item]:isInstanceOf(Card) then
local card = table.remove(items, item)
local deck = Deck({card, holding})
--deck:moveTo(card.x, card.y)
deck:moveTo(card:getPosition())
print(inspect(deck)) --NOTE DBEUG
insert(items, deck)
holding = false
elseif items[item]:isInstanceOf(Deck) then