diff --git a/objects/Animal.tscn b/objects/Animal.tscn index 3b7cfe8..1ce55d5 100644 --- a/objects/Animal.tscn +++ b/objects/Animal.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://byv2a5d0n1538"] +[gd_scene load_steps=13 format=3 uid="uid://cj457q2fx5mim"] [ext_resource type="Script" path="res://scripts/animal.gd" id="1_bjim0"] [ext_resource type="Texture2D" uid="uid://cxbv1inffa2bq" path="res://assets/plants/abre1.png" id="2_n8edq"] @@ -7,6 +7,34 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_5dvar"] radius = 599.083 +[sub_resource type="Animation" id="Animation_qi2vx"] +resource_name = "Closed" +length = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Fées:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:modulate") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0.529067, 0.529067, 0.529067, 1)] +} + [sub_resource type="Animation" id="Animation_6wgo4"] resource_name = "Finished" tracks/0/type = "value" @@ -94,6 +122,83 @@ tracks/6/keys = { "values": [Vector2(0.7, 0.7), Vector2(0.6, 0.9), Vector2(0.7, 0.7)] } +[sub_resource type="Animation" id="Animation_qxluk"] +resource_name = "Open" +length = 4.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Fées/Fée:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1.36667, 3.03333), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(-24, -362), Vector2(80, -373), Vector2(11, -442)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Fées/Fée2:position") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 1.36667, 3.03333), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(126, -635), Vector2(190, -618), Vector2(145, -586)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Fées/Fée3:position") +tracks/2/interp = 2 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 1.36667, 3.03333), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(291, -461), Vector2(251, -548), Vector2(337, -500)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Fées/Fée4:position") +tracks/3/interp = 2 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 1.36667, 3.03333), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(392.121, -288.879), Vector2(473, -329), Vector2(377, -354)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Fées:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Sprite2D:modulate") +tracks/5/interp = 2 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} + [sub_resource type="Animation" id="Animation_had0j"] length = 0.001 tracks/0/type = "value" @@ -181,111 +286,6 @@ tracks/6/keys = { "values": [Vector2(0.7, 0.7)] } -[sub_resource type="Animation" id="Animation_qi2vx"] -resource_name = "Closed" -length = 0.1 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Fées:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Sprite2D:modulate") -tracks/1/interp = 2 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(0.529067, 0.529067, 0.529067, 1)] -} - -[sub_resource type="Animation" id="Animation_qxluk"] -resource_name = "Open" -length = 4.0 -loop_mode = 1 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Fées/Fée:position") -tracks/0/interp = 2 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 1.36667, 3.03333), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(-24, -362), Vector2(80, -373), Vector2(11, -442)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Fées/Fée2:position") -tracks/1/interp = 2 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 1.36667, 3.03333), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(126, -635), Vector2(190, -618), Vector2(145, -586)] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Fées/Fée3:position") -tracks/2/interp = 2 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 1.36667, 3.03333), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(291, -461), Vector2(251, -548), Vector2(337, -500)] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Fées/Fée4:position") -tracks/3/interp = 2 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 1.36667, 3.03333), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(392.121, -288.879), Vector2(473, -329), Vector2(377, -354)] -} -tracks/4/type = "value" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath("Fées:visible") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [true] -} -tracks/5/type = "value" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("Sprite2D:modulate") -tracks/5/interp = 2 -tracks/5/loop_wrap = true -tracks/5/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(1, 1, 1, 1)] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_0kfkq"] _data = { "Closed": SubResource("Animation_qi2vx"), @@ -309,6 +309,7 @@ font_size = 21 [node name="Animal" type="Node2D"] script = ExtResource("1_bjim0") +n_plant_needed = 1 [node name="Sprite2D" type="Sprite2D" parent="."] modulate = Color(0.529067, 0.529067, 0.529067, 1) diff --git a/objects/Robot.tscn b/objects/Robot.tscn index c0da660..8cb7e65 100644 --- a/objects/Robot.tscn +++ b/objects/Robot.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://bp3c63qgkmi6o"] [ext_resource type="Script" path="res://scripts/robot.gd" id="1_4eix8"] -[ext_resource type="SpriteFrames" uid="uid://8ewbadpftqoh" path="res://assets/sprites/robot/walk/Robot.tres" id="2_k06te"] +[ext_resource type="SpriteFrames" path="res://assets/sprites/robot/walk/Robot.tres" id="2_k06te"] [ext_resource type="PackedScene" uid="uid://dyuqq8v1tckrv" path="res://objects/Wanderer.tscn" id="2_mhqh4"] [ext_resource type="AudioStream" uid="uid://cb4ouq4awiyri" path="res://assets/sounds/Actions/Planter.mp3" id="51_f30v0"] [ext_resource type="AudioStream" uid="uid://c1jt77fyb2lx4" path="res://assets/sounds/Actions/Déplacement.mp3" id="52_xvi3g"] diff --git a/scenes/Map.tscn b/scenes/Map.tscn index 70e5aa1..40399da 100644 --- a/scenes/Map.tscn +++ b/scenes/Map.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://scripts/map.gd" id="1_3np0o"] [ext_resource type="PackedScene" uid="uid://6ferubyu2uy1" path="res://scenes/Scanners.tscn" id="1_6mlj0"] -[ext_resource type="PackedScene" uid="uid://byv2a5d0n1538" path="res://objects/Animal.tscn" id="4_pkphc"] +[ext_resource type="PackedScene" uid="uid://cj457q2fx5mim" path="res://objects/Animal.tscn" id="4_pkphc"] [ext_resource type="Texture2D" uid="uid://c84bc7d0f8gtn" path="res://assets/texture/sky.png" id="4_uy8vn"] [ext_resource type="Texture2D" uid="uid://bkwi6yurko7gm" path="res://assets/texture/sol_gamejam_fleurs.png" id="5_6sl35"] [ext_resource type="Shader" path="res://scripts/shaders/TextureSplit.gdshader" id="5_iqvbx"] @@ -74,15 +74,14 @@ polygon = PackedVector2Array(27, 788, 54, 1452, 1715, 1163, 1439, -501, -416, -3 y_sort_enabled = true [node name="Animal" parent="Animals" instance=ExtResource("4_pkphc")] -position = Vector2(1905, 566) +position = Vector2(1452, 579) [node name="Animal2" parent="Animals" instance=ExtResource("4_pkphc")] -position = Vector2(382, 2220) +position = Vector2(364, 1856) [node name="Animal3" parent="Animals" instance=ExtResource("4_pkphc")] -position = Vector2(1847, 2248) - -[node name="Animal4" parent="Animals" instance=ExtResource("4_pkphc")] -position = Vector2(536, 548) +position = Vector2(1991, 2235) [connection signal="liberated" from="Animals/Animal" to="." method="_on_animal_liberated"] +[connection signal="liberated" from="Animals/Animal2" to="." method="_on_animal_2_liberated"] +[connection signal="liberated" from="Animals/Animal3" to="." method="_on_animal_3_liberated"] diff --git a/scripts/animal.gd b/scripts/animal.gd index debc32f..42e2da2 100644 --- a/scripts/animal.gd +++ b/scripts/animal.gd @@ -13,12 +13,12 @@ func _ready(): func _on_area_2d_area_entered(area: Area2D) -> void: var plant = area.get_parent() - if plant is Plant and not liberated: - plant.grown.connect(tracked_plant_grew) - plant.died.connect() + if plant is Plant and not is_liberated: + plant.grown.connect(tracked_plant_grew) + plant.died.connect(tracked_plant_died) func tracked_plant_grew(): - if liberated: + if is_liberated: return current_plants += 1 if current_plants == n_plant_needed: @@ -26,7 +26,7 @@ func tracked_plant_grew(): update_count() func tracked_plant_died(): - if liberated: + if is_liberated: return current_plants -= 1 update_count() diff --git a/scripts/map.gd b/scripts/map.gd index fd4de67..ed4627c 100644 --- a/scripts/map.gd +++ b/scripts/map.gd @@ -6,7 +6,7 @@ const OUT_OF_BOUND_DIST = 2000 signal win_game -@export var n_animals_to_liberate := 4 +@export var n_animals_to_liberate := 3 func _ready(): var map_size = GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO @@ -39,3 +39,15 @@ func _on_animal_liberated() -> void: n_animals_to_liberate -= 1 if n_animals_to_liberate == 0: emit_signal("win_game") + + +func _on_animal_2_liberated() -> void: + n_animals_to_liberate -= 1 + if n_animals_to_liberate == 0: + emit_signal("win_game") + + +func _on_animal_3_liberated() -> void: + n_animals_to_liberate -= 1 + if n_animals_to_liberate == 0: + emit_signal("win_game") diff --git a/scripts/plant.gd b/scripts/plant.gd index df385c1..a95e8a0 100644 --- a/scripts/plant.gd +++ b/scripts/plant.gd @@ -14,7 +14,7 @@ signal died @onready var sprite_node: AnimatedSprite2D = $AnimatedSprite2D const NEED_CHECK_PERIOD := 0.5 -const SAPLING_LIFETIME_MULT := 2.0 # this multiplies the time to grow to tell the time it can stay as a sapling +const SAPLING_LIFETIME_MULT := 20.0 # this multiplies the time to grow to tell the time it can stay as a sapling const OFFSET_REPRODUCTION_PERCT_DIST := 0.1 var parameter: PlantType @@ -70,7 +70,7 @@ func _on_growing_timeout() -> void: func plant(new_position: Vector2): - if not GameTerrain.is_on_map(new_position): + if not GameTerrain.is_on_map_real(new_position): push_error("Planting out of the map") position = new_position state = PlantState.SAPLING @@ -148,7 +148,7 @@ func _on_reproduction_timeout() -> void: var max_dist := parameter.distance_prod + parameter.distance_prod * OFFSET_REPRODUCTION_PERCT_DIST var plant_pos = position + (Vector2.RIGHT * randf_range(min_dist, max_dist)).rotated(randf_range(0, PI)) - if not GameTerrain.is_on_map(plant_pos): + if not GameTerrain.is_on_map_real(plant_pos): return var space := get_world_2d().direct_space_state diff --git a/scripts/planter.gd b/scripts/planter.gd index dc1b3be..462c10d 100644 --- a/scripts/planter.gd +++ b/scripts/planter.gd @@ -48,7 +48,7 @@ func take_next_seed() -> PlantType: func _unhandled_input(_event: InputEvent) -> void: if Input.is_action_just_pressed("plant") : var mouse_pos = camera.get_global_mouse_position() - var click_on_map = GameTerrain.is_on_map(mouse_pos) + var click_on_map = GameTerrain.is_on_map_real(mouse_pos) if can_plant and click_on_map and robot.state == robot.MoveState.IDLE: var next_plant := plants[seed_queue.back()] diff --git a/scripts/terrain.gd b/scripts/terrain.gd index 2418a4f..b674f3d 100644 --- a/scripts/terrain.gd +++ b/scripts/terrain.gd @@ -27,8 +27,11 @@ func map_to_pixel( int(pos.y / MAP_RATIO) ) -func is_on_map(pos: Vector2) -> bool: +func is_on_map_real(pos: Vector2) -> bool: return pos.x >= 0 and pos.x < TERRAIN_SIZE.x * MAP_RATIO and pos.y >= 0 and pos.y < TERRAIN_SIZE.y * MAP_RATIO + +func is_on_map_image(pos: Vector2) -> bool: + return pos.x >= 0 and pos.x < TERRAIN_SIZE.x and pos.y >= 0 and pos.y < TERRAIN_SIZE.y func color_value_to_level( color_value : float @@ -84,7 +87,7 @@ func modify_pixel( stat: Stats, modification: int, ): - if not is_on_map(pixel_pos): + if not is_on_map_image(pixel_pos): return var actual_levels = color_to_levels(image.get_pixelv(pixel_pos)) var modification_levels = modification_to_levels(stat, modification) @@ -95,7 +98,7 @@ func set_pixel( pixel_pos: Vector2i, level: Vector3i, ): - if not is_on_map(pixel_pos): + if not is_on_map_image(pixel_pos): return image.set_pixelv(pixel_pos, levels_to_color(level)) @@ -109,7 +112,7 @@ func modify_zone( var pixel_radius = int(radius / MAP_RATIO) for x in range(pixel_center.x - pixel_radius, pixel_center.x + pixel_radius + 1) : for y in range(pixel_center.y - pixel_radius, pixel_center.y + pixel_radius + 1): - if not is_on_map(Vector2i(x, y)): + if not is_on_map_image(Vector2i(x, y)): continue if pow(x - pixel_center.x,2) + pow(y - pixel_center.y,2) <= pow(pixel_radius,2): modify_pixel( @@ -146,7 +149,7 @@ func get_stat( pos: Vector2, stat : Stats ) -> int: - if not is_on_map(pos): + if not is_on_map_real(pos): return 0 var pixel_pos = map_to_pixel(pos) var levels = color_to_levels(image.get_pixelv(pixel_pos))