FPS game progress
This commit is contained in:
@@ -3,4 +3,7 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Scenes\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
24
Models/machinegun.mtl
Normal file
24
Models/machinegun.mtl
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#
|
||||||
|
## Alias OBJ Material File
|
||||||
|
# Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
|
||||||
|
|
||||||
|
newmtl Gray8
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.266667 0.266667 0.266667
|
||||||
|
Ks 0.330000 0.330000 0.330000
|
||||||
|
|
||||||
|
newmtl Gray5
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.529412 0.529412 0.529412
|
||||||
|
Ks 0.330000 0.330000 0.330000
|
||||||
|
|
||||||
|
newmtl Gray6
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.376471 0.376471 0.376471
|
||||||
|
Ks 0.330000 0.330000 0.330000
|
||||||
|
|
||||||
|
newmtl FrontColor
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.330000 0.330000 0.330000
|
||||||
|
|
||||||
21
Models/machinegun.obj.import
Normal file
21
Models/machinegun.obj.import
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wavefront_obj"
|
||||||
|
importer_version=1
|
||||||
|
type="Mesh"
|
||||||
|
uid="uid://d7b2roon4kjw"
|
||||||
|
path="res://.godot/imported/machinegun.obj-de3394cab87f093dcf4bc6a41fb34309.mesh"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
files=["res://.godot/imported/machinegun.obj-de3394cab87f093dcf4bc6a41fb34309.mesh"]
|
||||||
|
|
||||||
|
source_file="res://Models/machinegun.obj"
|
||||||
|
dest_files=["res://.godot/imported/machinegun.obj-de3394cab87f093dcf4bc6a41fb34309.mesh", "res://.godot/imported/machinegun.obj-de3394cab87f093dcf4bc6a41fb34309.mesh"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
generate_tangents=true
|
||||||
|
scale_mesh=Vector3(1, 1, 1)
|
||||||
|
offset_mesh=Vector3(0, 0, 0)
|
||||||
|
optimize_mesh=true
|
||||||
43
Scenes/Crosshair.gdshader
Normal file
43
Scenes/Crosshair.gdshader
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
shader_type canvas_item;
|
||||||
|
|
||||||
|
uniform bool center_enabled = true;
|
||||||
|
uniform bool legs_enabled = true;
|
||||||
|
uniform bool inverted = false;
|
||||||
|
uniform int color_id = 0;
|
||||||
|
uniform vec4 color_0 = vec4(0., 1, 0., 1.);
|
||||||
|
uniform vec4 color_1 = vec4(1., 0., 0., 1.);
|
||||||
|
uniform vec4 color_2 = vec4(0., 0., 1., 1.);
|
||||||
|
uniform float center_radius = .002;
|
||||||
|
uniform float width = .003;
|
||||||
|
uniform float len = .03;
|
||||||
|
uniform float spacing = .008;
|
||||||
|
uniform float spread = 1.;
|
||||||
|
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
|
||||||
|
|
||||||
|
|
||||||
|
void fragment(){
|
||||||
|
|
||||||
|
float a = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
|
||||||
|
vec2 UVa = vec2(UV.x / a, UV.y);
|
||||||
|
vec2 center = vec2(.5 / a, .5);
|
||||||
|
|
||||||
|
float point = step(distance(UVa, center), center_radius);
|
||||||
|
|
||||||
|
float h = step(center.x - len - spacing*spread, UVa.x) - step(center.x - spacing*spread, UVa.x);
|
||||||
|
h += step(center.x + spacing*spread, UVa.x) - step(center.x + len + spacing*spread, UVa.x);
|
||||||
|
h *= step(center.y - width, UVa.y) - step(center.y + width, UVa.y);
|
||||||
|
|
||||||
|
float v = step(center.y - len - spacing*spread, UVa.y) - step(center.y - spacing*spread, UVa.y);
|
||||||
|
v += step(center.y + spacing*spread, UVa.y) - step(center.y + len + spacing*spread, UVa.y);
|
||||||
|
v *= step(center.x - width, UVa.x) - step(center.x + width, UVa.x);
|
||||||
|
|
||||||
|
float crosshair;
|
||||||
|
|
||||||
|
crosshair = (h+v) * float(legs_enabled) + point * float(center_enabled);
|
||||||
|
|
||||||
|
if(!inverted){
|
||||||
|
COLOR = (color_0 * float(color_id == 0) + color_1 * float(color_id == 1) + color_2 * float(color_id == 2)) * crosshair;
|
||||||
|
}else{
|
||||||
|
COLOR = vec4((cos(textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb * 3.1415926534) + 1.)/2., 1.) * crosshair;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Scenes/Enivornment.tres
Normal file
3
Scenes/Enivornment.tres
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[gd_resource type="Environment" format=3 uid="uid://c1i78mwq3ug2f"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
65
Scenes/Gun.tscn
Normal file
65
Scenes/Gun.tscn
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://cc5emorildoar"]
|
||||||
|
|
||||||
|
[ext_resource type="Environment" uid="uid://c1i78mwq3ug2f" path="res://Scenes/Enivornment.tres" id="1_3jquc"]
|
||||||
|
[ext_resource type="ArrayMesh" uid="uid://d7b2roon4kjw" path="res://Models/machinegun.obj" id="1_lxd3t"]
|
||||||
|
[ext_resource type="Shader" path="res://Scenes/Crosshair.gdshader" id="3_avtvy"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_foxul"]
|
||||||
|
shader = ExtResource("3_avtvy")
|
||||||
|
shader_parameter/center_enabled = true
|
||||||
|
shader_parameter/legs_enabled = true
|
||||||
|
shader_parameter/inverted = false
|
||||||
|
shader_parameter/color_id = 0
|
||||||
|
shader_parameter/color_0 = Vector4(0, 1, 0, 1)
|
||||||
|
shader_parameter/color_1 = Vector4(1, 0, 0, 1)
|
||||||
|
shader_parameter/color_2 = Vector4(0, 0, 1, 1)
|
||||||
|
shader_parameter/center_radius = 0.002
|
||||||
|
shader_parameter/width = 0.002
|
||||||
|
shader_parameter/len = 0.025
|
||||||
|
shader_parameter/spacing = 0.008
|
||||||
|
shader_parameter/spread = 1.0
|
||||||
|
|
||||||
|
[node name="Gun" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
|
||||||
|
light_mask = 2
|
||||||
|
visibility_layer = 2
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
stretch = true
|
||||||
|
|
||||||
|
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
|
||||||
|
transparent_bg = true
|
||||||
|
handle_input_locally = false
|
||||||
|
size = Vector2i(1152, 648)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport"]
|
||||||
|
cull_mask = 1047554
|
||||||
|
environment = ExtResource("1_3jquc")
|
||||||
|
|
||||||
|
[node name="Machinegun" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/Camera3D"]
|
||||||
|
transform = Transform3D(-8, 0, -1.20797e-06, 0, 8, 0, 1.20797e-06, 0, -8, 0.355038, -0.26573, -0.622725)
|
||||||
|
layers = 2
|
||||||
|
mesh = ExtResource("1_lxd3t")
|
||||||
|
skeleton = NodePath("../../../..")
|
||||||
|
|
||||||
|
[node name="Crosshair" 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="ColorRect" type="ColorRect" parent="Crosshair"]
|
||||||
|
material = SubResource("ShaderMaterial_foxul")
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
8
Scenes/Healthbar.cs
Normal file
8
Scenes/Healthbar.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Healthbar : Sprite3D
|
||||||
|
{
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://ocor7udqvoec"]
|
[gd_scene load_steps=7 format=3 uid="uid://ocor7udqvoec"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bi7j4afsxghrj" path="res://Scenes/Player.tscn" id="1_my8b5"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cc5emorildoar" path="res://Scenes/Gun.tscn" id="2_mhg71"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b03tplah8y1do" path="res://Scenes/target.tscn" id="3_civmh"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gyf0l"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_gyf0l"]
|
||||||
size = Vector3(20, 0.5, 20)
|
size = Vector3(20, 0.5, 20)
|
||||||
@@ -13,9 +17,22 @@ size = Vector3(20, 0.5, 20)
|
|||||||
[node name="Level" type="Node3D"]
|
[node name="Level" type="Node3D"]
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||||
shape = SubResource("BoxShape3D_gyf0l")
|
shape = SubResource("BoxShape3D_gyf0l")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.189965, 0)
|
||||||
mesh = SubResource("BoxMesh_v2sg1")
|
mesh = SubResource("BoxMesh_v2sg1")
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource("1_my8b5")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.269294, 0)
|
||||||
|
|
||||||
|
[node name="Gun" parent="Player" instance=ExtResource("2_mhg71")]
|
||||||
|
transform = Transform3D(0.979575, 0, 0.201078, 0, 1, 0, -0.201078, 0, 0.979575, 0.074702, 1.59908, -0.498807)
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
|
transform = Transform3D(-0.0510635, -0.435165, -0.898901, 0, -0.900076, 0.435734, -0.998695, 0.0222501, 0.045961, -5.60126, 7.19548, 0)
|
||||||
|
|
||||||
|
[node name="Target" parent="." instance=ExtResource("3_civmh")]
|
||||||
|
|||||||
34
Scenes/Player.tscn
Normal file
34
Scenes/Player.tscn
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://bi7j4afsxghrj"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Player.cs" id="1_jsq3s"]
|
||||||
|
[ext_resource type="Environment" uid="uid://c1i78mwq3ug2f" path="res://Scenes/Enivornment.tres" id="2_t03qe"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cxbex"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleMesh" id="CapsuleMesh_7dxig"]
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("_pivot")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.13331, 0)
|
||||||
|
script = ExtResource("1_jsq3s")
|
||||||
|
_mouseSensitivity = 0.07
|
||||||
|
_pivot = NodePath("Pivot")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
|
shape = SubResource("CapsuleShape3D_cxbex")
|
||||||
|
|
||||||
|
[node name="Pivot" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="Pivot"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.47186, 0.0718701)
|
||||||
|
environment = ExtResource("2_t03qe")
|
||||||
|
fov = 60.0
|
||||||
|
|
||||||
|
[node name="AimCast" type="RayCast3D" parent="Pivot/Camera3D"]
|
||||||
|
transform = Transform3D(0.125, 0, 0, 0, 0.125, 0, 0, 0, 0.125, 0, 0, 0)
|
||||||
|
target_position = Vector3(0, 0, -1000)
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
|
visible = false
|
||||||
|
mesh = SubResource("CapsuleMesh_7dxig")
|
||||||
33
Scenes/target.tscn
Normal file
33
Scenes/target.tscn
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://b03tplah8y1do"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Target.cs" id="1_ykgyh"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_37aka"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8nuxw"]
|
||||||
|
albedo_color = Color(1, 0.282353, 0, 1)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_ni5do"]
|
||||||
|
material = SubResource("StandardMaterial3D_8nuxw")
|
||||||
|
|
||||||
|
[node name="Target" type="StaticBody3D" node_paths=PackedStringArray("_progressBar")]
|
||||||
|
script = ExtResource("1_ykgyh")
|
||||||
|
_progressBar = NodePath("ProgressBar")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.12414, -3.96702)
|
||||||
|
shape = SubResource("BoxShape3D_37aka")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.12414, -3.96702)
|
||||||
|
mesh = SubResource("BoxMesh_ni5do")
|
||||||
|
skeleton = NodePath("")
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="."]
|
||||||
|
offset_left = 460.0
|
||||||
|
offset_top = 3.0
|
||||||
|
offset_right = 688.0
|
||||||
|
offset_bottom = 58.0
|
||||||
|
value = 100.0
|
||||||
|
|
||||||
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
101
Scripts/Player.cs
Normal file
101
Scripts/Player.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Player : CharacterBody3D
|
||||||
|
{
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnHitEventHandler();
|
||||||
|
|
||||||
|
public const float _speed = 5.0f;
|
||||||
|
public const float _jumpVelocity = 4.5f;
|
||||||
|
[Export]
|
||||||
|
private float _mouseSensitivity = 0.03f;
|
||||||
|
[Export]
|
||||||
|
private float _joystickDeadZone = 0.5f;
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityHorizontal = 0.5f;
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityVertical = 0.5f;
|
||||||
|
[Export]
|
||||||
|
private Node3D _pivot;
|
||||||
|
|
||||||
|
private RayCast3D _aimCast;
|
||||||
|
|
||||||
|
// Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||||
|
public static float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
_aimCast = GetNode<RayCast3D>("Pivot/Camera3D/AimCast");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
var isOnFloor = IsOnFloor();
|
||||||
|
Velocity = MovePlayer(Velocity, Transform.Basis, (float)delta, isOnFloor);
|
||||||
|
MoveAndSlide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
var joyRightX = Input.GetJoyAxis(0, JoyAxis.RightX);
|
||||||
|
var joyRightY = Input.GetJoyAxis(0, JoyAxis.RightY);
|
||||||
|
|
||||||
|
if (Mathf.Abs(joyRightX) > _joystickDeadZone)
|
||||||
|
RotateY(Mathf.DegToRad(-joyRightX * _sensitivityHorizontal));
|
||||||
|
if (Mathf.Abs(joyRightY) > _joystickDeadZone)
|
||||||
|
{
|
||||||
|
_pivot.RotateX(Mathf.DegToRad(-joyRightY * _sensitivityVertical));
|
||||||
|
_pivot.Rotation = new Vector3(Mathf.Clamp(_pivot.Rotation.X, Mathf.DegToRad(-80), Mathf.DegToRad(80)), _pivot.Rotation.Y, _pivot.Rotation.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Input.IsActionJustPressed("quit"))
|
||||||
|
GetTree().Quit();
|
||||||
|
|
||||||
|
if (@event is InputEventMouseMotion inputMouseEvent)
|
||||||
|
{
|
||||||
|
RotateY(Mathf.DegToRad(-inputMouseEvent.Relative.X * _mouseSensitivity));
|
||||||
|
_pivot.RotateX(Mathf.DegToRad(-inputMouseEvent.Relative.Y * _mouseSensitivity));
|
||||||
|
_pivot.Rotation = new Vector3(Mathf.Clamp(_pivot.Rotation.X, Mathf.DegToRad(-80), Mathf.DegToRad(80)), _pivot.Rotation.Y, _pivot.Rotation.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("fire") && _aimCast.IsColliding())
|
||||||
|
{
|
||||||
|
EmitSignal(SignalName.OnHit);
|
||||||
|
_aimCast.GetCollider().Call("OnHitEvent", 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vector3 MovePlayer(Vector3 velocity, Basis basis, float delta, bool isOnFloor)
|
||||||
|
{
|
||||||
|
var startingVelocity = velocity;
|
||||||
|
// Add the gravity.
|
||||||
|
if (!isOnFloor)
|
||||||
|
velocity.Y -= gravity * delta;
|
||||||
|
|
||||||
|
// Handle Jump.
|
||||||
|
if (Input.IsActionJustPressed("jump") && isOnFloor)
|
||||||
|
velocity.Y = _jumpVelocity;
|
||||||
|
|
||||||
|
// Get the input direction and handle the movement/deceleration.
|
||||||
|
// As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
|
Vector2 inputDir = Input.GetVector("left", "right", "up", "down");
|
||||||
|
Vector3 direction = (basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
||||||
|
if (direction != Vector3.Zero)
|
||||||
|
{
|
||||||
|
velocity.X = direction.X * _speed;
|
||||||
|
velocity.Z = direction.Z * _speed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = Mathf.MoveToward(startingVelocity.X, 0, _speed);
|
||||||
|
velocity.Z = Mathf.MoveToward(startingVelocity.Z, 0, _speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return velocity;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Scripts/Target.cs
Normal file
26
Scripts/Target.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Target : StaticBody3D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
private int _maxHP = 100;
|
||||||
|
private int _currentHP;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private ProgressBar _progressBar;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_currentHP = _maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnHitEvent(int damage)
|
||||||
|
{
|
||||||
|
_currentHP -= damage;
|
||||||
|
GD.Print($"Current HP: {_currentHP}");
|
||||||
|
_progressBar.Value = _currentHP;
|
||||||
|
|
||||||
|
if (_currentHP <= 0)
|
||||||
|
QueueFree();
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Textures/Healthbar/barHorizontal_green_mid 200.png
Normal file
BIN
Textures/Healthbar/barHorizontal_green_mid 200.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 292 B |
35
Textures/Healthbar/barHorizontal_green_mid 200.png.import
Normal file
35
Textures/Healthbar/barHorizontal_green_mid 200.png.import
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dhcfanxewk34"
|
||||||
|
path.s3tc="res://.godot/imported/barHorizontal_green_mid 200.png-ba8c88892332a40612df0726c113abf1.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Textures/Healthbar/barHorizontal_green_mid 200.png"
|
||||||
|
dest_files=["res://.godot/imported/barHorizontal_green_mid 200.png-ba8c88892332a40612df0726c113abf1.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
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/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
|
||||||
BIN
Textures/Healthbar/barHorizontal_red_mid 200.png
Normal file
BIN
Textures/Healthbar/barHorizontal_red_mid 200.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 360 B |
34
Textures/Healthbar/barHorizontal_red_mid 200.png.import
Normal file
34
Textures/Healthbar/barHorizontal_red_mid 200.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bjh06psv7qg06"
|
||||||
|
path="res://.godot/imported/barHorizontal_red_mid 200.png-e40ac6e900cd3d39ba0d9194290b293a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Textures/Healthbar/barHorizontal_red_mid 200.png"
|
||||||
|
dest_files=["res://.godot/imported/barHorizontal_red_mid 200.png-e40ac6e900cd3d39ba0d9194290b293a.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
Textures/Healthbar/barHorizontal_yellow_mid 200.png
Normal file
BIN
Textures/Healthbar/barHorizontal_yellow_mid 200.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 360 B |
34
Textures/Healthbar/barHorizontal_yellow_mid 200.png.import
Normal file
34
Textures/Healthbar/barHorizontal_yellow_mid 200.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d3xp4otnenl1q"
|
||||||
|
path="res://.godot/imported/barHorizontal_yellow_mid 200.png-d77c21427b8443909ca99c00f2118f80.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Textures/Healthbar/barHorizontal_yellow_mid 200.png"
|
||||||
|
dest_files=["res://.godot/imported/barHorizontal_yellow_mid 200.png-d77c21427b8443909ca99c00f2118f80.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
|
||||||
@@ -11,9 +11,58 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="FPS"
|
config/name="FPS"
|
||||||
config/features=PackedStringArray("4.1", "Forward Plus")
|
run/main_scene="res://Scenes/Level.tscn"
|
||||||
config/icon="res://icon.svg"
|
config/features=PackedStringArray("4.1", "C#", "Forward Plus")
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="FPS"
|
project/assembly_name="FPS"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
jump={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":32,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
fire={
|
||||||
|
"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,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
quit={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
common/physics_ticks_per_second=300
|
||||||
|
|||||||
Reference in New Issue
Block a user