Skip to content

Commit d849da8

Browse files
committed
Draw Pile; Dynamic Cards
1 parent 8309ce9 commit d849da8

File tree

13 files changed

+374
-125
lines changed

13 files changed

+374
-125
lines changed

CollisionShape2D.gd

Lines changed: 0 additions & 32 deletions
This file was deleted.

Discard.gd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ func _ready():
1010
# Initialization here
1111
pass
1212

13-
func _physics_process(delta):
14-
overlapping_bodies = get_overlapping_bodies()
15-
if overlapping_bodies.size() > 0:
16-
print("found object")
17-
var ovlb = overlapping_bodies[0]
18-
if ovlb.grabbed == false:
19-
ovlb.queue_free()
13+
#func _physics_process(delta):
14+
# overlapping_bodies = get_overlapping_bodies()
15+
# if overlapping_bodies.size() > 0:
16+
# print("found object")
17+
# var ovlb = overlapping_bodies[0]
18+
# if ovlb.grabbed == false:
19+
# ovlb.queue_free()
2020

2121
#func _process(delta):
2222
# # Called every frame. Delta is time since last frame.

DiscardCollision.gd

Lines changed: 0 additions & 15 deletions
This file was deleted.

card.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ var destination = Vector2()
99
var move_to_destination = false
1010
var speed = 10
1111
var active = true
12+
var card_name = 'blank'
13+
var cost = 1
14+
1215

1316

1417
func _ready():
18+
randomize()
1519
# set_fixed_process(true)
1620
connect("mouse_entered", self, "_mouse_over", [true])
1721
connect("mouse_exited", self, "_mouse_over", [false])
1822
# print(get_viewport().get_size())
23+
$CardName.text = card_name
24+
$Cost.text = str(cost)
25+
$Damage.text = str(damage)
26+
var redness = rand_range(0,1)
27+
var blueness = rand_range(0,1)
28+
var greenness = rand_range(0,1)
29+
$Background.color = Color(redness, blueness, greenness, 1)
1930

2031

2132
func _mouse_over(over):

card.tscn

Lines changed: 121 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,165 @@
11
[gd_scene load_steps=4 format=2]
22

33
[ext_resource path="res://card.gd" type="Script" id=1]
4-
[ext_resource path="res://CollisionShape2D.gd" type="Script" id=2]
54

65
[sub_resource type="RectangleShape2D" id=1]
76

87
custom_solver_bias = 0.0
9-
extents = Vector2( 26.0067, 26.0836 )
8+
extents = Vector2( 40.0082, 54.8255 )
109

11-
[node name="Card" type="KinematicBody2D"]
10+
[sub_resource type="StyleBoxFlat" id=2]
1211

13-
self_modulate = Color( 0.613281, 0.220913, 0.220913, 1 )
12+
content_margin_left = -1.0
13+
content_margin_right = -1.0
14+
content_margin_top = -1.0
15+
content_margin_bottom = -1.0
16+
bg_color = Color( 0.6, 0.6, 0.6, 1 )
17+
draw_center = true
18+
border_width_left = 0
19+
border_width_top = 0
20+
border_width_right = 0
21+
border_width_bottom = 0
22+
border_color = Color( 0.8, 0.8, 0.8, 1 )
23+
border_blend = false
24+
corner_radius_top_left = 0
25+
corner_radius_top_right = 0
26+
corner_radius_bottom_right = 0
27+
corner_radius_bottom_left = 0
28+
corner_detail = 8
29+
expand_margin_left = 0.0
30+
expand_margin_right = 0.0
31+
expand_margin_top = 0.0
32+
expand_margin_bottom = 0.0
33+
shadow_color = Color( 0, 0, 0, 0.6 )
34+
shadow_size = 0
35+
anti_aliasing = true
36+
anti_aliasing_size = 1
37+
38+
[node name="Card" type="KinematicBody2D" index="0"]
39+
40+
self_modulate = Color( 1, 1, 1, 0 )
1441
position = Vector2( -3.07553, -0.504135 )
1542
z_index = 1
1643
input_pickable = true
1744
collision_layer = 1
1845
collision_mask = 1
1946
collision/safe_margin = 0.08
2047
script = ExtResource( 1 )
21-
_sections_unfolded = [ "Collision", "Pickable", "Transform", "Visibility", "Z Index" ]
22-
__meta__ = {
23-
"_edit_group_": true
24-
}
48+
_sections_unfolded = [ "Collision", "Pickable", "Transform", "Visibility", "Z Index", "collision" ]
2549

