feat: work on player animations&improve level

This commit is contained in:
Sara Gerretsen 2025-12-03 18:05:04 +01:00
parent 4858a402eb
commit 01750cb3c8
10 changed files with 2207 additions and 59 deletions

View file

@ -0,0 +1,49 @@
#include "level_status.h"
void LevelStatus::_bind_methods() {
ClassDB::bind_method(D_METHOD("object_destroyed", "value"), &self_type::object_destroyed);
ADD_SIGNAL(MethodInfo(sig_object_destroyed, PropertyInfo(Variant::FLOAT, "style"), PropertyInfo(Variant::INT, "score")));
}
void LevelStatus::process(double delta) {
this->time_since_last += delta;
}
void LevelStatus::_notification(int what) {
if (Engine::get_singleton()->is_editor_hint()) {
return;
}
switch (what) {
default:
return;
case NOTIFICATION_ENTER_TREE:
instance = this;
return;
case NOTIFICATION_EXIT_TREE:
if (instance == this) {
instance = nullptr;
}
return;
case NOTIFICATION_READY:
set_process(true);
return;
case NOTIFICATION_PROCESS:
process(get_process_delta_time());
return;
}
}
void LevelStatus::object_destroyed(int value) {
double style_value{ 1 + (this->max_time_between > this->time_since_last ? this->max_time_between - this->time_since_last : 0.0) };
this->style += this->base_style_per_object * style_value;
this->score += value * (1 + this->style);
emit_signal(sig_object_destroyed, this->style, this->score);
}
String const LevelStatus::sig_object_destroyed{ "object_destroyed" };
LevelStatus *LevelStatus::instance{ nullptr };
LevelStatus *LevelStatus::get_instance() {
return instance;
}

View file

@ -0,0 +1,31 @@
#pragma once
#include "break_utopia/macros.h"
#include "core/math/math_defs.h"
#include "scene/main/node.h"
class LevelStatus : public Node {
GDCLASS(LevelStatus, Node);
static void _bind_methods();
void process(double delta);
protected:
void _notification(int what);
public:
void object_destroyed(int value);
private:
static LevelStatus *instance;
float style{};
int score{};
double base_style_per_object{ 0.25 };
double time_since_last{ Math::INF };
double max_time_between{ 1.f };
public:
static String const sig_object_destroyed;
static LevelStatus *get_instance();
GET_SET_FNS(float, style);
GET_SET_FNS(int, score);
};

View file

