Compare commits
10 Commits
df937c69d0
...
c8859d5e9f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8859d5e9f | ||
|
|
fdcef59322 | ||
|
|
6bfc792cd0 | ||
|
|
fbc4795e8a | ||
|
|
4b926f4ea5 | ||
|
|
59bd119254 | ||
|
|
6029bc66bd | ||
|
|
4c1e5fe895 | ||
|
|
21bd9b1bb1 | ||
|
|
d1758f750d |
@@ -823,15 +823,12 @@ separation = Vector2i(1, 1)
|
||||
25:14/0 = 0
|
||||
26:14/0 = 0
|
||||
0:15/0 = 0
|
||||
0:15/0/z_index = 1
|
||||
1:15/0 = 0
|
||||
1:15/0/z_index = 1
|
||||
1:15/0/terrain_set = 0
|
||||
1:15/0/terrains_peering_bit/right_side = 1
|
||||
1:15/0/terrains_peering_bit/bottom_side = 1
|
||||
1:15/0/terrains_peering_bit/left_side = 1
|
||||
2:15/0 = 0
|
||||
2:15/0/z_index = 1
|
||||
3:15/0 = 0
|
||||
4:15/0 = 0
|
||||
5:15/0 = 0
|
||||
@@ -857,9 +854,7 @@ separation = Vector2i(1, 1)
|
||||
25:15/0 = 0
|
||||
26:15/0 = 0
|
||||
0:16/0 = 0
|
||||
0:16/0/z_index = 1
|
||||
1:16/0 = 0
|
||||
1:16/0/z_index = 1
|
||||
1:16/0/y_sort_origin = 1
|
||||
1:16/0/terrain_set = 0
|
||||
1:16/0/terrains_peering_bit/right_side = 1
|
||||
@@ -867,23 +862,14 @@ separation = Vector2i(1, 1)
|
||||
1:16/0/terrains_peering_bit/left_side = 1
|
||||
1:16/0/terrains_peering_bit/top_side = 1
|
||||
2:16/0 = 0
|
||||
2:16/0/z_index = 1
|
||||
3:16/0 = 0
|
||||
3:16/0/z_index = 1
|
||||
4:16/0 = 0
|
||||
4:16/0/z_index = 1
|
||||
5:16/0 = 0
|
||||
5:16/0/z_index = 1
|
||||
6:16/0 = 0
|
||||
6:16/0/z_index = 1
|
||||
7:16/0 = 0
|
||||
7:16/0/z_index = 1
|
||||
8:16/0 = 0
|
||||
8:16/0/z_index = 1
|
||||
9:16/0 = 0
|
||||
9:16/0/z_index = 1
|
||||
10:16/0 = 0
|
||||
10:16/0/z_index = 1
|
||||
11:16/0 = 0
|
||||
12:16/0 = 0
|
||||
13:16/0 = 0
|
||||
@@ -903,42 +889,32 @@ separation = Vector2i(1, 1)
|
||||
0:17/0 = 0
|
||||
0:17/0/z_index = 1
|
||||
1:17/0 = 0
|
||||
1:17/0/z_index = 1
|
||||
1:17/0/terrain_set = 0
|
||||
1:17/0/terrains_peering_bit/right_side = 1
|
||||
1:17/0/terrains_peering_bit/left_side = 1
|
||||
1:17/0/terrains_peering_bit/top_side = 1
|
||||
2:17/0 = 0
|
||||
2:17/0/z_index = 1
|
||||
2:17/0/terrain_set = 0
|
||||
2:17/0/terrains_peering_bit/right_side = 1
|
||||
2:17/0/terrains_peering_bit/bottom_side = 1
|
||||
2:17/0/terrains_peering_bit/top_side = 1
|
||||
3:17/0 = 0
|
||||
3:17/0/z_index = 1
|
||||
3:17/0/terrain_set = 0
|
||||
3:17/0/terrains_peering_bit/right_side = 1
|
||||
3:17/0/terrains_peering_bit/bottom_side = 1
|
||||
3:17/0/terrains_peering_bit/left_side = 1
|
||||
3:17/0/terrains_peering_bit/top_side = 1
|
||||
4:17/0 = 0
|
||||
4:17/0/z_index = 1
|
||||
4:17/0/terrain_set = 0
|
||||
4:17/0/terrains_peering_bit/bottom_side = 1
|
||||
4:17/0/terrains_peering_bit/left_side = 1
|
||||
4:17/0/terrains_peering_bit/top_side = 1
|
||||
5:17/0 = 0
|
||||
5:17/0/z_index = 1
|
||||
6:17/0 = 0
|
||||
6:17/0/z_index = 1
|
||||
7:17/0 = 0
|
||||
7:17/0/z_index = 1
|
||||
8:17/0 = 0
|
||||
8:17/0/z_index = 1
|
||||
9:17/0 = 0
|
||||
9:17/0/z_index = 1
|
||||
10:17/0 = 0
|
||||
10:17/0/z_index = 1
|
||||
11:17/0 = 0
|
||||
12:17/0 = 0
|
||||
13:17/0 = 0
|
||||
|
||||
@@ -15,3 +15,8 @@ func _process(delta: float) -> void:
|
||||
global_position += Vector2.LEFT * 2
|
||||
if Input.is_action_pressed("MoveRight"):
|
||||
global_position += Vector2.RIGHT * 2
|
||||
|
||||
if Input.is_action_just_released("ZoomIn"):
|
||||
$SmartCamera2D.zoom += Vector2.ONE
|
||||
if Input.is_action_just_released("ZoomOut"):
|
||||
$SmartCamera2D.zoom -= Vector2.ONE
|
||||
18
Scenes/Camera/camera_controller.tscn
Normal file
18
Scenes/Camera/camera_controller.tscn
Normal file
@@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bfvijh611aggp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://brublmhrsdc7l" path="res://Scenes/Camera/camera_controller.gd" id="1_ig7ij"]
|
||||
[ext_resource type="Script" uid="uid://xrddv2epi3ty" path="res://addons/smartcamera2D/SmartCamera2D.gd" id="2_du7i2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bq6ud1dmn8fds" path="res://addons/smartcamera2D/Camera2D.svg" id="3_bg4ca"]
|
||||
|
||||
[node name="CameraController" type="Node2D"]
|
||||
script = ExtResource("1_ig7ij")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="SmartCamera2D" type="Camera2D" parent="."]
|
||||
position_smoothing_enabled = true
|
||||
script = ExtResource("2_du7i2")
|
||||
target = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://xrddv2epi3ty"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("3_bg4ca")
|
||||
@@ -1,18 +1,24 @@
|
||||
extends Node
|
||||
|
||||
@onready var _Map: Node = $Map
|
||||
#@onready var _Player = $Player
|
||||
#@onready var _Camera = $WorldCamera
|
||||
@onready var _Unit = $Unit
|
||||
@onready var _Camera = $CameraController
|
||||
|
||||
@export var mapSize: int = 15
|
||||
var _UnitScene = preload("res://Scenes/Unit/unit.tscn")
|
||||
|
||||
#@export var mapSize: int = 15
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var thread: Thread = Thread.new()
|
||||
thread.start(func(): _Map.generate_map(mapSize))
|
||||
thread.wait_to_finish()
|
||||
_createUnit(Vector2i(150, 150))
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _createUnit(pos: Vector2i):
|
||||
var newUnit = _UnitScene.instantiate()
|
||||
newUnit.global_position = pos
|
||||
add_child(newUnit)
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://d05j5yuhlsxp0"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d05j5yuhlsxp0"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cywuuce71rmgb" path="res://Scenes/Map/map.tscn" id="1_1r6ip"]
|
||||
[ext_resource type="Script" uid="uid://btdvxp8ckmeb3" path="res://Scenes/Main/main.gd" id="1_qw60k"]
|
||||
[ext_resource type="Script" uid="uid://brublmhrsdc7l" path="res://Scenes/Main/camera_controller.gd" id="3_p6jpk"]
|
||||
[ext_resource type="Script" uid="uid://xrddv2epi3ty" path="res://addons/smartcamera2D/SmartCamera2D.gd" id="3_qw60k"]
|
||||
[ext_resource type="Texture2D" uid="uid://bq6ud1dmn8fds" path="res://addons/smartcamera2D/Camera2D.svg" id="5_2a143"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfvijh611aggp" path="res://Scenes/Camera/camera_controller.tscn" id="3_qw60k"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy7rltpxyqyw7" path="res://Scenes/Unit/unit.tscn" id="4_5yls4"]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource("1_qw60k")
|
||||
mapSize = 100
|
||||
|
||||
[node name="Map" parent="." instance=ExtResource("1_1r6ip")]
|
||||
|
||||
[node name="CameraController" type="Node2D" parent="."]
|
||||
script = ExtResource("3_p6jpk")
|
||||
metadata/_edit_group_ = true
|
||||
[node name="CameraController" parent="." instance=ExtResource("3_qw60k")]
|
||||
|
||||
[node name="SmartCamera2D" type="Camera2D" parent="CameraController"]
|
||||
script = ExtResource("3_qw60k")
|
||||
target = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://xrddv2epi3ty"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="CameraController"]
|
||||
texture = ExtResource("5_2a143")
|
||||
|
||||
[editable path="Map"]
|
||||
[node name="Unit" parent="." instance=ExtResource("4_5yls4")]
|
||||
|
||||
@@ -28,7 +28,7 @@ tile_set = ExtResource("2_fyo8k")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Buildings" type="TileMapLayer" parent="."]
|
||||
tile_map_data = PackedByteArray("AAAgAAkAAQAAAAMAAAAhAAkAAQACAAMAAAAkAAkAAQACAAMAAAAjAAkAAQACAAMAAAAiAAkAAQACAAMAAAAgAAsAAQAAAAMAAAAgAAwAAQAAAAQAAAAgAA0AAQAAAAUAAAAgAA4AAQAQAAQAAAAgAA8AAQAQAAUAAAAgABAAAQAQAAYAAAAgABEAAQAQAAYAAAAgABIAAQAQAAYAAAAgABMAAQAQAAcAAAAhAAsAAQABAAMAAAAhAAwAAQABAAQAAAAhAA0AAQABAAUAAAAhAA4AAQASAAQAAAAhAA8AAQASAAYAAAAhABAAAQASAAYAAAAhABEAAQASAAYAAAAhABIAAQASAAYAAAAhABMAAQASAAcAAAAiAAsAAQABAAMAAAAiAAwAAQABAAQAAAAiAA0AAQABAAUAAAAiAA4AAQASAAQAAAAiAA8AAQASAAYAAAAiABAAAQASAAYAAAAiABEAAQASAAYAAAAiABIAAQASAAYAAAAiABMAAQASAAcAAAAjAAsAAQABAAMAAAAjAAwAAQABAAQAAAAjAA0AAQABAAUAAAAjAA4AAQASAAQAAAAjAA8AAQASAAYAAAAjABAAAQASAAYAAAAjABEAAQASAAYAAAAjABIAAQASAAYAAAAjABMAAQ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AAAA0AA8AAQAQAAYAAAA0ABAAAQAQAAUAAAA0ABEAAQAQAAYAAAA0ABIAAQAQAAUAAAAwABMAAQAQAAcAAAAxABMAAQASAAcAAAAyABMAAQASAAcAAAAzABMAAQASAAcAAAA0ABMAAQAQAAcAAAA=")
|
||||
tile_set = ExtResource("2_fyo8k")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
|
||||
@@ -31,15 +31,6 @@ func _input(event: InputEvent):
|
||||
if event.is_action_pressed("Select"):
|
||||
print_debug("Action is Select")
|
||||
|
||||
# Can't select from myself since (global_)position is alway 0,0
|
||||
print("Event position: ", event.position)
|
||||
print("My position is", position)
|
||||
print("My global_position is", global_position)
|
||||
|
||||
if event.position == global_position:
|
||||
_setSelected(true)
|
||||
print_debug("Unit selected")
|
||||
|
||||
# We combine it with the fact that it is already marked (@see _markUnit)
|
||||
if _readyToSelect: _selectUnit()
|
||||
else: _deselectUnit()
|
||||
|
||||
@@ -60,6 +60,26 @@ MoveRight={
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
Select={
|
||||
"deadzone": 0.2,
|
||||
"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":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
SetMarker={
|
||||
"deadzone": 0.2,
|
||||
"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":2,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
ZoomIn={
|
||||
"deadzone": 0.2,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
ZoomOut={
|
||||
"deadzone": 0.2,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user