Merge pull request 'feat/bigtrees' (#9) from feat/bigtrees into master
Reviewed-on: https://git.zacharie-guet.fr/zacharie/minijam-166/pulls/9
This commit is contained in:
commit
e1797e1062
@ -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)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://qpdlnll5pihe"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://qpdlnll5pihe"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/planter.gd" id="1_l7lry"]
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="2_7h3ga"]
|
||||
@ -14,11 +14,14 @@
|
||||
[ext_resource type="Resource" uid="uid://d25s1eywvsyei" path="res://objects/plant_types/Oogut.tres" id="11_horsi"]
|
||||
[ext_resource type="Resource" uid="uid://c64hhkqk4tnas" path="res://objects/plant_types/Ungrake.tres" id="12_3gp5h"]
|
||||
[ext_resource type="Resource" uid="uid://cev7wbg0cfel3" path="res://objects/plant_types/Wyrran.tres" id="13_bk383"]
|
||||
[ext_resource type="Resource" uid="uid://cfbdjq14ouwra" path="res://objects/plant_types/Bonaluria.tres" id="14_kmmq3"]
|
||||
[ext_resource type="Resource" uid="uid://cbvlod5m6s5pk" path="res://objects/plant_types/Lithoniel.tres" id="15_2ou33"]
|
||||
[ext_resource type="Resource" uid="uid://bje2xwse2ilga" path="res://objects/plant_types/Neviusia.tres" id="16_oikee"]
|
||||
|
||||
[node name="Planter" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("1_l7lry")
|
||||
plants = Array[ExtResource("2_7h3ga")]([ExtResource("3_p5nyf"), ExtResource("4_3dxep"), ExtResource("5_4of7l"), ExtResource("6_xiom8"), ExtResource("7_7i4v0"), ExtResource("8_i0wa5"), ExtResource("9_y8ss7"), ExtResource("10_sdupl"), ExtResource("11_horsi"), ExtResource("12_3gp5h"), ExtResource("13_bk383")])
|
||||
plants = Array[ExtResource("2_7h3ga")]([ExtResource("3_p5nyf"), ExtResource("4_3dxep"), ExtResource("5_4of7l"), ExtResource("6_xiom8"), ExtResource("7_7i4v0"), ExtResource("8_i0wa5"), ExtResource("9_y8ss7"), ExtResource("10_sdupl"), ExtResource("11_horsi"), ExtResource("12_3gp5h"), ExtResource("13_bk383"), ExtResource("14_kmmq3"), ExtResource("15_2ou33"), ExtResource("16_oikee")])
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.2
|
||||
|
||||
@ -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"]
|
||||
|
||||
57
objects/plant_types/Neviusia.tres
Normal file
57
objects/plant_types/Neviusia.tres
Normal file
@ -0,0 +1,57 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=8 format=3 uid="uid://bje2xwse2ilga"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="1_8y2m5"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3kjaw1hajc6s" path="res://assets/grille_seeds.png" id="2_0bswh"]
|
||||
[ext_resource type="Texture2D" uid="uid://di74g50h3oruf" path="res://assets/plants/plantes mortes/arbre_mort.png" id="3_pmix4"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbj6fmw8pxnsb" path="res://assets/plants/arbre4.png" id="4_4j1rk"]
|
||||
[ext_resource type="Texture2D" uid="uid://bxw81k0af64wo" path="res://assets/plants/arbre4_bebe.png" id="5_0d7t0"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e0ddp"]
|
||||
atlas = ExtResource("2_0bswh")
|
||||
region = Rect2(810, 270, 270, 270)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_qtm0k"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("3_pmix4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"DEAD",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_4j1rk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"GROWN",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("5_0d7t0")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"SAPLING",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_8y2m5")
|
||||
type = "Neviusia"
|
||||
seed_sprite = SubResource("AtlasTexture_e0ddp")
|
||||
sprite_frames = SubResource("SpriteFrames_qtm0k")
|
||||
growing_time = 60.0
|
||||
offspring_per_lifetime = 0
|
||||
dying_time = 240.0
|
||||
dead_time = 120.0
|
||||
water_need = [0, 10]
|
||||
fertility_need = [0, 10]
|
||||
presence_need = [2, 20]
|
||||
water_prod = 4
|
||||
fertility_prod = 4
|
||||
presence_prod = 4
|
||||
dead_water_prod = 2
|
||||
dead_fertility_prod = 2
|
||||
distance_prod = 600
|
||||
@ -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"]
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()]
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user