Final touches

This commit is contained in:
2024-06-12 17:51:29 +02:00
parent 9cfd9e0200
commit 965a56c7ad
8 changed files with 120 additions and 77 deletions

6
FPS.gd Normal file
View File

@@ -0,0 +1,6 @@
extends Label
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var fps = Engine.get_frames_per_second()
text = "FPS: %d" % fps

6
Mob.gd
View File

@@ -10,7 +10,7 @@ func _physics_process(delta):
func initialize(start_position, player_position):
# Look to the player
look_at_from_position(start_position, player_position, Vector3.UP)
look_at_horizontal(start_position, player_position)
# But rotate a little bit
rotate_y(randf_range(-PI / 4, PI / 4))
# Set random speed
@@ -21,6 +21,10 @@ func initialize(start_position, player_position):
$AnimationPlayer.speed_scale = random_speed / min_speed
func look_at_horizontal(start_position: Vector3, target_position: Vector3):
var target_horizontal_position = Vector3(target_position.x, start_position.y, target_position.z)
look_at_from_position(start_position, target_horizontal_position, Vector3.UP)
func squash():
squashed.emit()
queue_free()

View File

@@ -14,14 +14,10 @@ func _physics_process(delta):
var direction = Vector3.ZERO
# Check inputs
if Input.is_action_pressed("move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
direction.x -= 1
if Input.is_action_pressed("move_back"):
direction.z += 1
if Input.is_action_pressed("move_forward"):
direction.z -= 1
direction.x = Input.get_axis("move_left", "move_right")
direction.z = Input.get_axis("move_forward", "move_back")
$Control/Direction.text = "x: %.2f, z: %.2f" % [direction.x, direction.z]
# If in movement, normalize direction and change looking_at
if direction != Vector3.ZERO:

View File

@@ -4,6 +4,8 @@ extends Node
func _ready():
$UserInterface/Retry.hide()
Engine.max_fps = 144
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
@@ -22,6 +24,7 @@ func _on_mob_timer_timeout():
func _on_player_hit():
$MobTimer.stop()
$UserInterface/Retry.show()
Engine.max_fps = 30
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=12 format=3 uid="uid://6o4jfv4sjc42"]
[gd_scene load_steps=13 format=3 uid="uid://6o4jfv4sjc42"]
[ext_resource type="Script" path="res://main.gd" id="1_git68"]
[ext_resource type="PackedScene" uid="uid://bl4b5g1o8ud5y" path="res://player.tscn" id="1_qvjem"]
[ext_resource type="PackedScene" uid="uid://h2hapmuai55b" path="res://mob.tscn" id="2_oiwul"]
[ext_resource type="FontFile" uid="uid://d1r2cqlplg2wb" path="res://fonts/Montserrat-Medium.ttf" id="4_o3155"]
[ext_resource type="Script" path="res://ScoreLabel.gd" id="5_y0lvi"]
[ext_resource type="Script" path="res://FPS.gd" id="6_jdbnj"]
[sub_resource type="BoxShape3D" id="BoxShape3D_jiv4h"]
size = Vector3(60, 2, 60)
@@ -79,7 +80,7 @@ mesh = SubResource("CylinderMesh_1gwnh")
curve = SubResource("Curve3D_476rq")
[node name="SpawnLocation" type="PathFollow3D" parent="SpawnPath"]
transform = Transform3D(0.0074346, 0, -0.999971, 0, 1, 0, 0.999971, 0, 0.0074346, -13.6297, 0, -15.0268)
transform = Transform3D(0.00743615, 0, -0.999971, 0, 1, 0, 0.999971, 0, 0.00743615, -13.6297, 0, -15.0268)
[node name="MobTimer" type="Timer" parent="."]
wait_time = 0.5
@@ -94,16 +95,6 @@ grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_eyu2y")
[node name="ScoreLabel" type="Label" parent="UserInterface"]
layout_mode = 0
offset_left = 38.0
offset_top = 29.0
offset_right = 99.0
offset_bottom = 52.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "Score: 0"
script = ExtResource("5_y0lvi")
[node name="Retry" type="ColorRect" parent="UserInterface"]
layout_mode = 1
anchors_preset = 15
@@ -128,5 +119,25 @@ grow_horizontal = 2
grow_vertical = 2
text = "Press Enter to retry"
[node name="ScoreLabel" type="Label" parent="UserInterface"]
layout_mode = 0
offset_left = 38.0
offset_top = 29.0
offset_right = 99.0
offset_bottom = 52.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "Score: 0"
script = ExtResource("5_y0lvi")
[node name="FPS" type="Label" parent="UserInterface"]
layout_mode = 0
offset_left = 610.0
offset_top = 22.0
offset_right = 654.0
offset_bottom = 50.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "FPS"
script = ExtResource("6_jdbnj")
[connection signal="hit" from="Player" to="." method="_on_player_hit"]
[connection signal="timeout" from="MobTimer" to="." method="_on_mob_timer_timeout"]

View File

@@ -6,6 +6,33 @@
[sub_resource type="BoxShape3D" id="BoxShape3D_vwmkp"]
size = Vector3(2.5, 1.5, 3.5)
[sub_resource type="Animation" id="Animation_g67lg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot/Character:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Pivot/Character:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="Animation" id="Animation_ja4nm"]
resource_name = "float"
length = 1.2
@@ -35,33 +62,6 @@ tracks/1/keys = {
"values": [Vector3(0, 0, 0), Vector3(0.139626, 0, 0), Vector3(-0.15708, 0, 0)]
}
[sub_resource type="Animation" id="Animation_g67lg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot/Character:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Pivot/Character:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_x0i7m"]
_data = {
"RESET": SubResource("Animation_g67lg"),

View File

@@ -7,9 +7,36 @@
radius = 1.0
[sub_resource type="CylinderShape3D" id="CylinderShape3D_chb66"]
height = 0.2
height = 0.4
radius = 1.3
[sub_resource type="Animation" id="Animation_g67lg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot/Character:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Pivot/Character:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="Animation" id="Animation_ja4nm"]
resource_name = "float"
length = 1.2
@@ -39,33 +66,6 @@ tracks/1/keys = {
"values": [Vector3(0, 0, 0), Vector3(0.139626, 0, 0), Vector3(-0.15708, 0, 0)]
}
[sub_resource type="Animation" id="Animation_g67lg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot/Character:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Pivot/Character:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_x0i7m"]
_data = {
"RESET": SubResource("Animation_g67lg"),
@@ -100,4 +100,19 @@ libraries = {
}
autoplay = "float"
[node name="Control" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Direction" type="Label" parent="Control"]
layout_mode = 0
offset_left = 453.0
offset_top = 38.0
offset_right = 493.0
offset_bottom = 61.0
[connection signal="body_entered" from="MobDetector" to="." method="_on_mob_detector_body_entered"]

View File

@@ -12,6 +12,7 @@ config_version=5
config/name="Godot"
config/features=PackedStringArray("4.2", "Forward Plus")
run/max_fps=144
config/icon="res://icon.svg"
[autoload]
@@ -90,3 +91,10 @@ jump={
3d_physics/layer_1="player"
3d_physics/layer_2="enemies"
3d_physics/layer_3="world"
[rendering]
anti_aliasing/quality/msaa_2d=3
anti_aliasing/quality/msaa_3d=3
anti_aliasing/quality/screen_space_aa=1
anti_aliasing/quality/use_taa=true