Add base scenes; add 2D map, zoom in/out, movement in this map
This commit is contained in:
parent
d781605806
commit
a3c98163ba
5
assets/sounds/.gitignore
vendored
Normal file
5
assets/sounds/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
|
|
||||||
BIN
assets/textures/US.jpg
Normal file
BIN
assets/textures/US.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 228 KiB |
41
assets/textures/US.jpg.import
Normal file
41
assets/textures/US.jpg.import
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dyiw2b842pin3"
|
||||||
|
path.s3tc="res://.godot/imported/US.jpg-a8d40fbb3cf4b6ef7949b3d74f1191b3.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/textures/US.jpg"
|
||||||
|
dest_files=["res://.godot/imported/US.jpg-a8d40fbb3cf4b6ef7949b3d74f1191b3.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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=0
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
[gd_scene format=3 uid="uid://yfu77mws733s"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://1fu1sydbh2rd" path="res://main.gd" id="1_ig7tw"]
|
|
||||||
|
|
||||||
[node name="Main" type="Node" unique_id=2064521053]
|
|
||||||
script = ExtResource("1_ig7tw")
|
|
||||||
1
player.gd.uid
Normal file
1
player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dh4v5wgj7ec1n
|
||||||
|
|
@ -11,6 +11,7 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="conquista-mort"
|
config/name="conquista-mort"
|
||||||
|
run/main_scene="uid://yfu77mws733s"
|
||||||
config/features=PackedStringArray("4.7", "GL Compatibility")
|
config/features=PackedStringArray("4.7", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|
@ -19,6 +20,24 @@ config/icon="res://icon.svg"
|
||||||
window/stretch/mode="canvas_items"
|
window/stretch/mode="canvas_items"
|
||||||
window/stretch/aspect="expand"
|
window/stretch/aspect="expand"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
dragging={
|
||||||
|
"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
zoom-in={
|
||||||
|
"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
zoom-out={
|
||||||
|
"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
|
||||||
3
scenes/game_ui.tscn
Normal file
3
scenes/game_ui.tscn
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[gd_scene format=3 uid="uid://dw0jc5fh4411n"]
|
||||||
|
|
||||||
|
[node name="GameUI" type="CanvasLayer" unique_id=2075735181]
|
||||||
3
scenes/hud.tscn
Normal file
3
scenes/hud.tscn
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[gd_scene format=3 uid="uid://beshh12linnpj"]
|
||||||
|
|
||||||
|
[node name="HUD" type="CanvasLayer" unique_id=1561272234]
|
||||||
18
scenes/main.tscn
Normal file
18
scenes/main.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene format=3 uid="uid://yfu77mws733s"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cb300e3rkwwpm" path="res://scripts/main.gd" id="1_ig7tw"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c5b3ssno3qjsc" path="res://scenes/map.tscn" id="2_0xm2m"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://beshh12linnpj" path="res://scenes/hud.tscn" id="2_lquwl"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dw0jc5fh4411n" path="res://scenes/game_ui.tscn" id="3_7mycd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://yjpa04jof6bk" path="res://scenes/player.tscn" id="3_h2yge"]
|
||||||
|
|
||||||
|
[node name="Main" type="Node" unique_id=2064521053]
|
||||||
|
script = ExtResource("1_ig7tw")
|
||||||
|
|
||||||
|
[node name="HUD" parent="." unique_id=1561272234 instance=ExtResource("2_lquwl")]
|
||||||
|
|
||||||
|
[node name="GameUI" parent="." unique_id=2075735181 instance=ExtResource("3_7mycd")]
|
||||||
|
|
||||||
|
[node name="Map" parent="." unique_id=2049311125 instance=ExtResource("2_0xm2m")]
|
||||||
|
|
||||||
|
[node name="Player" parent="." unique_id=815405141 instance=ExtResource("3_h2yge")]
|
||||||
19
scenes/map.tscn
Normal file
19
scenes/map.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene format=3 uid="uid://c5b3ssno3qjsc"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dyiw2b842pin3" path="res://assets/textures/US.jpg" id="1_c7s6e"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_kwsvg"]
|
||||||
|
|
||||||
|
[node name="Map" type="Node3D" unique_id=2049311125]
|
||||||
|
|
||||||
|
[node name="Map2D" type="Sprite3D" parent="." unique_id=2106451994]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||||
|
texture = ExtResource("1_c7s6e")
|
||||||
|
|
||||||
|
[node name="Node" type="Area3D" parent="." unique_id=328338387]
|
||||||
|
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Node" unique_id=960609839]
|
||||||
|
shape = SubResource("SphereShape3D_kwsvg")
|
||||||
|
|
||||||
|
[node name="CSGSphere3D" type="CSGSphere3D" parent="Node" unique_id=1383250462]
|
||||||
9
scenes/player.tscn
Normal file
9
scenes/player.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene format=3 uid="uid://yjpa04jof6bk"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cl2ml4raypnmo" path="res://scripts/player.gd" id="1_4flbx"]
|
||||||
|
|
||||||
|
[node name="Player" type="Node3D" unique_id=815405141]
|
||||||
|
script = ExtResource("1_4flbx")
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="." unique_id=1882427094]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2, 0)
|
||||||
|
|
@ -5,7 +5,6 @@ extends Node
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
1
scripts/main.gd.uid
Normal file
1
scripts/main.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cb300e3rkwwpm
|
||||||
42
scripts/player.gd
Normal file
42
scripts/player.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
var center = Vector3.ZERO
|
||||||
|
var screen_size
|
||||||
|
@export var LIMIT_ZOOM = [1.0, 4.0]
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
$Camera3D.position.y = 2.0
|
||||||
|
screen_size = get_viewport().get_visible_rect().size
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
camera_player_movement()
|
||||||
|
camera_player_zoom()
|
||||||
|
|
||||||
|
func camera_player_movement():
|
||||||
|
var mouse_pos = get_viewport().get_mouse_position()
|
||||||
|
|
||||||
|
# Récupération de la position de la souris par rapport aux mondes
|
||||||
|
# En tirant un raycast
|
||||||
|
var camera = get_viewport().get_camera_3d()
|
||||||
|
var from = camera.project_ray_origin(mouse_pos)
|
||||||
|
var dir = camera.project_ray_normal(mouse_pos)
|
||||||
|
var mouse_pos_world = Plane(Vector3.UP, 0).intersects_ray(from, dir)
|
||||||
|
|
||||||
|
var dragging = Input.is_action_pressed("dragging")
|
||||||
|
|
||||||
|
if (dragging && center == Vector3.ZERO):
|
||||||
|
center = mouse_pos_world
|
||||||
|
elif (dragging):
|
||||||
|
var distance_center_mouse = center - mouse_pos_world
|
||||||
|
$Camera3D.position.x += distance_center_mouse.x
|
||||||
|
$Camera3D.position.z += distance_center_mouse.z
|
||||||
|
elif (not dragging):
|
||||||
|
center = Vector3.ZERO
|
||||||
|
|
||||||
|
func camera_player_zoom():
|
||||||
|
if (Input.is_action_just_released("zoom-in")):
|
||||||
|
$Camera3D.position.y -= 0.1
|
||||||
|
elif (Input.is_action_just_released("zoom-out")):
|
||||||
|
$Camera3D.position.y += 0.1
|
||||||
|
# Mettre une limite au zomm de la caméra
|
||||||
|
$Camera3D.position.y = clamp($Camera3D.position.y, LIMIT_ZOOM[0], LIMIT_ZOOM[1])
|
||||||
1
scripts/player.gd.uid
Normal file
1
scripts/player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cl2ml4raypnmo
|
||||||
Loading…
Reference in a new issue