LD56 is over. This is the game.
This commit is contained in:
218
player/pla4A66.tmp
Normal file
218
player/pla4A66.tmp
Normal file
@@ -0,0 +1,218 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://chjbet2mt6llt"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/player.gd" id="1_whwfs"]
|
||||
[ext_resource type="Script" path="res://player/player_camera.gd" id="2_io7bq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl3j7ai85use8" path="res://assets/textures/minimap_surrounding.png" id="3_07gwb"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1ah7x5u22gy8" path="res://assets/textures/bublle.png" id="4_5wskw"]
|
||||
[ext_resource type="Texture2D" uid="uid://dk7y821oncja0" path="res://assets/textures/mouse.png" id="5_hdsov"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_2won1"]
|
||||
background_mode = 1
|
||||
background_color = Color(0.422875, 0.856206, 7.70092e-07, 1)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_3m02s"]
|
||||
script/source = "extends Camera3D
|
||||
|
||||
@export var player_camera:PlayerCamera
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
global_position = player_camera.global_position
|
||||
global_position.y = 50
|
||||
global_rotation.y = player_camera.global_rotation.y
|
||||
"
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_0u73m"]
|
||||
font_size = 15
|
||||
font_color = Color(1, 0.0823529, 0.0823529, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_lw1xe"]
|
||||
font_size = 10
|
||||
font_color = Color(1, 0.0823529, 0.0823529, 1)
|
||||
|
||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_8sg2e"]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_y76dc"]
|
||||
texture = ExtResource("4_5wskw")
|
||||
texture_margin_left = 3.0
|
||||
texture_margin_top = 3.0
|
||||
texture_margin_right = 3.0
|
||||
texture_margin_bottom = 4.0
|
||||
region_rect = Rect2(0, 0, 11, 11)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_dq8wh"]
|
||||
script/source = "extends HSlider
|
||||
|
||||
|
||||
@export var player_camera:PlayerCamera
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
value = player_camera.move_speed
|
||||
"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_6sqcg"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_uh3ob"]
|
||||
gradient = SubResource("Gradient_6sqcg")
|
||||
fill = 1
|
||||
fill_from = Vector2(1, 0)
|
||||
fill_to = Vector2(1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_2v41q"]
|
||||
texture = SubResource("GradientTexture2D_uh3ob")
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ctm04"]
|
||||
font_size = 15
|
||||
font_color = Color(1, 0, 0, 1)
|
||||
|
||||
[node name="Player" type="Node"]
|
||||
script = ExtResource("1_whwfs")
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0189449, 0, -4.86374e-05)
|
||||
cull_mask = 1047553
|
||||
current = true
|
||||
script = ExtResource("2_io7bq")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, 0, 0)
|
||||
debug_shape_custom_color = Color(0, 0.633333, 1, 1)
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
offset_left = 915.0
|
||||
offset_top = 400.0
|
||||
offset_right = 1291.0
|
||||
offset_bottom = 716.0
|
||||
texture = ExtResource("3_07gwb")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="TextureRect"]
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -128.5
|
||||
offset_top = -112.0
|
||||
offset_right = 126.5
|
||||
offset_bottom = 143.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 0
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="TextureRect/SubViewportContainer"]
|
||||
handle_input_locally = false
|
||||
size = Vector2i(255, 255)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="TextureRect/SubViewportContainer/SubViewport" node_paths=PackedStringArray("player_camera")]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.0189449, 50, -4.86374e-05)
|
||||
cull_mask = 1048574
|
||||
environment = SubResource("Environment_2won1")
|
||||
projection = 1
|
||||
current = true
|
||||
size = 150.0
|
||||
script = SubResource("GDScript_3m02s")
|
||||
player_camera = NodePath("../../../../PlayerCamera")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="TextureRect"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 21.0
|
||||
offset_top = -39.0
|
||||
offset_right = -25.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="Label" type="Label" parent="TextureRect/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Camera speed"
|
||||
label_settings = SubResource("LabelSettings_0u73m")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TextureRect/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="TextureRect/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "<- Scroll ->"
|
||||
label_settings = SubResource("LabelSettings_lw1xe")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="TextureRect/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("player_camera")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_icons/grabber_disabled = SubResource("PlaceholderTexture2D_8sg2e")
|
||||
theme_override_styles/grabber_area = SubResource("StyleBoxTexture_y76dc")
|
||||
min_value = 3.0
|
||||
max_value = 50.0
|
||||
value = 10.0
|
||||
editable = false
|
||||
scrollable = false
|
||||
script = SubResource("GDScript_dq8wh")
|
||||
player_camera = NodePath("../../../../PlayerCamera")
|
||||
|
||||
[node name="Ants" type="Node" parent="."]
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -166.0
|
||||
offset_bottom = 168.0
|
||||
grow_horizontal = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxTexture_2v41q")
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -135.0
|
||||
offset_top = 29.0
|
||||
offset_right = -52.0
|
||||
offset_bottom = 161.0
|
||||
grow_horizontal = 0
|
||||
texture = ExtResource("5_hdsov")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
offset_left = -28.0
|
||||
offset_top = -1.0
|
||||
offset_right = 21.0
|
||||
offset_bottom = 24.0
|
||||
text = "Select"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
|
||||
[node name="Label2" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -54.5
|
||||
offset_top = -25.0
|
||||
offset_right = 54.5
|
||||
grow_horizontal = 2
|
||||
text = "Turn camera"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
|
||||
[node name="Label3" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -23.0
|
||||
offset_right = 46.0
|
||||
offset_bottom = 25.0
|
||||
grow_horizontal = 0
|
||||
text = "Interact"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
horizontal_alignment = 1
|
||||
58
player/player.gd
Normal file
58
player/player.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
class_name Player extends Node
|
||||
|
||||
const RAY_LENGTH = 1000.0
|
||||
|
||||
static var instance:Player
|
||||
|
||||
@onready var raycast := $RayCast3D as RayCast3D
|
||||
|
||||
var selected_unit:Ant
|
||||
|
||||
func _init() -> void:
|
||||
instance = self
|
||||
|
||||
func _unhandled_input(event:InputEvent)->void:
|
||||
if not event is InputEventMouseButton: return
|
||||
var mouse_event := event as InputEventMouseButton
|
||||
if not mouse_event.pressed: return
|
||||
if mouse_event.button_index == MOUSE_BUTTON_MIDDLE: return
|
||||
if mouse_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
input_left_mouse_click()
|
||||
if mouse_event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
input_right_mouse_click()
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
process_raycast()
|
||||
|
||||
func input_left_mouse_click()->void:
|
||||
var collider := raycast.get_collider()
|
||||
selected_unit = null
|
||||
if collider is Ant:
|
||||
var player_unit := collider as Ant
|
||||
selected_unit = player_unit
|
||||
else:
|
||||
PlayerCamp.instance.on_interact(
|
||||
raycast.get_collider(),
|
||||
raycast.get_collision_point()
|
||||
)
|
||||
|
||||
func input_right_mouse_click()->void:
|
||||
if selected_unit != null:
|
||||
selected_unit.on_interact(
|
||||
raycast.get_collider(),
|
||||
raycast.get_collision_point()
|
||||
)
|
||||
else:
|
||||
if PlayerCamp.instance.active_indicator != null:
|
||||
PlayerCamp.instance.active_indicator.queue_free()
|
||||
|
||||
|
||||
func process_raycast()->void:
|
||||
var camera := get_viewport().get_camera_3d()
|
||||
var mouse_position := get_viewport().get_mouse_position()
|
||||
var from := camera.project_ray_origin(mouse_position)
|
||||
var to := from + camera.project_ray_normal(mouse_position) * RAY_LENGTH
|
||||
|
||||
raycast.global_position = from
|
||||
raycast.target_position = to
|
||||
raycast.force_raycast_update()
|
||||
201
player/player.tscn
Normal file
201
player/player.tscn
Normal file
@@ -0,0 +1,201 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://chjbet2mt6llt"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/player.gd" id="1_whwfs"]
|
||||
[ext_resource type="Script" path="res://player/player_camera.gd" id="2_io7bq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl3j7ai85use8" path="res://assets/textures/minimap_surrounding.png" id="3_07gwb"]
|
||||
[ext_resource type="Texture2D" uid="uid://cday33lyy4qqw" path="res://assets/textures/camera_icon.png" id="3_shutu"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1b7efqg14tt3" path="res://entities/buildings/player_camp.tscn" id="5_c7f30"]
|
||||
[ext_resource type="Texture2D" uid="uid://dk7y821oncja0" path="res://assets/textures/mouse.png" id="5_hdsov"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_2won1"]
|
||||
background_mode = 1
|
||||
background_color = Color(0.422875, 0.856206, 7.70092e-07, 1)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_3m02s"]
|
||||
script/source = "extends Camera3D
|
||||
|
||||
@export var player_camera:PlayerCamera
|
||||
|
||||
func _ready() -> void:
|
||||
global_position.y = 1000
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
return
|
||||
#global_position = player_camera.global_position
|
||||
#global_position.y = 50
|
||||
global_rotation.y = player_camera.global_rotation.y
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mouseEvent := event as InputEventMouseButton
|
||||
mouseEvent.button_index = MOUSE_BUTTON_LEFT
|
||||
var newpos := project_ray_origin(mouseEvent.global_position)
|
||||
newpos.y = player_camera.global_position.y
|
||||
player_camera.global_position = newpos
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_k784c"]
|
||||
script/source = "extends Label
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
text = \"Current Score %0d\" % Game.instance.score
|
||||
"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_6sqcg"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_uh3ob"]
|
||||
gradient = SubResource("Gradient_6sqcg")
|
||||
fill = 1
|
||||
fill_from = Vector2(1, 0)
|
||||
fill_to = Vector2(1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_2v41q"]
|
||||
texture = SubResource("GradientTexture2D_uh3ob")
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ctm04"]
|
||||
font_size = 15
|
||||
font_color = Color(1, 0, 0, 1)
|
||||
|
||||
[node name="Player" type="Node"]
|
||||
script = ExtResource("1_whwfs")
|
||||
|
||||
[node name="PlayerCamera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0189449, 0, -4.86374e-05)
|
||||
cull_mask = 1047553
|
||||
current = true
|
||||
script = ExtResource("2_io7bq")
|
||||
|
||||
[node name="Sprite3D2" type="Sprite3D" parent="PlayerCamera"]
|
||||
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 60, 0)
|
||||
layers = 2
|
||||
billboard = 1
|
||||
texture = ExtResource("3_shutu")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, 0, 0)
|
||||
debug_shape_custom_color = Color(0, 0.633333, 1, 1)
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
offset_left = 915.0
|
||||
offset_top = 400.0
|
||||
offset_right = 1291.0
|
||||
offset_bottom = 716.0
|
||||
texture = ExtResource("3_07gwb")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="TextureRect"]
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -128.5
|
||||
offset_top = -112.0
|
||||
offset_right = 126.5
|
||||
offset_bottom = 143.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 0
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="TextureRect/SubViewportContainer"]
|
||||
handle_input_locally = false
|
||||
size = Vector2i(255, 255)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="TextureRect/SubViewportContainer/SubViewport" node_paths=PackedStringArray("player_camera")]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
||||
cull_mask = 1048574
|
||||
environment = SubResource("Environment_2won1")
|
||||
projection = 1
|
||||
current = true
|
||||
size = 200.0
|
||||
script = SubResource("GDScript_3m02s")
|
||||
player_camera = NodePath("../../../../PlayerCamera")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="TextureRect"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 21.0
|
||||
offset_top = -39.0
|
||||
offset_right = -25.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TextureRect/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="TextureRect/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Current score:"
|
||||
script = SubResource("GDScript_k784c")
|
||||
|
||||
[node name="Ants" type="Node" parent="."]
|
||||
|
||||
[node name="Buildings" type="Node" parent="."]
|
||||
|
||||
[node name="PlayerCamp" parent="Buildings" instance=ExtResource("5_c7f30")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.093426, -0.0590961)
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -166.0
|
||||
offset_bottom = 168.0
|
||||
grow_horizontal = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxTexture_2v41q")
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -135.0
|
||||
offset_top = 29.0
|
||||
offset_right = -52.0
|
||||
offset_bottom = 161.0
|
||||
grow_horizontal = 0
|
||||
texture = ExtResource("5_hdsov")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
offset_left = -28.0
|
||||
offset_top = -1.0
|
||||
offset_right = 21.0
|
||||
offset_bottom = 24.0
|
||||
text = "Select"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
|
||||
[node name="Label2" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -54.5
|
||||
offset_top = -25.0
|
||||
offset_right = 54.5
|
||||
grow_horizontal = 2
|
||||
text = "Turn camera"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
|
||||
[node name="Label3" type="Label" parent="Panel/TextureRect2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -23.0
|
||||
offset_right = 46.0
|
||||
offset_bottom = 25.0
|
||||
grow_horizontal = 0
|
||||
text = "Interact"
|
||||
label_settings = SubResource("LabelSettings_ctm04")
|
||||
horizontal_alignment = 1
|
||||
30
player/player_camera.gd
Normal file
30
player/player_camera.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
class_name PlayerCamera extends Camera3D
|
||||
|
||||
var move_speed : float = 10
|
||||
var tilt_speed : float = 2
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
process_movement(delta)
|
||||
process_camera_tilt(delta)
|
||||
|
||||
func process_movement(delta:float) -> void:
|
||||
var input_vector := Vector3.ZERO;
|
||||
input_vector += -global_basis.z * Input.get_axis("move_back", "move_forward")
|
||||
input_vector += global_basis.x * Input.get_axis("move_left", "move_right")
|
||||
input_vector.y = 0;
|
||||
input_vector += Vector3.UP * Input.get_axis("move_down", "move_up")
|
||||
|
||||
var speed_scaler := lerpf(0.3, 3, global_position.y/20)
|
||||
global_position += input_vector * move_speed * speed_scaler * delta
|
||||
position.y = clampf(position.y, 2, 20)
|
||||
|
||||
func process_camera_tilt(delta: float) -> void:
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
var mouse_move := -Input.get_last_mouse_velocity()
|
||||
mouse_move /= get_viewport().size as Vector2
|
||||
mouse_move *= tilt_speed * delta
|
||||
rotation.y = rotation.y + mouse_move.x
|
||||
rotation.x =clampf(rotation.x + mouse_move.y, -PI/2, 0)
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
Reference in New Issue
Block a user