26-
[node name="ColorRect" type="ColorRect" parent="." index="0"]
50+
[node name="Background" type="ColorRect" parent="." index="0"]
2751

2852
anchor_left = 0.0
2953
anchor_top = 0.0
3054
anchor_right = 0.0
3155
anchor_bottom = 0.0
32-
margin_left = -24.0
33-
margin_top = -26.0
34-
margin_right = 35.0
35-
margin_bottom = 27.0
56+
margin_left = -36.0
57+
margin_top = -57.0
58+
margin_right = 43.0
59+
margin_bottom = 52.0
3660
rect_pivot_offset = Vector2( 0, 0 )
3761
mouse_filter = 2
3862
mouse_default_cursor_shape = 0
3963
size_flags_horizontal = 1
4064
size_flags_vertical = 1
41-
color = Color( 1, 1, 1, 1 )
65+
color = Color( 0, 0, 0, 1 )
4266
_sections_unfolded = [ "Anchor", "Focus", "Mouse", "Rect", "Visibility" ]
4367

4468
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
4569

46-
modulate = Color( 0.914062, 0.0147429, 0.0147429, 1 )
47-
position = Vector2( 3.26602, 0.445938 )
70+
visible = false
71+
position = Vector2( 3.05154, -2.12785 )
4872
shape = SubResource( 1 )
49-
script = ExtResource( 2 )
5073
_sections_unfolded = [ "Material", "Transform", "Visibility" ]
5174

52-
[node name="Control" type="Control" parent="." index="2"]
75+
[node name="CardName" type="Label" parent="." index="2"]
5376

5477
anchor_left = 0.0
5578
anchor_top = 0.0
5679
anchor_right = 0.0
5780
anchor_bottom = 0.0
58-
margin_right = 40.0
59-
margin_bottom = 40.0
81+
margin_left = -17.0
82+
margin_top = -27.0
83+
margin_right = 27.0
84+
margin_bottom = -13.0
6085
rect_pivot_offset = Vector2( 0, 0 )
61-
mouse_filter = 0
86+
mouse_filter = 2
6287
mouse_default_cursor_shape = 0
6388
size_flags_horizontal = 1
64-
size_flags_vertical = 1
89+
size_flags_vertical = 4
90+
custom_colors/font_color = Color( 1, 1, 1, 1 )
91+
text = "default"
92+
percent_visible = 1.0
93+
lines_skipped = 0
94+
max_lines_visible = -1
95+
_sections_unfolded = [ "Visibility", "custom_colors" ]
96+
97+
[node name="DamageLabel" type="Label" parent="." index="3"]
98+
99+
anchor_left = 0.0
100+
anchor_top = 0.0
101+
anchor_right = 0.0
102+
anchor_bottom = 0.0
103+
margin_left = -24.0
104+
margin_right = 36.0
105+
margin_bottom = 20.0
106+
rect_pivot_offset = Vector2( 0, 0 )
107+
mouse_filter = 2
108+
mouse_default_cursor_shape = 0
109+
size_flags_horizontal = 1
110+
size_flags_vertical = 4
111+
text = "damage: "
112+
percent_visible = 1.0
113+
lines_skipped = 0
114+
max_lines_visible = -1
115+
116+
[node name="Cost" type="Label" parent="." index="4"]
117+
118+
self_modulate = Color( 0, 1, 0.0625, 1 )
119+
anchor_left = 0.0
120+
anchor_top = 0.0
121+
anchor_right = 0.0
122+
anchor_bottom = 0.0
123+
margin_left = -37.0
124+
margin_top = -57.0
125+
margin_right = -9.0
126+
margin_bottom = -30.0
127+
rect_pivot_offset = Vector2( 0, 0 )
128+
mouse_filter = 2
129+
mouse_default_cursor_shape = 0
130+
size_flags_horizontal = 1
131+
size_flags_vertical = 4
132+
custom_styles/normal = SubResource( 2 )
133+
text = "0"
134+
align = 1
135+
valign = 1
136+
percent_visible = 1.0
137+
lines_skipped = 0
138+
max_lines_visible = -1
139+
_sections_unfolded = [ "Visibility", "custom_styles" ]
140+
141+
[node name="Damage" type="Label" parent="." index="5"]
142+
143+
self_modulate = Color( 0, 0, 0, 1 )
144+
anchor_left = 0.0
145+
anchor_top = 0.0
146+
anchor_right = 0.0
147+
anchor_bottom = 0.0
148+
margin_left = -16.0
149+
margin_top = 23.0
150+
margin_right = 24.0
151+
margin_bottom = 37.0
152+
rect_pivot_offset = Vector2( 0, 0 )
153+
mouse_filter = 2
154+
mouse_default_cursor_shape = 0
155+
size_flags_horizontal = 1
156+
size_flags_vertical = 4
157+
text = "1"
158+
align = 1
159+
valign = 1
160+
percent_visible = 1.0
161+
lines_skipped = 0
162+
max_lines_visible = -1
163+
_sections_unfolded = [ "Size Flags", "Visibility" ]
65164

