mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-11 21:22:22 +02:00
cards work well
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
extends Control
|
||||
|
||||
var usedCards = [cards.BARREL,cards.BEAR,cards.EMPTY,cards.EMPTY,cards.EMPTY]
|
||||
var cardPositions = [Vector2(0,150), Vector2(50,150), Vector2(100,150), Vector2(150,150), Vector2(200, 150)]
|
||||
var cardPositions = [Vector2(10,223), Vector2(60,223), Vector2(110,223), Vector2(160,223), Vector2(210, 223)]
|
||||
|
||||
enum cards {
|
||||
BANANA,
|
||||
@@ -23,9 +23,9 @@ func update_cards():
|
||||
var index = 0
|
||||
while index < 5 and usedCards[index] != cards.EMPTY:
|
||||
index += 1
|
||||
|
||||
for card in range(index + 1):
|
||||
var newchild = []
|
||||
for card in range(index):
|
||||
|
||||
match usedCards[card]:
|
||||
cards.BANANA:
|
||||
newchild.append(load("res://Objects/Banana/BananaCard.tscn").instance())
|
||||
@@ -43,13 +43,13 @@ func update_cards():
|
||||
newchild.append(load("res://Objects/Traps/Spike/SpikeCard.tscn").instance())
|
||||
#cards.SLIME:
|
||||
#newchild=(load("res://Objects/Slime/SlimeCard.tscn").instance())
|
||||
for i in range(index + 1):
|
||||
$CardsDisplay.add_child(shownCards[i])
|
||||
shownCards[0].set_begin (cardPositions[0])
|
||||
shownCards[1].set_begin (cardPositions[1])
|
||||
shownCards[2].set_begin (cardPositions[2])
|
||||
for i in range(index):
|
||||
$CardsDisplay.add_child(newchild[i])
|
||||
|
||||
for i in range(index + 1):
|
||||
shownCards[i].canNotPlace = true
|
||||
shownCards[i].margin_bottom = shownCards[i].margin_top+32
|
||||
shownCards[i].margin_right = shownCards[i].margin_left+32
|
||||
for i in range(index):
|
||||
newchild[i].set_begin(cardPositions[i])
|
||||
|
||||
|
||||
for i in range(index):
|
||||
newchild[i].margin_bottom = newchild[i].margin_top+32
|
||||
newchild[i].margin_right = newchild[i].margin_left+32
|
||||
|
||||
@@ -14,6 +14,7 @@ func _ready():
|
||||
|
||||
|
||||
func starting():
|
||||
shownCards = []
|
||||
if (showCards):
|
||||
randcards[0] = randi() % DrNDrPre.cards.EMPTY
|
||||
while(DrNDr.usedCards[0]==randcards[0] or
|
||||
@@ -39,7 +40,7 @@ func starting():
|
||||
DrNDr.usedCards[4]==randcards[2]):
|
||||
randcards[2] = randi() % DrNDrPre.cards.EMPTY
|
||||
|
||||
print(randcards)
|
||||
|
||||
for i in range(3):
|
||||
match randcards[i]:
|
||||
DrNDrPre.cards.BANANA:
|
||||
@@ -76,10 +77,10 @@ func starting():
|
||||
func _input(event):
|
||||
if((event is InputEventMouseButton) && allowChoosCards):
|
||||
for card in range(3):
|
||||
if(event.global_position[0] >= cardPositions[card][0] &&
|
||||
event.global_position[0] >= cardPositions[card][0]+32 &&
|
||||
event.global_position[1] >= cardPositions[card][1] &&
|
||||
event.global_position[1] >= cardPositions[card][1]+32):
|
||||
if(event.position[0] >= cardPositions[card][0] &&
|
||||
event.position[0] <= cardPositions[card][0]+32 &&
|
||||
event.position[1] >= cardPositions[card][1] &&
|
||||
event.position[1] <= cardPositions[card][1]+32):
|
||||
for i in range(5):
|
||||
if (DrNDr.usedCards[i] == DrNDrPre.cards.EMPTY):
|
||||
DrNDr.usedCards[i] = randcards[card]
|
||||
@@ -90,6 +91,7 @@ func _input(event):
|
||||
showCards = false
|
||||
for j in range(3):
|
||||
shownCards[j].queue_free()
|
||||
DrNDr.update_cards()
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user