plant needs and adds
This commit is contained in:
parent
5f8052f0a3
commit
7949eb6489
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://d3srnfkpx01we"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://d3srnfkpx01we"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d3hul8b7hlmj7" path="res://scenes/Map.tscn" id="1_nnb57"]
|
||||
[ext_resource type="PackedScene" uid="uid://dha8pa1les53a" path="res://scenes/Gui.tscn" id="2_d5c8m"]
|
||||
[ext_resource type="PackedScene" uid="uid://qpdlnll5pihe" path="res://objects/Planter.tscn" id="3_qx0o7"]
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
|
||||
@ -11,4 +12,6 @@
|
||||
|
||||
[node name="Gui" parent="Interface" instance=ExtResource("2_d5c8m")]
|
||||
|
||||
[node name="Planter" parent="." instance=ExtResource("3_qx0o7")]
|
||||
|
||||
[connection signal="scanner_selected" from="Interface/Gui" to="Map" method="_on_gui_scanner_selected"]
|
||||
|
||||
BIN
assets/gamejam_plantes_props1.png
Normal file
BIN
assets/gamejam_plantes_props1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
34
assets/gamejam_plantes_props1.png.import
Normal file
34
assets/gamejam_plantes_props1.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://r1bq2tgt1yxf"
|
||||
path="res://.godot/imported/gamejam_plantes_props1.png-883395961c2967eab2cce52353d847dc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gamejam_plantes_props1.png"
|
||||
dest_files=["res://.godot/imported/gamejam_plantes_props1.png-883395961c2967eab2cce52353d847dc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
15
objects/Planter.tscn
Normal file
15
objects/Planter.tscn
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=6 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"]
|
||||
[ext_resource type="Resource" uid="uid://bgi2lo7kb3d2v" path="res://objects/plant_types/chardon.tres" id="3_lgbrc"]
|
||||
[ext_resource type="Resource" uid="uid://dnahox31xqy6l" path="res://objects/plant_types/peuplier.tres" id="4_tmfl1"]
|
||||
[ext_resource type="Resource" uid="uid://b6ufxuqdcgwmx" path="res://objects/plant_types/chene.tres" id="5_j34av"]
|
||||
|
||||
[node name="Planter" type="Node"]
|
||||
script = ExtResource("1_l7lry")
|
||||
plants = Array[ExtResource("2_7h3ga")]([ExtResource("3_lgbrc"), ExtResource("4_tmfl1"), ExtResource("5_j34av")])
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
@ -1,6 +1,4 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c4doyvo3mqgvl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://biekl11dvnhgw" path="res://Victor_carre.jpg" id="1_x6d3i"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://x4kv2y5f52cm"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_x3g5o"]
|
||||
script/source = "class_name Plant
|
||||
@ -14,14 +12,39 @@ signal died
|
||||
|
||||
@onready var growing_timer: Timer = $Growing
|
||||
@onready var sprite_node: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var need_checker: Timer = $NeedChecker
|
||||
|
||||
const NEEDCHECKPERIOD := 1.0
|
||||
|
||||
var parameter: PlantType
|
||||
var state := PlantState.SAPLING
|
||||
|
||||
var can_grow := true
|
||||
|
||||
func init(plant_parameter: PlantType):
|
||||
parameter = plant_parameter
|
||||
sprite_node.sprite_frames = parameter.sprite_frames
|
||||
need_checker.start(NEEDCHECKPERIOD)
|
||||
|
||||
|
||||
func _on_need_checker_timeout() -> void:
|
||||
can_grow = check_terrain_viability()
|
||||
growing_timer.paused = not can_grow
|
||||
|
||||
func check_terrain_viability() -> bool:
|
||||
var water := GameTerrain.get_stat(position, GameTerrain.Stats.WATER)
|
||||
if water < parameter.water_need[0] or water > parameter.water_need[1]:
|
||||
return false
|
||||
|
||||
var fertility := GameTerrain.get_stat(position, GameTerrain.Stats.FERTILITY)
|
||||
if fertility < parameter.fertility_need[0] or fertility > parameter.fertility_need[1]:
|
||||
return false
|
||||
|
||||
var presence := GameTerrain.get_stat(position, GameTerrain.Stats.PRESENCE)
|
||||
presence += GameTerrain.LEVELS_NUMBER / 2
|
||||
if presence < parameter.presence_need[0] or parameter.presence_need[1]:
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _on_growing_timeout() -> void:
|
||||
@ -47,6 +70,18 @@ func grow():
|
||||
return
|
||||
state = PlantState.GROWN
|
||||
growing_timer.start(parameter.dying_time)
|
||||
GameTerrain.modify_zone(position,
|
||||
parameter.distance_prod,
|
||||
GameTerrain.Stats.WATER,
|
||||
parameter.water_prod)
|
||||
GameTerrain.modify_zone(position,
|
||||
parameter.distance_prod,
|
||||
GameTerrain.Stats.FERTILITY,
|
||||
parameter.fertility_prod)
|
||||
GameTerrain.modify_zone(position,
|
||||
parameter.distance_prod,
|
||||
GameTerrain.Stats.PRESENCE,
|
||||
parameter.presence_prod)
|
||||
grown.emit()
|
||||
sprite_node.play(\"GROWN\")
|
||||
|
||||
@ -60,10 +95,7 @@ func die():
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_667un"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("1_x6d3i")
|
||||
}],
|
||||
"frames": [],
|
||||
"loop": true,
|
||||
"name": &"SEED",
|
||||
"speed": 5.0
|
||||
@ -73,10 +105,14 @@ animations = [{
|
||||
script = SubResource("GDScript_x3g5o")
|
||||
|
||||
[node name="Growing" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="NeedChecker" type="Timer" parent="."]
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(0.0378561, 0.0378561)
|
||||
scale = Vector2(0.2, 0.2)
|
||||
sprite_frames = SubResource("SpriteFrames_667un")
|
||||
animation = &"SEED"
|
||||
|
||||
[connection signal="timeout" from="Growing" to="." method="_on_growing_timeout"]
|
||||
[connection signal="timeout" from="NeedChecker" to="." method="_on_need_checker_timeout"]
|
||||
|
||||
@ -1,26 +1,41 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=4 format=3 uid="uid://bgi2lo7kb3d2v"]
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://bgi2lo7kb3d2v"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="1_i8xe4"]
|
||||
[ext_resource type="Texture2D" uid="uid://b11jyrkhw7ebp" path="res://icon.svg" id="1_t42om"]
|
||||
[ext_resource type="Texture2D" uid="uid://r1bq2tgt1yxf" path="res://assets/gamejam_plantes_props1.png" id="2_gaemm"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fxqnu"]
|
||||
atlas = ExtResource("2_gaemm")
|
||||
region = Rect2(1920, 1620, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sjq1e"]
|
||||
atlas = ExtResource("2_gaemm")
|
||||
region = Rect2(320, 1080, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jsm3j"]
|
||||
atlas = ExtResource("2_gaemm")
|
||||
region = Rect2(0, 1080, 320, 540)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_fxtnk"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("1_t42om")
|
||||
"texture": SubResource("AtlasTexture_fxqnu")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"DEAD",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [],
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sjq1e")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"GROWN",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("1_t42om")
|
||||
"texture": SubResource("AtlasTexture_jsm3j")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"SAPLING",
|
||||
@ -33,11 +48,12 @@ type = "Chardon"
|
||||
sprite_frames = SubResource("SpriteFrames_fxtnk")
|
||||
growing_time = 0.5
|
||||
dying_time = 10.0
|
||||
water_need = 5
|
||||
soil_need = 0
|
||||
distance_needed = 0.1
|
||||
water_prod = 0
|
||||
soil_prod = 0
|
||||
water_need = [0, 0]
|
||||
fertility_need = [0, 0]
|
||||
presence_need = [0, 0]
|
||||
water_prod = 1
|
||||
fertility_prod = -1
|
||||
presence_prod = 1
|
||||
dead_water_prod = 0
|
||||
dead_soil_prod = 1
|
||||
distance_prod = 0.1
|
||||
dead_fertility_prod = 1
|
||||
distance_prod = 50
|
||||
|
||||
@ -1,24 +1,42 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=4 format=3 uid="uid://b6ufxuqdcgwmx"]
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://b6ufxuqdcgwmx"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="1_meppe"]
|
||||
[ext_resource type="Texture2D" uid="uid://b11jyrkhw7ebp" path="res://icon.svg" id="3_14y3x"]
|
||||
[ext_resource type="Texture2D" uid="uid://r1bq2tgt1yxf" path="res://assets/gamejam_plantes_props1.png" id="2_jkmk8"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vmgwa"]
|
||||
atlas = ExtResource("2_jkmk8")
|
||||
region = Rect2(2880, 1080, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7r8et"]
|
||||
atlas = ExtResource("2_jkmk8")
|
||||
region = Rect2(2880, 540, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_oy8ng"]
|
||||
atlas = ExtResource("2_jkmk8")
|
||||
region = Rect2(3200, 0, 320, 540)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_shufc"]
|
||||
animations = [{
|
||||
"frames": [],
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vmgwa")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"DEAD",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("3_14y3x")
|
||||
"texture": SubResource("AtlasTexture_7r8et")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"GROWN",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [],
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_oy8ng")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"SAPLING",
|
||||
"speed": 5.0
|
||||
@ -30,11 +48,12 @@ type = "Chene"
|
||||
sprite_frames = SubResource("SpriteFrames_shufc")
|
||||
growing_time = 50.0
|
||||
dying_time = 100.0
|
||||
water_need = 1
|
||||
soil_need = 1
|
||||
distance_needed = 0.1
|
||||
water_need = [0, 0]
|
||||
fertility_need = [0, 0]
|
||||
presence_need = [0, 0]
|
||||
water_prod = 1
|
||||
soil_prod = 1
|
||||
fertility_prod = 2
|
||||
presence_prod = 1
|
||||
dead_water_prod = 0
|
||||
dead_soil_prod = 1
|
||||
distance_prod = 0.1
|
||||
dead_fertility_prod = 1
|
||||
distance_prod = 50.0
|
||||
|
||||
@ -1,23 +1,41 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=4 format=3 uid="uid://dnahox31xqy6l"]
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=7 format=3 uid="uid://dnahox31xqy6l"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b11jyrkhw7ebp" path="res://icon.svg" id="1_b2cb6"]
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="1_mhtmv"]
|
||||
[ext_resource type="Texture2D" uid="uid://r1bq2tgt1yxf" path="res://assets/gamejam_plantes_props1.png" id="2_gcjog"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ncq3n"]
|
||||
atlas = ExtResource("2_gcjog")
|
||||
region = Rect2(0, 540, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_slfxf"]
|
||||
atlas = ExtResource("2_gcjog")
|
||||
region = Rect2(1280, 1080, 320, 540)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gsxj4"]
|
||||
atlas = ExtResource("2_gcjog")
|
||||
region = Rect2(2240, 0, 320, 540)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_d15np"]
|
||||
animations = [{
|
||||
"frames": [],
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ncq3n")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"DEAD",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [],
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_slfxf")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"GROWN",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("1_b2cb6")
|
||||
"texture": SubResource("AtlasTexture_gsxj4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"SAPLING",
|
||||
@ -30,11 +48,12 @@ type = "Peuplier"
|
||||
sprite_frames = SubResource("SpriteFrames_d15np")
|
||||
growing_time = 2.0
|
||||
dying_time = 2.0
|
||||
water_need = 0
|
||||
soil_need = 0
|
||||
distance_needed = 0.1
|
||||
water_prod = 0
|
||||
soil_prod = 0
|
||||
water_need = [0, 0]
|
||||
fertility_need = [0, 0]
|
||||
presence_need = [0, 0]
|
||||
water_prod = 2
|
||||
fertility_prod = 2
|
||||
presence_prod = 1
|
||||
dead_water_prod = 0
|
||||
dead_soil_prod = 1
|
||||
distance_prod = 0.1
|
||||
dead_fertility_prod = 1
|
||||
distance_prod = 25.0
|
||||
|
||||
@ -23,3 +23,11 @@ GameTerrain="*res://scenes/Terrain.tscn"
|
||||
|
||||
version_control/plugin_name="GitPlugin"
|
||||
version_control/autoload_on_startup=true
|
||||
|
||||
[input]
|
||||
|
||||
plant={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(134, 4),"global_position":Vector2(143, 50),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
script = ExtResource("1_6gq27")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
@ -28,9 +29,11 @@ theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="SeedQueue" parent="MarginContainer" instance=ExtResource("1_lh8u1")]
|
||||
layout_mode = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="SeedCard" parent="MarginContainer" instance=ExtResource("2_bt3vo")]
|
||||
layout_mode = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="ScannerModes" parent="MarginContainer" instance=ExtResource("3_bsm7r")]
|
||||
layout_mode = 2
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
class_name Planter
|
||||
|
||||
extends Node2D
|
||||
|
||||
@export var plants: Array[PlantType]
|
||||
|
||||
@onready var plant_scene = preload("res://objects/plant.tscn")
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
var chosen_type: PlantType = plants[randi_range(0, plants.size() - 1)]
|
||||
var plant = plant_scene.instantiate()
|
||||
add_child(plant)
|
||||
plant.init(chosen_type, event.position)
|
||||
plant.plant(event.position)
|
||||
@ -34,21 +34,25 @@ script = ExtResource("1_orxwo")
|
||||
|
||||
[node name="Data" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
z_index = 5
|
||||
centered = false
|
||||
|
||||
[node name="Fertility" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
z_index = 5
|
||||
material = SubResource("ShaderMaterial_05bn7")
|
||||
centered = false
|
||||
|
||||
[node name="Water" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
z_index = 5
|
||||
material = SubResource("ShaderMaterial_lpu5x")
|
||||
texture = SubResource("GradientTexture2D_a7oi7")
|
||||
centered = false
|
||||
|
||||
[node name="Presence" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
z_index = 5
|
||||
material = SubResource("ShaderMaterial_0lkln")
|
||||
texture = SubResource("GradientTexture2D_a7oi7")
|
||||
centered = false
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bus7qrxwn2ck1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Planter.gd" id="1_l04h8"]
|
||||
[ext_resource type="Script" path="res://scripts/planter.gd" id="1_l04h8"]
|
||||
[ext_resource type="Script" path="res://scripts/plant_type.gd" id="2_6g58k"]
|
||||
[ext_resource type="Resource" uid="uid://bgi2lo7kb3d2v" path="res://objects/plant_types/chardon.tres" id="3_vfbum"]
|
||||
[ext_resource type="Resource" uid="uid://dnahox31xqy6l" path="res://objects/plant_types/peuplier.tres" id="4_aqqqx"]
|
||||
|
||||
@ -9,13 +9,14 @@ extends Resource
|
||||
@export var growing_time := 1.0
|
||||
@export var dying_time := 30.0
|
||||
|
||||
@export var water_need := 0
|
||||
@export var soil_need := 0
|
||||
@export var distance_needed := 0.1
|
||||
@export var water_need := [0, 0] # min max
|
||||
@export var fertility_need := [0, 0] # min max
|
||||
@export var presence_need := [0, 0] # min max
|
||||
|
||||
@export var water_prod := 0
|
||||
@export var soil_prod := 0
|
||||
@export var fertility_prod := 0
|
||||
@export var presence_prod := 1
|
||||
|
||||
@export var dead_water_prod := 0
|
||||
@export var dead_soil_prod := 1
|
||||
@export var distance_prod := 0.1
|
||||
@export var dead_fertility_prod := 1
|
||||
@export var distance_prod := 50
|
||||
|
||||
18
scripts/planter.gd
Normal file
18
scripts/planter.gd
Normal file
@ -0,0 +1,18 @@
|
||||
class_name Planter
|
||||
|
||||
extends Node
|
||||
|
||||
@export var plants: Array[PlantType]
|
||||
|
||||
@onready var plant_scene = preload("res://objects/Plant.tscn")
|
||||
@onready var timer: Timer = $Timer
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if Input.is_action_just_pressed("plant") and timer.is_stopped():
|
||||
var chosen_type: PlantType = plants[randi_range(0, plants.size() - 1)]
|
||||
var plant = plant_scene.instantiate()
|
||||
add_child(plant)
|
||||
plant.init(chosen_type)
|
||||
plant.plant(event.position)
|
||||
timer.start()
|
||||
@ -1,6 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
enum Stats {WATER, FERTILITY, TEMPERATURE}
|
||||
enum Stats {WATER, FERTILITY, PRESENCE}
|
||||
|
||||
const TERRAIN_SIZE = Vector2i(300, 300)
|
||||
const LEVELS_NUMBER : int = 10
|
||||
@ -19,7 +19,7 @@ var sum := 0.0
|
||||
signal terrain_updated
|
||||
|
||||
func _ready():
|
||||
setup_texture(Vector3i())
|
||||
setup_texture(Vector3i(0, 0, -5))
|
||||
|
||||
func map_to_pixel(
|
||||
position : Vector2
|
||||
@ -74,7 +74,7 @@ func modification_to_levels(
|
||||
levels.x = modification
|
||||
Stats.FERTILITY:
|
||||
levels.y = modification
|
||||
Stats.TEMPERATURE:
|
||||
Stats.PRESENCE:
|
||||
levels.z = modification
|
||||
return levels
|
||||
|
||||
@ -132,7 +132,7 @@ func modify_rect(
|
||||
func get_stat(
|
||||
pos: Vector2,
|
||||
stat : Stats
|
||||
) :
|
||||
) -> int:
|
||||
var pixel_pos = map_to_pixel(pos)
|
||||
var levels = color_to_levels(image.get_pixelv(pixel_pos))
|
||||
match stat:
|
||||
@ -140,8 +140,10 @@ func get_stat(
|
||||
return levels.x
|
||||
Stats.FERTILITY:
|
||||
return levels.y
|
||||
Stats.TEMPERATURE:
|
||||
Stats.PRESENCE:
|
||||
return levels.z
|
||||
_:
|
||||
return 0
|
||||
|
||||
func setup_texture(
|
||||
levels : Vector3i
|
||||
|
||||
Loading…
Reference in New Issue
Block a user