66165

deck.gd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
extends Node
2+
3+
var deck_data
4+
var hand
5+
6+
func _ready():
7+
# Called every time the node is added to the scene.
8+
# Initialization here
9+
hand = get_parent().get_node('Hand')
10+
11+
12+
func make_cards():
13+
deck_data = get_deck_data()
14+
for card_data in deck_data:
15+
16+
var card_scene = load("res://card.tscn")
17+
var card = card_scene.instance()
18+
# card.set_name("card")
19+
20+
# card.visible = false
21+
# card.input_pickable = false
22+
card.card_name = card_data['name']
23+
card.damage = card_data['damage']
24+
card.cost = card_data['cost']
25+
hand.add_child(card)
26+
hand.active_hand.append(card)
27+
hand.set_card_destinations()
28+
hand.organize()
29+
30+
31+
func get_deck_data():
32+
return [
33+
{
34+
"name" : "attack",
35+
"cost" : 2,
36+
"damage" : 10
37+
},
38+
{
39+
"name" : "attack",
40+
"cost" : 1,
41+
"damage" : 5
42+
},
43+
{
44+
"name" : "attack",
45+
"cost" : 1,
46+
"damage" : 3
47+
},
48+
{
49+
"name" : "attack",
50+
"cost" : 3,
51+
"damage" : 15
52+
},
53+
{
54+
"name" : "attack",
55+
"cost" : 2,
56+
"damage" : 11
57+
}
58+
]
59+

deck.tscn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://deck.gd" type="Script" id=1]
4+
5+
[node name="Deck" type="Node"]
6+
7+
script = ExtResource( 1 )
8+
9+

draw_pile.gd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
extends Area2D
2+
3+
var is_hovering = false
4+
5+
func _ready():
6+
connect("mouse_entered", self, "_mouse_over", [true])
7+
connect("mouse_exited", self, "_mouse_over", [false])
8+
9+
func _mouse_over(over):
10+
if over == true:
11+
is_hovering = true
12+
else:
13+
is_hovering = false
14+
15+
func _input(event):
16+
if event is InputEventMouseButton && event.pressed && is_hovering == true:
17+
print('draw')
18+
# var deck_data = get_parent().get_node('Deck').get_deck_data()
19+
get_parent().get_node('Deck').make_cards()

enemy.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ func _ready():
1111
# Called every time the node is added to the scene.
1212
# Initialization here
1313
_update_health()
14-
$EnemyShape/HP/HealthBar.max_value = starting_health
15-
$EnemyShape/HP/HealthBar.min_value = 0
14+
$EnemyShape/HealthBar.max_value = starting_health
15+
$EnemyShape/HealthBar.min_value = 0
1616

1717
func _update_health():
1818
$EnemyShape/HP.text = "hp: " + str(health)
19-
$EnemyShape/HP/HealthBar.value = health
19+
$EnemyShape/HealthBar.value = health
2020

2121
#func _process(delta):
2222
# # Called every frame. Delta is time since last frame.

0 commit comments

Comments
 (0)