camera zoom in/out & camera panning
This commit is contained in:
parent
24a05c557d
commit
acf1ed5423
17 changed files with 774 additions and 80 deletions
BIN
art/placeholder/indoors.png
Normal file
BIN
art/placeholder/indoors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
34
art/placeholder/indoors.png.import
Normal file
34
art/placeholder/indoors.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c1nssojjcesom"
|
||||
path="res://.godot/imported/indoors.png-0385194c4b5190bd9e7e9194dfc3e4e8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/placeholder/indoors.png"
|
||||
dest_files=["res://.godot/imported/indoors.png-0385194c4b5190bd9e7e9194dfc3e4e8.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
|
BIN
art/placeholder/outdoors.png
Normal file
BIN
art/placeholder/outdoors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
34
art/placeholder/outdoors.png.import
Normal file
34
art/placeholder/outdoors.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dakvtfpnjuwwl"
|
||||
path="res://.godot/imported/outdoors.png-7d3b490bfc156077300af39882442502.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/placeholder/outdoors.png"
|
||||
dest_files=["res://.godot/imported/outdoors.png-7d3b490bfc156077300af39882442502.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
|
BIN
art/placeholder/vehicles.png
Normal file
BIN
art/placeholder/vehicles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
34
art/placeholder/vehicles.png.import
Normal file
34
art/placeholder/vehicles.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bg55nglnk8uci"
|
||||
path="res://.godot/imported/vehicles.png-502f12d58ac50ed88adfdecffc422010.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/placeholder/vehicles.png"
|
||||
dest_files=["res://.godot/imported/vehicles.png-502f12d58ac50ed88adfdecffc422010.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
|
|
@ -18,3 +18,41 @@ config/icon="res://icon.svg"
|
|||
[autoload]
|
||||
|
||||
Globals="*res://scripts/Globals.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/size/resizable=false
|
||||
|
||||
[input]
|
||||
|
||||
place_building={
|
||||
"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":1,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
cancel={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
camera_zoom_in={
|
||||
"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,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
camera_zoom_out={
|
||||
"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,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
camera_move={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/defaults/default_clear_color=Color(0.658824, 0.329412, 0, 1)
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
[ext_resource type="Script" path="res://scenes/Building.gd" id="1_uqlnt"]
|
||||
[ext_resource type="Texture2D" uid="uid://dabmo11wkiwm3" path="res://art/buildings/building_grid.png" id="1_yd1tr"]
|
||||
|
||||
[node name="Building" type="Node2D"]
|
||||
script = ExtResource("1_uqlnt")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
[node name="Building" type="Sprite2D"]
|
||||
texture = ExtResource("1_yd1tr")
|
||||
script = ExtResource("1_uqlnt")
|
||||
|
|
6
scenes/Camera_zoom_2d.tscn
Normal file
6
scenes/Camera_zoom_2d.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://2we3txfr812u"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/CameraZoom2D.gd" id="1_ttsl2"]
|
||||
|
||||
[node name="CameraZoom2D" type="Camera2D"]
|
||||
script = ExtResource("1_ttsl2")
|
529
scenes/Main.tscn
529
scenes/Main.tscn
|
@ -1,70 +1,541 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://ciperl36hv26g"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://ciperl36hv26g"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Main.gd" id="1_ysxum"]
|
||||
[ext_resource type="Script" path="res://scripts/View.gd" id="2_rg0qh"]
|
||||
[ext_resource type="Script" path="res://scripts/Control.gd" id="3_1t1c8"]
|
||||
[ext_resource type="Script" path="res://scripts/World.gd" id="3_6q5ju"]
|
||||
[ext_resource type="Texture2D" uid="uid://dakvtfpnjuwwl" path="res://art/placeholder/outdoors.png" id="3_yddbk"]
|
||||
[ext_resource type="PackedScene" uid="uid://2we3txfr812u" path="res://scenes/Camera_zoom_2d.tscn" id="4_rx82t"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_s55i2"]
|
||||
texture = ExtResource("3_yddbk")
|
||||
0:0/0 = 0
|
||||
1:0/0 = 0
|
||||
2:0/0 = 0
|
||||
3:0/0 = 0
|
||||
8:0/0 = 0
|
||||
9:0/0 = 0
|
||||
10:0/0 = 0
|
||||
14:0/0 = 0
|
||||
15:0/0 = 0
|
||||
16:0/0 = 0
|
||||
17:0/0 = 0
|
||||
20:0/0 = 0
|
||||
21:0/0 = 0
|
||||
22:0/0 = 0
|
||||
23:0/0 = 0
|
||||
24:0/0 = 0
|
||||
25:0/0 = 0
|
||||
26:0/0 = 0
|
||||
27:0/0 = 0
|
||||
0:1/0 = 0
|
||||
1:1/0 = 0
|
||||
2:1/0 = 0
|
||||
3:1/0 = 0
|
||||
8:1/0 = 0
|
||||
9:1/0 = 0
|
||||
10:1/0 = 0
|
||||
14:1/0 = 0
|
||||
15:1/0 = 0
|
||||
16:1/0 = 0
|
||||
17:1/0 = 0
|
||||
21:1/0 = 0
|
||||
23:1/0 = 0
|
||||
25:1/0 = 0
|
||||
27:1/0 = 0
|
||||
28:1/0 = 0
|
||||
0:2/0 = 0
|
||||
1:2/0 = 0
|
||||
2:2/0 = 0
|
||||
3:2/0 = 0
|
||||
8:2/0 = 0
|
||||
9:2/0 = 0
|
||||
10:2/0 = 0
|
||||
11:2/0 = 0
|
||||
12:2/0 = 0
|
||||
13:2/0 = 0
|
||||
18:2/0 = 0
|
||||
19:2/0 = 0
|
||||
21:2/0 = 0
|
||||
22:2/0 = 0
|
||||
23:2/0 = 0
|
||||
24:2/0 = 0
|
||||
25:2/0 = 0
|
||||
27:2/0 = 0
|
||||
28:2/0 = 0
|
||||
0:3/0 = 0
|
||||
1:3/0 = 0
|
||||
2:3/0 = 0
|
||||
3:3/0 = 0
|
||||
8:3/0 = 0
|
||||
9:3/0 = 0
|
||||
10:3/0 = 0
|
||||
11:3/0 = 0
|
||||
12:3/0 = 0
|
||||
13:3/0 = 0
|
||||
18:3/0 = 0
|
||||
19:3/0 = 0
|
||||
21:3/0 = 0
|
||||
23:3/0 = 0
|
||||
25:3/0 = 0
|
||||
0:4/0 = 0
|
||||
1:4/0 = 0
|
||||
2:4/0 = 0
|
||||
3:4/0 = 0
|
||||
8:4/0 = 0
|
||||
9:4/0 = 0
|
||||
10:4/0 = 0
|
||||
11:4/0 = 0
|
||||
12:4/0 = 0
|
||||
13:4/0 = 0
|
||||
18:4/0 = 0
|
||||
19:4/0 = 0
|
||||
20:4/0 = 0
|
||||
21:4/0 = 0
|
||||
22:4/0 = 0
|
||||
23:4/0 = 0
|
||||
24:4/0 = 0
|
||||
25:4/0 = 0
|
||||
26:4/0 = 0
|
||||
27:4/0 = 0
|
||||
28:4/0 = 0
|
||||
0:5/0 = 0
|
||||
1:5/0 = 0
|
||||
2:5/0 = 0
|
||||
3:5/0 = 0
|
||||
8:5/0 = 0
|
||||
9:5/0 = 0
|
||||
10:5/0 = 0
|
||||
11:5/0 = 0
|
||||
12:5/0 = 0
|
||||
13:5/0 = 0
|
||||
18:5/0 = 0
|
||||
19:5/0 = 0
|
||||
20:5/0 = 0
|
||||
21:5/0 = 0
|
||||
22:5/0 = 0
|
||||
23:5/0 = 0
|
||||
24:5/0 = 0
|
||||
25:5/0 = 0
|
||||
26:5/0 = 0
|
||||
27:5/0 = 0
|
||||
28:5/0 = 0
|
||||
0:6/0 = 0
|
||||
1:6/0 = 0
|
||||
2:6/0 = 0
|
||||
3:6/0 = 0
|
||||
8:6/0 = 0
|
||||
9:6/0 = 0
|
||||
10:6/0 = 0
|
||||
11:6/0 = 0
|
||||
14:6/0 = 0
|
||||
15:6/0 = 0
|
||||
16:6/0 = 0
|
||||
17:6/0 = 0
|
||||
20:6/0 = 0
|
||||
21:6/0 = 0
|
||||
22:6/0 = 0
|
||||
23:6/0 = 0
|
||||
24:6/0 = 0
|
||||
25:6/0 = 0
|
||||
27:6/0 = 0
|
||||
28:6/0 = 0
|
||||
0:7/0 = 0
|
||||
1:7/0 = 0
|
||||
2:7/0 = 0
|
||||
3:7/0 = 0
|
||||
8:7/0 = 0
|
||||
9:7/0 = 0
|
||||
10:7/0 = 0
|
||||
11:7/0 = 0
|
||||
14:7/0 = 0
|
||||
15:7/0 = 0
|
||||
16:7/0 = 0
|
||||
17:7/0 = 0
|
||||
20:7/0 = 0
|
||||
21:7/0 = 0
|
||||
24:7/0 = 0
|
||||
25:7/0 = 0
|
||||
26:7/0 = 0
|
||||
27:7/0 = 0
|
||||
0:8/0 = 0
|
||||
1:8/0 = 0
|
||||
2:8/0 = 0
|
||||
3:8/0 = 0
|
||||
8:8/0 = 0
|
||||
9:8/0 = 0
|
||||
10:8/0 = 0
|
||||
11:8/0 = 0
|
||||
12:8/0 = 0
|
||||
13:8/0 = 0
|
||||
14:8/0 = 0
|
||||
15:8/0 = 0
|
||||
16:8/0 = 0
|
||||
17:8/0 = 0
|
||||
18:8/0 = 0
|
||||
19:8/0 = 0
|
||||
20:8/0 = 0
|
||||
21:8/0 = 0
|
||||
22:8/0 = 0
|
||||
23:8/0 = 0
|
||||
24:8/0 = 0
|
||||
25:8/0 = 0
|
||||
26:8/0 = 0
|
||||
27:8/0 = 0
|
||||
0:9/0 = 0
|
||||
1:9/0 = 0
|
||||
2:9/0 = 0
|
||||
3:9/0 = 0
|
||||
8:9/0 = 0
|
||||
9:9/0 = 0
|
||||
10:9/0 = 0
|
||||
11:9/0 = 0
|
||||
12:9/0 = 0
|
||||
13:9/0 = 0
|
||||
14:9/0 = 0
|
||||
15:9/0 = 0
|
||||
16:9/0 = 0
|
||||
17:9/0 = 0
|
||||
18:9/0 = 0
|
||||
19:9/0 = 0
|
||||
22:9/0 = 0
|
||||
23:9/0 = 0
|
||||
26:9/0 = 0
|
||||
27:9/0 = 0
|
||||
0:10/0 = 0
|
||||
1:10/0 = 0
|
||||
2:10/0 = 0
|
||||
3:10/0 = 0
|
||||
8:10/0 = 0
|
||||
9:10/0 = 0
|
||||
10:10/0 = 0
|
||||
12:10/0 = 0
|
||||
13:10/0 = 0
|
||||
14:10/0 = 0
|
||||
15:10/0 = 0
|
||||
16:10/0 = 0
|
||||
17:10/0 = 0
|
||||
18:10/0 = 0
|
||||
19:10/0 = 0
|
||||
22:10/0 = 0
|
||||
23:10/0 = 0
|
||||
26:10/0 = 0
|
||||
27:10/0 = 0
|
||||
0:11/0 = 0
|
||||
8:11/0 = 0
|
||||
9:11/0 = 0
|
||||
10:11/0 = 0
|
||||
12:11/0 = 0
|
||||
13:11/0 = 0
|
||||
14:11/0 = 0
|
||||
15:11/0 = 0
|
||||
16:11/0 = 0
|
||||
17:11/0 = 0
|
||||
18:11/0 = 0
|
||||
19:11/0 = 0
|
||||
20:11/0 = 0
|
||||
21:11/0 = 0
|
||||
22:11/0 = 0
|
||||
23:11/0 = 0
|
||||
24:11/0 = 0
|
||||
25:11/0 = 0
|
||||
26:11/0 = 0
|
||||
0:12/0 = 0
|
||||
8:12/0 = 0
|
||||
9:12/0 = 0
|
||||
10:12/0 = 0
|
||||
11:12/0 = 0
|
||||
12:12/0 = 0
|
||||
13:12/0 = 0
|
||||
14:12/0 = 0
|
||||
15:12/0 = 0
|
||||
16:12/0 = 0
|
||||
17:12/0 = 0
|
||||
18:12/0 = 0
|
||||
19:12/0 = 0
|
||||
21:12/0 = 0
|
||||
22:12/0 = 0
|
||||
24:12/0 = 0
|
||||
25:12/0 = 0
|
||||
26:12/0 = 0
|
||||
0:13/0 = 0
|
||||
8:13/0 = 0
|
||||
9:13/0 = 0
|
||||
10:13/0 = 0
|
||||
11:13/0 = 0
|
||||
12:13/0 = 0
|
||||
13:13/0 = 0
|
||||
14:13/0 = 0
|
||||
15:13/0 = 0
|
||||
16:13/0 = 0
|
||||
17:13/0 = 0
|
||||
18:13/0 = 0
|
||||
19:13/0 = 0
|
||||
21:13/0 = 0
|
||||
22:13/0 = 0
|
||||
24:13/0 = 0
|
||||
25:13/0 = 0
|
||||
26:13/0 = 0
|
||||
0:14/0 = 0
|
||||
8:14/0 = 0
|
||||
9:14/0 = 0
|
||||
10:14/0 = 0
|
||||
11:14/0 = 0
|
||||
12:14/0 = 0
|
||||
13:14/0 = 0
|
||||
14:14/0 = 0
|
||||
15:14/0 = 0
|
||||
16:14/0 = 0
|
||||
17:14/0 = 0
|
||||
18:14/0 = 0
|
||||
19:14/0 = 0
|
||||
24:14/0 = 0
|
||||
10:15/0 = 0
|
||||
11:15/0 = 0
|
||||
12:15/0 = 0
|
||||
13:15/0 = 0
|
||||
14:15/0 = 0
|
||||
15:15/0 = 0
|
||||
16:15/0 = 0
|
||||
17:15/0 = 0
|
||||
18:15/0 = 0
|
||||
19:15/0 = 0
|
||||
21:15/0 = 0
|
||||
22:15/0 = 0
|
||||
23:15/0 = 0
|
||||
24:15/0 = 0
|
||||
25:15/0 = 0
|
||||
26:15/0 = 0
|
||||
27:15/0 = 0
|
||||
28:15/0 = 0
|
||||
21:16/0 = 0
|
||||
22:16/0 = 0
|
||||
23:16/0 = 0
|
||||
24:16/0 = 0
|
||||
25:16/0 = 0
|
||||
26:16/0 = 0
|
||||
27:16/0 = 0
|
||||
28:16/0 = 0
|
||||
21:17/0 = 0
|
||||
22:17/0 = 0
|
||||
23:17/0 = 0
|
||||
24:17/0 = 0
|
||||
25:17/0 = 0
|
||||
26:17/0 = 0
|
||||
27:17/0 = 0
|
||||
28:17/0 = 0
|
||||
8:18/0 = 0
|
||||
9:18/0 = 0
|
||||
10:18/0 = 0
|
||||
11:18/0 = 0
|
||||
21:18/0 = 0
|
||||
22:18/0 = 0
|
||||
23:18/0 = 0
|
||||
24:18/0 = 0
|
||||
25:18/0 = 0
|
||||
26:18/0 = 0
|
||||
27:18/0 = 0
|
||||
28:18/0 = 0
|
||||
8:19/0 = 0
|
||||
11:19/0 = 0
|
||||
21:19/0 = 0
|
||||
22:19/0 = 0
|
||||
23:19/0 = 0
|
||||
24:19/0 = 0
|
||||
25:19/0 = 0
|
||||
26:19/0 = 0
|
||||
27:19/0 = 0
|
||||
28:19/0 = 0
|
||||
8:20/0 = 0
|
||||
9:20/0 = 0
|
||||
10:20/0 = 0
|
||||
11:20/0 = 0
|
||||
21:20/0 = 0
|
||||
22:20/0 = 0
|
||||
23:20/0 = 0
|
||||
24:20/0 = 0
|
||||
25:20/0 = 0
|
||||
26:20/0 = 0
|
||||
27:20/0 = 0
|
||||
28:20/0 = 0
|
||||
9:21/0 = 0
|
||||
10:21/0 = 0
|
||||
11:21/0 = 0
|
||||
21:21/0 = 0
|
||||
22:21/0 = 0
|
||||
23:21/0 = 0
|
||||
24:21/0 = 0
|
||||
25:21/0 = 0
|
||||
26:21/0 = 0
|
||||
27:21/0 = 0
|
||||
28:21/0 = 0
|
||||
9:22/0 = 0
|
||||
10:22/0 = 0
|
||||
21:22/0 = 0
|
||||
22:22/0 = 0
|
||||
23:22/0 = 0
|
||||
24:22/0 = 0
|
||||
25:22/0 = 0
|
||||
26:22/0 = 0
|
||||
27:22/0 = 0
|
||||
28:22/0 = 0
|
||||
21:23/0 = 0
|
||||
22:23/0 = 0
|
||||
23:23/0 = 0
|
||||
24:23/0 = 0
|
||||
21:24/0 = 0
|
||||
22:24/0 = 0
|
||||
23:24/0 = 0
|
||||
24:24/0 = 0
|
||||
7:0/size_in_atlas = Vector2i(1, 3)
|
||||
7:0/0 = 0
|
||||
7:3/0 = 0
|
||||
4:3/size_in_atlas = Vector2i(3, 1)
|
||||
4:3/0 = 0
|
||||
4:0/size_in_atlas = Vector2i(3, 3)
|
||||
4:0/0 = 0
|
||||
13:18/size_in_atlas = Vector2i(2, 5)
|
||||
13:18/0 = 0
|
||||
12:20/size_in_atlas = Vector2i(1, 3)
|
||||
12:20/0 = 0
|
||||
15:20/size_in_atlas = Vector2i(1, 3)
|
||||
15:20/0 = 0
|
||||
4:24/size_in_atlas = Vector2i(3, 3)
|
||||
4:24/0 = 0
|
||||
4:27/size_in_atlas = Vector2i(3, 1)
|
||||
4:27/0 = 0
|
||||
7:27/0 = 0
|
||||
7:24/size_in_atlas = Vector2i(1, 3)
|
||||
7:24/0 = 0
|
||||
4:20/size_in_atlas = Vector2i(3, 3)
|
||||
4:20/0 = 0
|
||||
4:23/size_in_atlas = Vector2i(3, 1)
|
||||
4:23/0 = 0
|
||||
7:23/0 = 0
|
||||
7:20/size_in_atlas = Vector2i(1, 3)
|
||||
7:20/0 = 0
|
||||
4:16/size_in_atlas = Vector2i(3, 3)
|
||||
4:16/0 = 0
|
||||
4:19/size_in_atlas = Vector2i(3, 1)
|
||||
4:19/0 = 0
|
||||
7:19/0 = 0
|
||||
7:16/size_in_atlas = Vector2i(1, 3)
|
||||
7:16/0 = 0
|
||||
7:15/0 = 0
|
||||
4:15/size_in_atlas = Vector2i(3, 1)
|
||||
4:15/0 = 0
|
||||
4:12/size_in_atlas = Vector2i(3, 3)
|
||||
4:12/0 = 0
|
||||
7:12/size_in_atlas = Vector2i(1, 3)
|
||||
7:12/0 = 0
|
||||
4:4/size_in_atlas = Vector2i(3, 3)
|
||||
4:4/0 = 0
|
||||
7:4/size_in_atlas = Vector2i(1, 3)
|
||||
7:4/0 = 0
|
||||
7:7/0 = 0
|
||||
4:7/size_in_atlas = Vector2i(3, 1)
|
||||
4:7/0 = 0
|
||||
4:8/size_in_atlas = Vector2i(3, 3)
|
||||
4:8/0 = 0
|
||||
7:8/size_in_atlas = Vector2i(1, 3)
|
||||
7:8/0 = 0
|
||||
7:11/0 = 0
|
||||
4:11/size_in_atlas = Vector2i(3, 1)
|
||||
4:11/0 = 0
|
||||
8:15/size_in_atlas = Vector2i(2, 3)
|
||||
8:15/0 = 0
|
||||
10:16/size_in_atlas = Vector2i(3, 2)
|
||||
10:16/0 = 0
|
||||
13:16/size_in_atlas = Vector2i(3, 2)
|
||||
13:16/0 = 0
|
||||
16:16/size_in_atlas = Vector2i(2, 2)
|
||||
16:16/0 = 0
|
||||
14:2/size_in_atlas = Vector2i(4, 4)
|
||||
14:2/0 = 0
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_t3bbo"]
|
||||
sources/1 = SubResource("TileSetAtlasSource_s55i2")
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource("1_ysxum")
|
||||
|
||||
[node name="View" type="Node2D" parent="."]
|
||||
script = ExtResource("2_rg0qh")
|
||||
[node name="World" type="TileMap" parent="."]
|
||||
tile_set = SubResource("TileSet_t3bbo")
|
||||
format = 2
|
||||
layer_0/name = "Buildings"
|
||||
script = ExtResource("3_6q5ju")
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
[node name="CameraZoom2D" parent="World" instance=ExtResource("4_rx82t")]
|
||||
position = Vector2(960, 536)
|
||||
limit_left = -40000
|
||||
limit_top = -40000
|
||||
limit_right = 40000
|
||||
limit_bottom = 40000
|
||||
editor_draw_limits = true
|
||||
|
||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Control" type="Control" parent="UILayer"]
|
||||
layout_mode = 3
|
||||
anchor_right = 0.193
|
||||
anchor_bottom = 0.299
|
||||
offset_left = 265.0
|
||||
offset_top = 243.0
|
||||
offset_right = 82.664
|
||||
offset_bottom = 89.248
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
grow_horizontal = 2
|
||||
script = ExtResource("3_1t1c8")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="ConstructionPanel" type="Panel" parent="Control"]
|
||||
[node name="ConstructionPanel" type="Panel" parent="UILayer/Control"]
|
||||
custom_minimum_size = Vector2(500, 100)
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
offset_left = -248.0
|
||||
offset_right = 252.0
|
||||
offset_bottom = 120.0
|
||||
|
||||
[node name="button_residental" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_residental" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_commercial" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_commercial" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_industrial" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_industrial" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_roads" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_roads" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_demolish" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_demolish" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_services" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_services" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[node name="button_social" type="Button" parent="Control/ConstructionPanel"]
|
||||
[node name="button_social" type="Button" parent="UILayer/Control/ConstructionPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
|
||||
[connection signal="button_pressed" from="Control" to="View" method="_on_control_button_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_residental" to="Control" method="_on_button_residental_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_commercial" to="Control" method="_on_button_commercial_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_industrial" to="Control" method="_on_button_industrial_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_roads" to="Control" method="_on_button_roads_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_demolish" to="Control" method="_on_button_demolish_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_services" to="Control" method="_on_button_services_pressed"]
|
||||
[connection signal="pressed" from="Control/ConstructionPanel/button_social" to="Control" method="_on_button_social_pressed"]
|
||||
[node name="DebugInfo" type="Label" parent="UILayer/Control"]
|
||||
offset_left = 568.0
|
||||
offset_top = 24.0
|
||||
offset_right = 928.0
|
||||
offset_bottom = 280.0
|
||||
|
||||
[connection signal="button_pressed" from="UILayer/Control" to="World" method="_on_control_button_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_residental" to="UILayer/Control" method="_on_button_residental_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_commercial" to="UILayer/Control" method="_on_button_commercial_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_industrial" to="UILayer/Control" method="_on_button_industrial_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_roads" to="UILayer/Control" method="_on_button_roads_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_demolish" to="UILayer/Control" method="_on_button_demolish_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_services" to="UILayer/Control" method="_on_button_services_pressed"]
|
||||
[connection signal="pressed" from="UILayer/Control/ConstructionPanel/button_social" to="UILayer/Control" method="_on_button_social_pressed"]
|
||||
|
|
40
scripts/CameraZoom2D.gd
Normal file
40
scripts/CameraZoom2D.gd
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Class handles the camera zoom and movement in the game
|
||||
class_name CameraZoom2D
|
||||
extends Camera2D
|
||||
|
||||
var _zoom_level : float = 1.0 : set = _set_zoom_level
|
||||
var is_dragging_camera = false
|
||||
var tween
|
||||
|
||||
func _set_zoom_level(value: float) -> void:
|
||||
_zoom_level = clamp(value, Globals.CAMERA_MIN_ZOOM_LEVEL, Globals.CAMERA_MAX_ZOOM_LEVEL)
|
||||
|
||||
#interpolate frames between zoom levels to make zooming look smoother
|
||||
tween = get_tree().create_tween()
|
||||
tween.tween_property(
|
||||
self,
|
||||
"zoom",
|
||||
Vector2(_zoom_level, _zoom_level),
|
||||
Globals.CAMERA_ZOOM_DURATION
|
||||
)
|
||||
|
||||
func _unhandled_input(event):
|
||||
# camera zooming
|
||||
if event.is_action_pressed("camera_zoom_in"):
|
||||
_set_zoom_level(_zoom_level - Globals.CAMERA_ZOOM_FACTOR)
|
||||
elif event.is_action_pressed("camera_zoom_out"):
|
||||
_set_zoom_level(_zoom_level + Globals.CAMERA_ZOOM_DURATION)
|
||||
|
||||
# camera dragging
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if !is_dragging_camera and event.pressed:
|
||||
is_dragging_camera = true
|
||||
if is_dragging_camera and !event.pressed:
|
||||
is_dragging_camera = false
|
||||
|
||||
if event is InputEventMouseMotion and is_dragging_camera:
|
||||
if self.position != event.position:
|
||||
tween = get_tree().create_tween()
|
||||
tween.tween_property(self, "property", Vector2(self.position, event.position), Globals.CAMERA_ZOOM_DURATION)
|
||||
else:
|
||||
self.position = event.position * Globals.CAMERA_DRAG_MULTI
|
|
@ -3,8 +3,7 @@ extends Control
|
|||
# var view = get_node("../View")
|
||||
|
||||
signal button_pressed(button_name)
|
||||
|
||||
var BUTTON_SIZE = Vector2i(50,50)
|
||||
@onready var debug_info = get_node("DebugInfo")
|
||||
|
||||
# name, position
|
||||
var buttons = {
|
||||
|
@ -19,17 +18,11 @@ var buttons = {
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
adjust_construction_panel()
|
||||
$ConstructionPanel.set_size(Vector2(500, 120))
|
||||
create_buttons()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
||||
func adjust_construction_panel():
|
||||
$ConstructionPanel.set_size(Vector2i(500, 120))
|
||||
$ConstructionPanel.set_position(Vector2i(0, -200))
|
||||
debug_info.set_text(str(get_viewport().get_mouse_position()))
|
||||
|
||||
# defines construction toolbar buttons
|
||||
func create_buttons():
|
||||
|
@ -40,7 +33,7 @@ func create_buttons():
|
|||
if(!node_path):
|
||||
push_error("Error: Button '" + button + "' not found when trying to set it's properties in Control.gd!")
|
||||
|
||||
node_path.set_size(BUTTON_SIZE)
|
||||
node_path.set_size(Globals.GUI_BUILD_BUTTON_SIZE)
|
||||
node_path.set_position(values[0])
|
||||
node_path.set_anchor(SIDE_TOP, anchor_top)
|
||||
node_path.set_text(values[1])
|
||||
|
|
|
@ -4,6 +4,10 @@ const SCENE_PATH:String = "res://scenes/"
|
|||
const ART_PATH:String = "res://art/"
|
||||
const SCRIPT_PATH:String = "res://scripts"
|
||||
|
||||
const GUI_BUILD_BUTTON_SIZE_X: int = 50
|
||||
const GUI_BUILD_BUTTON_SIZE_Y: int = 50
|
||||
const GUI_BUILD_BUTTON_SIZE: Vector2i = Vector2i(GUI_BUILD_BUTTON_SIZE_X,GUI_BUILD_BUTTON_SIZE_Y)
|
||||
|
||||
const DEFAULT_X_RES:int = 1920
|
||||
const DEFAULT_Y_RES:int = 1080
|
||||
|
||||
|
@ -15,3 +19,9 @@ const TYPE_SOCIAL = "social"
|
|||
const TYPE_POWERPLANT = "powerplant"
|
||||
const TYPE_ROADS = "roads"
|
||||
const TYPE_DEMOLISH = "demolish"
|
||||
|
||||
const CAMERA_MIN_ZOOM_LEVEL: float = 0.5
|
||||
const CAMERA_MAX_ZOOM_LEVEL: float = 2.0
|
||||
const CAMERA_ZOOM_FACTOR: float = 0.1
|
||||
const CAMERA_ZOOM_DURATION: float = 0.1
|
||||
const CAMERA_DRAG_MULTI:float = 2.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# - "Cube Clicker 2000" where you click a spot and a cube appears there.
|
||||
# - Then add different shapes or colors of cubes.
|
||||
# - Then clamp their positions to be on a grid.
|
||||
# OK - "Cube Clicker 2000" where you click a spot and a cube appears there.
|
||||
# OK - Then add different shapes or colors of cubes.
|
||||
# OK - Then clamp their positions to be on a grid.
|
||||
# - Then make it so that when you add yellow cubes, yellow desire meter goes down and green meter goes up.
|
||||
# - Then click a bunch of grey cubes in a row and have them automatically flatten out into flat grey cubes (roads).
|
||||
# - Then click and drag to draw the lines of grey cubes.
|
||||
|
|
8
scripts/Snippets.gd
Normal file
8
scripts/Snippets.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Node
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func placeholder():
|
||||
# print all children of the node
|
||||
for _i in self.get_children():
|
||||
print(_i
|
|
@ -1,34 +0,0 @@
|
|||
extends Node2D
|
||||
|
||||
var gui
|
||||
var building
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_control_button_pressed(button_name):
|
||||
# create new building, in Building node it is attached to mouse cursor
|
||||
var scene = load(Globals.SCENE_PATH + "Building.tscn")
|
||||
building = scene.instantiate()
|
||||
add_child(building)
|
||||
|
||||
#for _i in self.get_children():
|
||||
# print(_i)
|
||||
|
||||
# stop processing the sprite (fix it in place). no idea if it is a good idea yet..
|
||||
|
||||
|
||||
# print(button_name + " button pressed in Control! :-0")
|
||||
|
||||
func _input(event):
|
||||
# places the building on cursor. a bad way!
|
||||
if Input.is_anything_pressed() and building != null:
|
||||
building.set_process(false)
|
||||
building = null
|
||||
# print(event.as_text())
|
62
scripts/World.gd
Normal file
62
scripts/World.gd
Normal file
|
@ -0,0 +1,62 @@
|
|||
extends TileMap
|
||||
|
||||
var building : bool = false
|
||||
var building_type: String
|
||||
var tilemap: Vector2i
|
||||
#var scene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_control_button_pressed(type):
|
||||
# create new building, in Building node it is attached to mouse cursor
|
||||
#scene = load(Globals.SCENE_PATH + "Building.tscn")
|
||||
#building = scene.instantiate()
|
||||
#add_child(building)
|
||||
self.building = true
|
||||
self.building_type = type
|
||||
|
||||
#print(button_name + " button pressed in Control! :-0")
|
||||
pass
|
||||
|
||||
func _input(event):
|
||||
# place the building
|
||||
if event.is_action_pressed("place_building") and building != false:
|
||||
# stop processing the sprite (fix it in place). no idea if it is a good idea yet..
|
||||
#building.set_process(false)
|
||||
building = false
|
||||
place_building_to_map()
|
||||
|
||||
# cancel placement
|
||||
if event.is_action_pressed("cancel"):
|
||||
if building != false:
|
||||
pass
|
||||
|
||||
|
||||
func place_building_to_map():
|
||||
|
||||
match building_type:
|
||||
Globals.TYPE_RESIDENTIAL:
|
||||
tilemap = Vector2i(4,4)
|
||||
Globals.TYPE_COMMERCIAL:
|
||||
tilemap = Vector2i(4,12)
|
||||
Globals.TYPE_INDUSTRIAL:
|
||||
tilemap = Vector2i(4,20)
|
||||
Globals.TYPE_ROADS:
|
||||
tilemap = Vector2i(14,2)
|
||||
Globals.TYPE_DEMOLISH:
|
||||
tilemap = Vector2i(4,4)
|
||||
Globals.TYPE_SERVICES:
|
||||
tilemap = Vector2i(4,8)
|
||||
Globals.TYPE_SOCIAL:
|
||||
tilemap = Vector2i(4,0)
|
||||
_: #default
|
||||
tilemap = Vector2i(16,16)
|
||||
|
||||
set_cell(0, local_to_map(get_viewport().get_mouse_position()), 1, tilemap, 0)
|
Loading…
Add table
Add a link
Reference in a new issue