Various adding : camera, ground texture...
This commit is contained in:
parent
7949eb6489
commit
b3e06bdb2d
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
# Godot 4+ specific ignores
|
# Godot 4+ specific ignores
|
||||||
.godot/
|
.godot/
|
||||||
/android/
|
/android/
|
||||||
addons/
|
addons/
|
||||||
|
*.tmp
|
||||||
@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://d3srnfkpx01we"]
|
[gd_scene load_steps=5 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://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://dha8pa1les53a" path="res://scenes/Gui.tscn" id="2_d5c8m"]
|
||||||
[ext_resource type="PackedScene" uid="uid://qpdlnll5pihe" path="res://objects/Planter.tscn" id="3_qx0o7"]
|
[ext_resource type="Script" path="res://scripts/camera.gd" id="3_7olyu"]
|
||||||
|
[ext_resource type="PackedScene" path="res://objects/Planter.tscn" id="3_qx0o7"]
|
||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
|
|
||||||
@ -14,4 +15,8 @@
|
|||||||
|
|
||||||
[node name="Planter" parent="." instance=ExtResource("3_qx0o7")]
|
[node name="Planter" parent="." instance=ExtResource("3_qx0o7")]
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(709, 382)
|
||||||
|
script = ExtResource("3_7olyu")
|
||||||
|
|
||||||
[connection signal="scanner_selected" from="Interface/Gui" to="Map" method="_on_gui_scanner_selected"]
|
[connection signal="scanner_selected" from="Interface/Gui" to="Map" method="_on_gui_scanner_selected"]
|
||||||
|
|||||||
7
assets/gradients/Presence.tres
Normal file
7
assets/gradients/Presence.tres
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://biti1wmdsg7xr"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_pafyk"]
|
||||||
|
colors = PackedColorArray(0.1404, 0.69472, 0.78, 1, 0.94, 0, 0.344667, 1)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
gradient = SubResource("Gradient_pafyk")
|
||||||
8
assets/gradients/Water.tres
Normal file
8
assets/gradients/Water.tres
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://cwowpvsoo3dey"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_pafyk"]
|
||||||
|
offsets = PackedFloat32Array(0, 0.22549, 0.51634, 0.813725, 1)
|
||||||
|
colors = PackedColorArray(0.447739, 0.331581, 0, 1, 0.377511, 0.343195, 0, 1, 0.0321677, 2.76752e-07, 0.262162, 1, 1.92523e-06, 0.536048, 0.68651, 1, 0.5303, 0.775848, 1, 1)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
gradient = SubResource("Gradient_pafyk")
|
||||||
BIN
assets/texture/ground.jpg
Normal file
BIN
assets/texture/ground.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
34
assets/texture/ground.jpg.import
Normal file
34
assets/texture/ground.jpg.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dtvde6oxrfuk1"
|
||||||
|
path="res://.godot/imported/ground.jpg-2eec989771def1cab2ea361da548425a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/texture/ground.jpg"
|
||||||
|
dest_files=["res://.godot/imported/ground.jpg-2eec989771def1cab2ea361da548425a.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=true
|
||||||
|
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
|
||||||
@ -19,11 +19,13 @@ offset_right = 60.5
|
|||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
selected = 0
|
selected = 0
|
||||||
item_count = 3
|
item_count = 4
|
||||||
popup/item_0/text = "No Scanner"
|
popup/item_0/text = "No Scanner"
|
||||||
popup/item_1/text = "Water"
|
popup/item_1/text = "Water"
|
||||||
popup/item_1/id = 1
|
popup/item_1/id = 1
|
||||||
popup/item_2/text = "Fertility"
|
popup/item_2/text = "Fertility"
|
||||||
popup/item_2/id = 2
|
popup/item_2/id = 2
|
||||||
|
popup/item_3/text = "Population"
|
||||||
|
popup/item_3/id = 3
|
||||||
|
|
||||||
[connection signal="item_selected" from="Scanner Select" to="." method="_on_scanner_select_item_selected"]
|
[connection signal="item_selected" from="Scanner Select" to="." method="_on_scanner_select_item_selected"]
|
||||||
|
|||||||
@ -31,3 +31,13 @@ plant={
|
|||||||
"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)
|
"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)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
zoom={
|
||||||
|
"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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
dezoom={
|
||||||
|
"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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -1,9 +1,17 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://d3hul8b7hlmj7"]
|
[gd_scene load_steps=4 format=3 uid="uid://d3hul8b7hlmj7"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/map.gd" id="1_3np0o"]
|
[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://6ferubyu2uy1" path="res://scenes/Scanners.tscn" id="1_6mlj0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dtvde6oxrfuk1" path="res://assets/texture/ground.jpg" id="3_20ci8"]
|
||||||
|
|
||||||
[node name="Map" type="Node2D"]
|
[node name="Map" type="Node2D"]
|
||||||
script = ExtResource("1_3np0o")
|
script = ExtResource("1_3np0o")
|
||||||
|
|
||||||
[node name="Scanners" parent="." instance=ExtResource("1_6mlj0")]
|
[node name="Scanners" parent="." instance=ExtResource("1_6mlj0")]
|
||||||
|
|
||||||
|
[node name="Ground" type="Polygon2D" parent="."]
|
||||||
|
z_index = -1
|
||||||
|
texture_repeat = 2
|
||||||
|
texture = ExtResource("3_20ci8")
|
||||||
|
texture_scale = Vector2(5, 5)
|
||||||
|
polygon = PackedVector2Array(571, 76, 228, 282, 987, 657, 1379, 208)
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
[gd_scene load_steps=9 format=3 uid="uid://6ferubyu2uy1"]
|
[gd_scene load_steps=11 format=3 uid="uid://6ferubyu2uy1"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/scanners.gd" id="1_orxwo"]
|
[ext_resource type="Script" path="res://scripts/scanners.gd" id="1_orxwo"]
|
||||||
[ext_resource type="Shader" path="res://scripts/shaders/Scanner.gdshader" id="2_8t6wf"]
|
[ext_resource type="Shader" path="res://scripts/shaders/Scanner.gdshader" id="2_8t6wf"]
|
||||||
[ext_resource type="Texture2D" uid="uid://be2uusaqcpcpd" path="res://assets/gradients/Fertility.tres" id="3_bt6q7"]
|
[ext_resource type="Texture2D" uid="uid://be2uusaqcpcpd" path="res://assets/gradients/Fertility.tres" id="3_bt6q7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cwowpvsoo3dey" path="res://assets/gradients/Water.tres" id="4_ii7xr"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://biti1wmdsg7xr" path="res://assets/gradients/Presence.tres" id="5_t803i"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_05bn7"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_05bn7"]
|
||||||
shader = ExtResource("2_8t6wf")
|
shader = ExtResource("2_8t6wf")
|
||||||
@ -12,7 +14,7 @@ shader_parameter/gradient = ExtResource("3_bt6q7")
|
|||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lpu5x"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lpu5x"]
|
||||||
shader = ExtResource("2_8t6wf")
|
shader = ExtResource("2_8t6wf")
|
||||||
shader_parameter/dimension = 0
|
shader_parameter/dimension = 0
|
||||||
shader_parameter/gradient = ExtResource("3_bt6q7")
|
shader_parameter/gradient = ExtResource("4_ii7xr")
|
||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_sc8ss"]
|
[sub_resource type="Gradient" id="Gradient_sc8ss"]
|
||||||
interpolation_mode = 1
|
interpolation_mode = 1
|
||||||
@ -27,7 +29,7 @@ fill_to = Vector2(1, 1)
|
|||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0lkln"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0lkln"]
|
||||||
shader = ExtResource("2_8t6wf")
|
shader = ExtResource("2_8t6wf")
|
||||||
shader_parameter/dimension = 2
|
shader_parameter/dimension = 2
|
||||||
shader_parameter/gradient = ExtResource("3_bt6q7")
|
shader_parameter/gradient = ExtResource("5_t803i")
|
||||||
|
|
||||||
[node name="Scanners" type="Node2D"]
|
[node name="Scanners" type="Node2D"]
|
||||||
script = ExtResource("1_orxwo")
|
script = ExtResource("1_orxwo")
|
||||||
|
|||||||
34
scripts/camera.gd
Normal file
34
scripts/camera.gd
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
extends Camera2D
|
||||||
|
|
||||||
|
const MOVEMENT_SPEED = 200
|
||||||
|
const ZOOM_SPEED = 10
|
||||||
|
const ZOOM_WINDOW = [0.5, 2]
|
||||||
|
const BORDER_THRESHOLD = 50
|
||||||
|
|
||||||
|
var movement = Vector2()
|
||||||
|
var zoom_change = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
movement = Vector2()
|
||||||
|
zoom_change = 0
|
||||||
|
|
||||||
|
if Input.is_action_pressed("ui_right"):
|
||||||
|
movement.x = 1
|
||||||
|
if Input.is_action_pressed("ui_left"):
|
||||||
|
movement.x = -1
|
||||||
|
if Input.is_action_pressed("ui_up"):
|
||||||
|
movement.y = -1
|
||||||
|
if Input.is_action_pressed("ui_down"):
|
||||||
|
movement.y = 1
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("zoom"):
|
||||||
|
zoom_change = 1
|
||||||
|
if Input.is_action_just_pressed("dezoom"):
|
||||||
|
zoom_change = -1
|
||||||
|
|
||||||
|
movement = movement.normalized()
|
||||||
|
|
||||||
|
var zoom_value = max(min(zoom.x + zoom_change*ZOOM_SPEED*delta, ZOOM_WINDOW[1]), ZOOM_WINDOW[0])
|
||||||
|
zoom = Vector2(zoom_value, zoom_value)
|
||||||
|
position = position+movement*MOVEMENT_SPEED*delta
|
||||||
@ -1,6 +1,15 @@
|
|||||||
class_name Map
|
class_name Map
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var map_size = GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO
|
||||||
|
|
||||||
|
$Ground.set_polygon(PackedVector2Array([
|
||||||
|
Vector2(0,0),
|
||||||
|
Vector2(map_size.x, 0),
|
||||||
|
Vector2(map_size.x, map_size.y),
|
||||||
|
Vector2(0, map_size.y),
|
||||||
|
]))
|
||||||
|
|
||||||
func _on_gui_scanner_selected(type : Scanners.Type):
|
func _on_gui_scanner_selected(type : Scanners.Type):
|
||||||
$Scanners.select_scanner(type)
|
$Scanners.select_scanner(type)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ shader_type canvas_item;
|
|||||||
uniform sampler2D gradient : source_color, filter_nearest;
|
uniform sampler2D gradient : source_color, filter_nearest;
|
||||||
uniform int dimension;
|
uniform int dimension;
|
||||||
|
|
||||||
const float alpha = 0.3;
|
const float alpha = 0.5;
|
||||||
const float strength = 0.5;
|
const float strength = 0.5;
|
||||||
const float pi = atan(1.0) * 4.0;
|
const float pi = atan(1.0) * 4.0;
|
||||||
const int samples = 35;
|
const int samples = 35;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ enum Stats {WATER, FERTILITY, PRESENCE}
|
|||||||
|
|
||||||
const TERRAIN_SIZE = Vector2i(300, 300)
|
const TERRAIN_SIZE = Vector2i(300, 300)
|
||||||
const LEVELS_NUMBER : int = 10
|
const LEVELS_NUMBER : int = 10
|
||||||
const MAP_RATIO = 4;
|
const MAP_RATIO = 8;
|
||||||
|
|
||||||
@onready var image := Image.create_empty(
|
@onready var image := Image.create_empty(
|
||||||
TERRAIN_SIZE.x,
|
TERRAIN_SIZE.x,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user