@ -1,7 +1,9 @@
#include "register_types.h"
#include "break_utopia/damage_box.h"
#include "break_utopia/destructable_object.h"
#include "break_utopia/hit_box.h"
#include "break_utopia/level_status.h"
#include "break_utopia/player_body.h"
#include "break_utopia/player_camera.h"
#include "break_utopia/player_states.h"
@ -20,6 +22,8 @@ void initialize_break_utopia_module(ModuleInitializationLevel p_level) {
ClassDB::register_class<DamageBox>();
ClassDB::register_class<HitBox>();
ClassDB::register_class<PlayerCamera>();
ClassDB::register_class<LevelStatus>();
ClassDB::register_class<DestructableObject>();
}
void uninitialize_break_utopia_module(ModuleInitializationLevel p_level) {

Binary file not shown.

View file

@ -1,23 +1,3 @@
[gd_resource type="StandardMaterial3D" load_steps=4 format=3 uid="uid://cx3sl5hvxpkph"]
[ext_resource type="Texture2D" uid="uid://dvokqlgw275hn" path="res://assets/effects/particle_textures/impact.png" id="1_8ex1x"]
[ext_resource type="Texture2D" uid="uid://dc65p8moj4l43" path="res://assets/effects/particle_textures/impact_outline.png" id="2_jll0k"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yiuqf"]
transparency = 1
cull_mode = 2
shading_mode = 0
diffuse_mode = 3
albedo_texture = ExtResource("2_jll0k")
grow_amount = 0.05
[gd_resource type="StandardMaterial3D" format=3 uid="uid://cx3sl5hvxpkph"]
[resource]
next_pass = SubResource("StandardMaterial3D_yiuqf")
transparency = 1
cull_mode = 2
shading_mode = 0
diffuse_mode = 3
specular_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("1_8ex1x")
billboard_keep_scale = true

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
[ext_resource type="PackedScene" uid="uid://2fxwkeifrwu3" path="res://objects/effects/impact_decal.tscn" id="2_1p07c"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_5j0w6"]
radius = 0.6
radius = 0.431641
[sub_resource type="GDScript" id="GDScript_yaurm"]
script/source = "extends Node3D
@ -95,7 +95,7 @@ transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition
graph_offset = Vector2(-228.371, 13.6511)
[sub_resource type="BoxShape3D" id="BoxShape3D_1p07c"]
size = Vector3(0.547852, 1.3642, 0.728516)
size = Vector3(0.547852, 1.3642, 0.529297)
[node name="PlayerBody" type="PlayerBody"]
collision_layer = 8
@ -127,14 +127,14 @@ bone_idx = 18
[node name="DamageBox" type="DamageBox" parent="character/character/Skeleton3D/BoneAttachment3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.008875, 1.58642, -6.97582e-10)
collision_layer = 0
collision_mask = 3
collision_mask = 2
input_ray_pickable = false
monitoring = false
monitorable = false
priority = 1
[node name="CollisionShape3D" type="CollisionShape3D" parent="character/character/Skeleton3D/BoneAttachment3D/DamageBox"]
transform = Transform3D(1, -1.06248e-06, 1.37836e-07, 6.46887e-07, 1, 1.88826e-07, 1.75089e-07, -2.18919e-07, 1, 1.78814e-07, -0.371879, -0.0270205)
transform = Transform3D(1, -1.36116e-06, 1.82539e-07, 6.46964e-07, 1, 2.05589e-07, 3.12924e-07, -2.22004e-07, 1, 2.38419e-07, -0.371879, -0.0270205)
shape = SubResource("BoxShape3D_1p07c")
[node name="PlayerIdleState" type="PlayerIdleState" parent="."]

View file

@ -69,7 +69,10 @@ light_attack={
[physics]
3d/run_on_separate_thread=true
common/max_physics_steps_per_frame=12
3d/physics_engine="Jolt Physics"
common/physics_interpolation=true
[rendering]

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://bopapid0k4qkr"]
[gd_scene load_steps=11 format=3 uid="uid://bopapid0k4qkr"]
[ext_resource type="PackedScene" uid="uid://csr23278g4hqe" path="res://objects/player_body.tscn" id="1_2venv"]
[ext_resource type="PackedScene" uid="uid://ct650octef6l3" path="res://objects/destructable_props/table.tscn" id="2_paw1w"]
[ext_resource type="Texture2D" uid="uid://mmgby1krvohd" path="res://assets/environment/textures/tiles_albedo.png" id="2_x4b8f"]
[ext_resource type="Texture2D" uid="uid://2cflalgoaq65" path="res://assets/environment/textures/tiles_normal.png" id="3_tmr53"]
[ext_resource type="Texture2D" uid="uid://cxw8lsrf72t3m" path="res://assets/environment/textures/tiles_rough.exr" id="4_tmr53"]
[ext_resource type="PackedScene" uid="uid://bw4dstm6d5s20" path="res://objects/destructable_props/cubicle.tscn" id="6_qcd3b"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_2venv"]
sky_horizon_color = Color(0.652763, 0.676338, 0.705513, 1)
@ -33,60 +34,84 @@ uv1_triplanar = true
[node name="TestLevel" type="Node3D"]
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.480286, 0.759602, -0.438557, 1.14428e-08, 0.5, 0.866025, 0.877112, 0.415939, -0.240142, 0, 1.79769, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_j6w7d")
[node name="Camera3D" type="PlayerCamera" parent="."]
transform = Transform3D(0.62034, -0.103054, 0.777533, 0, 0.99133, 0.131392, -0.784333, -0.081507, 0.614962, 6.62549, 3.07452, 6.725)
transform = Transform3D(0.684801, -0.157117, 0.711591, -7.45058e-09, 0.976481, 0.215604, -0.72873, -0.147646, 0.668695, 7.34832, 3.18426, 6.74264)
fov = 68.8063
[node name="PlayerBody" parent="." instance=ExtResource("1_2venv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.3668, -0.000488758, 2.05704)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.11913, -0.000492096, 2.81274)
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
layers = 3
use_collision = true
collision_layer = 5
collision_mask = 5
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -1.03728, 11.9601, -3.59061)
size = Vector3(104.384, 68.3779, 89.9268)
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 2.00604, 2.64007, 1.52303)
operation = 2
size = Vector3(13.0256, 5.64118, 12.0219)
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0863037, 0)
size = Vector3(49.2646, 0.171631, 34.6709)
material = SubResource("StandardMaterial3D_qcd3b")
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -6.79491, 0.863281, -4.90401)
size = Vector3(6.07801, 2.0708, 4.90196)
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -6.79491, 0.458618, 0.586282)
size = Vector3(5.05756, 1.26147, 4.90196)
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -6.79491, 0.249206, 5.44049)
size = Vector3(4.86313, 0.842651, 4.90196)
[node name="Table" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.539985, 0.0109616, 4.10204)
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 5.03561, 0.0109616, 2.7458)
[node name="Table2" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.539985, 0.0109616, 2.06498)
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.12511, 4.54104, -2.63257)
light_color = Color(1, 0.994333, 0.83, 1)
omni_range = 70.081
[node name="Table3" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.539985, 0.0109616, 0.207431)
[node name="OmniLight3D2" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.12511, 4.54104, 4.36743)
light_color = Color(1, 0.994333, 0.83, 1)
omni_range = 70.081
[node name="Table6" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.539985, 0.0109616, -1.79257)
[node name="Cubicle" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, 0.437047)
[node name="Table7" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.539985, 0.0109616, -3.79257)
[node name="Cubicle2" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, 2.60974)
[node name="Table4" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.46001, 0.0109616, -0.395865)
[node name="Cubicle3" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, 4.79514)
[node name="Table8" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.46001, 0.0109616, -2.39586)
[node name="Cubicle5" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, -1.76627)
[node name="Table5" parent="." instance=ExtResource("2_paw1w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.46001, 0.0109616, 1.58982)
[node name="Cubicle6" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, -3.96556)
[node name="Cubicle4" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71818, 0, 6.92378)
[node name="Cubicle7" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.425461, 0, -3.71851)
[node name="Cubicle10" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.425461, 0, -1.56591)
[node name="Cubicle13" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.425461, 0, 0.59779)
[node name="Cubicle14" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.425461, 0, 2.69581)
[node name="Cubicle17" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.425461, 0, 4.85067)
[node name="Cubicle15" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1.31134e-07, 0, 1, 0, 1, 0, -1, 0, 1.31134e-07, 4.74751, 2.38419e-07, -2.59513)
[node name="Cubicle16" parent="." instance=ExtResource("6_qcd3b")]
transform = Transform3D(1.31134e-07, 0, 1, 0, 1, 0, -1, 0, 1.31134e-07, 6.87643, 2.38419e-07, -2.59513)