diff --git a/Assets/Fonts/Bangers-Regular.ttf b/Assets/Fonts/Bangers-Regular.ttf new file mode 100644 index 0000000..df3fa73 Binary files /dev/null and b/Assets/Fonts/Bangers-Regular.ttf differ diff --git a/Assets/Fonts/Bangers-Regular.ttf.import b/Assets/Fonts/Bangers-Regular.ttf.import new file mode 100644 index 0000000..2b23a09 --- /dev/null +++ b/Assets/Fonts/Bangers-Regular.ttf.import @@ -0,0 +1,36 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://brm4s4a2b4ch2" +path="res://.godot/imported/Bangers-Regular.ttf-bff41b4a7246f67a7bcd99fff0c3874f.fontdata" + +[deps] + +source_file="res://Assets/Fonts/Bangers-Regular.ttf" +dest_files=["res://.godot/imported/Bangers-Regular.ttf-bff41b4a7246f67a7bcd99fff0c3874f.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +modulate_color_glyphs=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/Assets/Fonts/JosefinSans-VariableFont_wght.ttf b/Assets/Fonts/JosefinSans-VariableFont_wght.ttf new file mode 100644 index 0000000..5ddd9b0 Binary files /dev/null and b/Assets/Fonts/JosefinSans-VariableFont_wght.ttf differ diff --git a/Assets/Fonts/JosefinSans-VariableFont_wght.ttf.import b/Assets/Fonts/JosefinSans-VariableFont_wght.ttf.import new file mode 100644 index 0000000..08a5a58 --- /dev/null +++ b/Assets/Fonts/JosefinSans-VariableFont_wght.ttf.import @@ -0,0 +1,36 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://d4ma7vldbr7ae" +path="res://.godot/imported/JosefinSans-VariableFont_wght.ttf-605f3002d601ca8879327f2c16eafd00.fontdata" + +[deps] + +source_file="res://Assets/Fonts/JosefinSans-VariableFont_wght.ttf" +dest_files=["res://.godot/imported/JosefinSans-VariableFont_wght.ttf-605f3002d601ca8879327f2c16eafd00.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +modulate_color_glyphs=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/Assets/Fonts/Modak-Regular.ttf b/Assets/Fonts/Modak-Regular.ttf new file mode 100644 index 0000000..c9203a7 Binary files /dev/null and b/Assets/Fonts/Modak-Regular.ttf differ diff --git a/Assets/Fonts/Modak-Regular.ttf.import b/Assets/Fonts/Modak-Regular.ttf.import new file mode 100644 index 0000000..5cbd5b7 --- /dev/null +++ b/Assets/Fonts/Modak-Regular.ttf.import @@ -0,0 +1,36 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://b74c848bvnbeh" +path="res://.godot/imported/Modak-Regular.ttf-692cda482e13613dfc1b1fd4c16bbc50.fontdata" + +[deps] + +source_file="res://Assets/Fonts/Modak-Regular.ttf" +dest_files=["res://.godot/imported/Modak-Regular.ttf-692cda482e13613dfc1b1fd4c16bbc50.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +modulate_color_glyphs=false +hinting=1 +subpixel_positioning=4 +keep_rounding_remainders=true +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/Globals/Formulas.gd b/Globals/Formulas.gd new file mode 100644 index 0000000..74f7ef3 --- /dev/null +++ b/Globals/Formulas.gd @@ -0,0 +1,4 @@ +extends Node + +func calculate_damage(damage, armor) -> float: + return clamp(damage - armor, 1, 9999) diff --git a/Globals/Formulas.gd.uid b/Globals/Formulas.gd.uid new file mode 100644 index 0000000..66777cd --- /dev/null +++ b/Globals/Formulas.gd.uid @@ -0,0 +1 @@ +uid://cl00mrhbjhhb4 diff --git a/Objects/Battler.tscn b/Objects/Battler.tscn index 0e417c8..6425630 100644 --- a/Objects/Battler.tscn +++ b/Objects/Battler.tscn @@ -6,7 +6,6 @@ script = ExtResource("1_dv2oe") [node name="Sprite2D" type="Sprite2D" parent="." unique_id=763052965] -scale = Vector2(4, 4) [node name="Attack" type="Timer" parent="." unique_id=421541847] diff --git a/Objects/battler.gd b/Objects/battler.gd index 28a9e66..1b8032e 100644 --- a/Objects/battler.gd +++ b/Objects/battler.gd @@ -1,11 +1,13 @@ extends Node2D class_name Battler +@export var sprite_texture : Texture @export var battler_stats : BattlerStats @export_enum("Plant", "Pollution") var side = 0 @onready var attack_cooldown : Timer = $Attack +@onready var floating_text_packed : PackedScene = load("res://Objects/floating_text.tscn") var life : int = 1 : set(value): @@ -25,11 +27,13 @@ var _attack_ready : bool = false func _ready() -> void: + $Sprite2D.texture = sprite_texture set_side() set_battler_stats() _attack_ready = true + func _process(_delta: float) -> void: if target: if _attack_ready: @@ -70,13 +74,22 @@ func attack() -> void: attack_cooldown.start() -func get_hurt(hurt : int) -> void: - life -= clamp(hurt - armor, 1, 9999) +func get_hurt(damage : int) -> void: + life -= Formulas.calculate_damage(damage, armor) + instantiate_floating_text(damage) func death() -> void: queue_free() +func instantiate_floating_text(text_value) -> void: + var floating_text : Control = floating_text_packed.instantiate() + add_child(floating_text) + floating_text.text = str(text_value) + floating_text.position.y -= $Sprite2D.texture.get_height()/2.0 * $Sprite2D.scale.y + 30.0 + floating_text.position.x -= 10.0 + + func _on_attack_timeout() -> void: _attack_ready = true diff --git a/Objects/floating_text.gd b/Objects/floating_text.gd new file mode 100644 index 0000000..def6932 --- /dev/null +++ b/Objects/floating_text.gd @@ -0,0 +1,16 @@ +extends Control +var text : String = "-1" : + set(value): + text = str(value) + $Label.text = text + print("Text :", $Label.text) + +func _ready() -> void: + _animate() + +func _animate() -> void: + $Label/AnimationPlayer.play("in") + await $Label/AnimationPlayer.animation_finished + $Label/AnimationPlayer.play("out") + await $Label/AnimationPlayer.animation_finished + queue_free() diff --git a/Objects/floating_text.gd.uid b/Objects/floating_text.gd.uid new file mode 100644 index 0000000..0812263 --- /dev/null +++ b/Objects/floating_text.gd.uid @@ -0,0 +1 @@ +uid://dx5br1462ckj5 diff --git a/Objects/floating_text.tscn b/Objects/floating_text.tscn new file mode 100644 index 0000000..bc20506 --- /dev/null +++ b/Objects/floating_text.tscn @@ -0,0 +1,129 @@ +[gd_scene format=3 uid="uid://br3wpf7ntri03"] + +[ext_resource type="FontFile" uid="uid://b74c848bvnbeh" path="res://Assets/Fonts/Modak-Regular.ttf" id="1_uicqr"] +[ext_resource type="Script" uid="uid://dx5br1462ckj5" path="res://Objects/floating_text.gd" id="2_2dget"] + +[sub_resource type="LabelSettings" id="LabelSettings_2dget"] +font = ExtResource("1_uicqr") +font_size = 20 + +[sub_resource type="Animation" id="Animation_2dget"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(1, 1)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} + +[sub_resource type="Animation" id="Animation_3h7ba"] +resource_name = "in" +length = 0.3 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1.2, 1.2), Vector2(1, 1)] +} + +[sub_resource type="Animation" id="Animation_qoh3s"] +resource_name = "out" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(3.1383367, 0.124999955), +"update": 0, +"values": [Vector2(0, 0), Vector2(0, -50)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(0.5, 0.5)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.3, 0.5), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_3h7ba"] +_data = { +&"RESET": SubResource("Animation_2dget"), +&"in": SubResource("Animation_3h7ba"), +&"out": SubResource("Animation_qoh3s") +} + +[node name="FloatingText" type="Control" unique_id=1495993459] +layout_mode = 3 +anchors_preset = 0 +pivot_offset_ratio = Vector2(0.5, 0.5) +script = ExtResource("2_2dget") + +[node name="Label" type="Label" parent="." unique_id=222924785] +layout_mode = 0 +offset_right = 31.0 +offset_bottom = 31.0 +pivot_offset_ratio = Vector2(0.5, 0.5) +text = "100" +label_settings = SubResource("LabelSettings_2dget") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Label" unique_id=256124678] +libraries/ = SubResource("AnimationLibrary_3h7ba") diff --git a/Resources/plant_stats.tres b/Resources/plant_stats.tres new file mode 100644 index 0000000..a917dfc --- /dev/null +++ b/Resources/plant_stats.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="BattlerStats" format=3 uid="uid://te1aq7i3mahk"] + +[ext_resource type="Script" uid="uid://dr6js1vewp6rg" path="res://Scripts/battler_stats.gd" id="1_ou15e"] + +[resource] +script = ExtResource("1_ou15e") +base_life = 10 +base_speed = 0.5 +metadata/_custom_type_script = "uid://dr6js1vewp6rg" diff --git a/Resources/trash_stats.tres b/Resources/trash_stats.tres new file mode 100644 index 0000000..e45fbd5 --- /dev/null +++ b/Resources/trash_stats.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="BattlerStats" format=3 uid="uid://7rv28rbuxt2p"] + +[ext_resource type="Script" uid="uid://dr6js1vewp6rg" path="res://Scripts/battler_stats.gd" id="1_71kpj"] + +[resource] +script = ExtResource("1_71kpj") +base_speed = 0.3 +metadata/_custom_type_script = "uid://dr6js1vewp6rg" diff --git a/game.tscn b/game.tscn index 262cc2b..62ec6bd 100644 --- a/game.tscn +++ b/game.tscn @@ -1,46 +1,28 @@ [gd_scene format=3 uid="uid://vkh2dbrct7vh"] [ext_resource type="PackedScene" uid="uid://cndfpjgyfttdr" path="res://Objects/Battler.tscn" id="1_feb5d"] -[ext_resource type="Texture2D" uid="uid://cs0k1ofdlayvr" path="res://Assets/Flowers/Flower 2/Flower 2 - TEAL.png" id="3_7jktm"] -[ext_resource type="Script" uid="uid://dr6js1vewp6rg" path="res://Scripts/battler_stats.gd" id="3_fc0e3"] +[ext_resource type="Texture2D" uid="uid://drwi73l0d04vj" path="res://Assets/Flowers/Flower Pot 5/Flower Pot 5 - LILAC.png" id="2_ryrav"] +[ext_resource type="Resource" uid="uid://te1aq7i3mahk" path="res://Resources/plant_stats.tres" id="3_7jktm"] [ext_resource type="Texture2D" uid="uid://cdhk55d5d05di" path="res://Assets/Trashes/recycling 2.png" id="3_feb5d"] -[ext_resource type="Texture2D" uid="uid://bne02il4bsoq3" path="res://Assets/Flowers/Bush 1/Bush 1 - GREEN 2.png" id="5_7jktm"] - -[sub_resource type="Resource" id="Resource_7jktm"] -script = ExtResource("3_fc0e3") -base_life = 10 -base_speed = 2.0 -metadata/_custom_type_script = "uid://dr6js1vewp6rg" - -[sub_resource type="Resource" id="Resource_fc0e3"] -script = ExtResource("3_fc0e3") -metadata/_custom_type_script = "uid://dr6js1vewp6rg" +[ext_resource type="Resource" uid="uid://7rv28rbuxt2p" path="res://Resources/trash_stats.tres" id="5_ryrav"] [node name="Game" type="Node2D" unique_id=2069582450] [node name="Garden" type="Node2D" parent="." unique_id=491593255] [node name="Plant" parent="Garden" unique_id=1265041863 instance=ExtResource("1_feb5d")] -position = Vector2(159, 472) -battler_stats = SubResource("Resource_7jktm") - -[node name="Sprite2D2" type="Sprite2D" parent="Garden/Plant" unique_id=680807617] -position = Vector2(20, 3) -scale = Vector2(2, 2) -texture = ExtResource("3_7jktm") +position = Vector2(189, 183) +sprite_texture = ExtResource("2_ryrav") +battler_stats = ExtResource("3_7jktm") [node name="Dump" type="Node2D" parent="." unique_id=608611995] [node name="Trash" parent="Dump" unique_id=1865311551 instance=ExtResource("1_feb5d")] -position = Vector2(902, 495) -battler_stats = SubResource("Resource_fc0e3") +position = Vector2(330, 181) +sprite_texture = ExtResource("3_feb5d") +battler_stats = ExtResource("5_ryrav") side = 1 -[node name="Sprite2D2" type="Sprite2D" parent="Dump/Trash" unique_id=955529602] -scale = Vector2(4, 4) -texture = ExtResource("3_feb5d") - -[node name="Sprite2D" type="Sprite2D" parent="." unique_id=899833631] -position = Vector2(556.00006, 173.00005) -scale = Vector2(10, 10) -texture = ExtResource("5_7jktm") +[node name="Camera2D" type="Camera2D" parent="." unique_id=1468251961] +position = Vector2(259, 155) +zoom = Vector2(2, 2) diff --git a/project.godot b/project.godot index dccdbb3..bcc4a1a 100644 --- a/project.godot +++ b/project.godot @@ -14,3 +14,12 @@ config/name="PVP" run/main_scene="uid://vkh2dbrct7vh" config/features=PackedStringArray("4.6") config/icon="res://icon.svg" + +[autoload] + +Formulas="*uid://cl00mrhbjhhb4" + +[display] + +window/size/viewport_width=600 +window/size/viewport_height=300