-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove card.lua
65 lines (58 loc) · 2.48 KB
/
Remove card.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
RemoveCard = Class{__includes = BaseState}
function RemoveCard:init()
self.image = love.graphics.newImage('Buttons/Remove.png')
self.width = self.image:getWidth()
self.height = self.image:getHeight()
self.x = VIRTUALWIDTH / 2 - self.width / 2
self.y = 385
end
function RemoveCard:swap()
P1strength = P1strength - characterStrength({mouseTrapped.name,mouseTrapped.level,mouseTrapped.evolution}) --Reduce deck strength by card removed, before card is set as blank
gStateMachine.current:createDeckeditorBackground()
--Edit card removed to be a blank card
P1deck[mouseTrapped.number]:deleteEvolutionSprites()
P1deck[mouseTrapped.number].name, P1deck[mouseTrapped.number].level, P1deck[mouseTrapped.number].evolution, P1deck[mouseTrapped.number].imagePath, P1deck[mouseTrapped.number].deleting = 'Blank', nil, nil, 'Graphics/Blank Card', nil
if not sandbox then --Not necessary in sandbox as inventory does not change
P1cardsEdit(-1,{mouseTrapped.name,mouseTrapped.level,mouseTrapped.evolution})
gStateMachine.current:loadCards()
end
P1deckEdit(mouseTrapped.number,nil)
collectgarbage()
if love.mouse.isVisible() == false then
if mouseTrapped.number < 6 then
repositionMouse(gui[mouseTrapped.number+16])
elseif mouseTrapped.number < 12 then
repositionMouse(gui[mouseTrapped.number+4])
else
repositionMouse(gui[mouseTrapped.number-8])
end
end
mouseTrapped = false
mouseLocked = false
mouseTrapped2 = false
end
function RemoveCard:update()
if mouseTrapped and mouseTrapped.inDeck and ((math.abs(mouseLastX - mousePressedX) > 10 or math.abs(mouseLastY - mousePressedY) > 10) or not love.mouse.isVisible())then
self.visible = true
if mouseX > self.x and mouseX < self.x + self.width and mouseY > self.y and mouseY < self.y + self.height then
self.scaling = 1.04
mouseTrapped.deleting = true
if not love.mouse.isVisible() then
mouseTouching = self
end
if love.mouse.buttonsReleased[1] then
self:swap()
end
else
self.scaling = 1
mouseTrapped.deleting = false
end
else
self.visible = false
end
end
function RemoveCard:render()
if self.visible then
love.graphics.draw(self.image,self.x,self.y,0,self.scaling,self.scaling,(-1+self.scaling)/2*self.width,(-1+self.scaling)/2*self.height)
end
end