This commit is contained in:
erkkon 2023-07-17 19:58:25 +02:00
parent af88efa360
commit 346bd9d9eb
27 changed files with 1010 additions and 1 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

16
.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
# Godot 4+ specific ignores
/.godot
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg
# Imported translations (automatically generated from CSV files)
*.translation
# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json
.DS_Store

View file

@ -1,2 +1,69 @@
# OpenAimTrainer
Open Aim Trainer
🎯 **Open Aim Trainer** is a free and open source aim trainer that allows you to improve your aim in both 2D and 3D games. It is made with the **Godot game engine**, which is a free and open source game engine that is easy to learn and use.
It features a variety of different training modes, including:
🧍 **Static targets**: These targets stay in one place, so you can focus on improving your accuracy.
🏃 **Moving targets**: These targets move around, so you need to track them with your crosshair.
⚙️ Open Aim Trainer also features a variety of customization options, so you can tailor the training to your specific needs. You can choose the type of targets, the speed of the targets, and the scoring system.
🏆 Whether you're a beginner or a pro, Aim Trainer is a great way to improve your aim in any game. It's free, open source, and easy to use. So what are you waiting for? Start training today!
![Open Aim Trainer 3d](assets/images/godot_j8QRjOeEmU.jpg)
### Features:
🏎️ Made with the Godot game engine
👟 Variety of training modes
⚙️ Customizable settings
🆓 Free and open source
### Benefits:
🎯 Improve your aim in any game
🤯 Tailor the training to your specific needs
💪 Easy to use
### Get started:
⏬ Download the latest version of Open Aim Trainer
🖥️ Install the game on your computer
🏁 Start training!
### For more information:
🌐 Visit the Open Aim Trainer website
💬 Join the Open Aim Trainer Discord server
### Basic structure
```
/project-root
├── project.gd
├── README.md
├── assets
│ ├── images
│ ├── sounds
│ ├── fonts
│ └── models
├── scenes
│ ├── ui
│ ├── characters
│ └── levels
├── scripts
│ ├── ui
│ ├── characters
│ └── levels
└── resources
└── shaders
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://t6fxbl551xlp"
path="res://.godot/imported/erkkon_aim_trainer_16_9_Logo_v1.png-67980496f33c0b0ff4fc8aede44ca9c2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/erkkon_aim_trainer_16_9_Logo_v1.png"
dest_files=["res://.godot/imported/erkkon_aim_trainer_16_9_Logo_v1.png-67980496f33c0b0ff4fc8aede44ca9c2.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

BIN
assets/images/hole.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cqospwtedgwrg"
path.s3tc="res://.godot/imported/hole.png-d9ed514af341dcdf1e4f38a2db14165a.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://assets/images/hole.png"
dest_files=["res://.godot/imported/hole.png-d9ed514af341dcdf1e4f38a2db14165a.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=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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://mhv5qf7fdeig"
path.s3tc="res://.godot/imported/texture_08.png-95e3f4f0c198102f43c006254b6f0c19.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://assets/images/texture_08.png"
dest_files=["res://.godot/imported/texture_08.png-95e3f4f0c198102f43c006254b6f0c19.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
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

34
icon.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://7bm10kuags4h"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.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
other/godot-valorant.ods Normal file

Binary file not shown.

68
project.godot Normal file
View file

@ -0,0 +1,68 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Open Aim Trainer"
run/main_scene="res://scenes/ui/MainScreen.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
boot_splash/image="res://assets/images/erkkon_aim_trainer_16_9_Logo_v1.png"
config/icon="res://icon.png"
[autoload]
Global="*res://scripts/global.gd"
[display]
window/size/viewport_width=3840
window/size/viewport_height=2160
window/size/mode=3
window/size/borderless=true
window/stretch/mode="viewport"
window/stretch/aspect="expand"
[input]
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)
]
}
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)
]
}
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)
]
}
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)
]
}
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)
]
}
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)
]
}
esc={
"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":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}

View file

@ -0,0 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://baj568pnwc4ph"]
[ext_resource type="Script" path="res://scripts/characters/target.gd" id="1_mc4da"]
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_gfo2d"]
points = PackedVector3Array(0.457871, 0.198079, 0.0157824, -0.48874, -0.0916874, -0.0451868, -0.471509, -0.137027, -0.0907015, 0.0763591, -0.333275, 0.364179, 0.136569, -0.332425, -0.346906, -0.151617, 0.471982, -0.0602459, -0.105347, 0.211936, 0.43966, -0.0450169, 0.198098, -0.456416, 0.409077, -0.151168, 0.242516, -0.271376, -0.377761, 0.181871, 0.41148, -0.075981, -0.27324, 0.198197, -0.456161, -0.044931, -0.240641, -0.331674, -0.285768, 0.227137, 0.25672, 0.363041, 0.227522, 0.423604, -0.135488, -0.37899, 0.0607022, 0.319462, -0.406747, 0.181049, -0.225691, -0.0146313, -0.0917695, 0.490229, -0.377855, 0.302793, 0.121712, 0.0462323, 0.456011, 0.198185, -0.227464, -0.0607863, -0.440348, 0.228455, 0.0607228, -0.439887, -0.0911376, -0.489246, -0.045174, 0.441865, -0.228216, -0.0449581, 0.317179, 0.241214, -0.300812, -0.0448487, 0.394737, -0.302955, -0.316348, -0.196222, 0.332551, 0.198442, -0.0304293, 0.457237, 0.0614714, -0.152246, -0.471307, 0.363089, 0.256708, 0.227079, 0.152134, -0.439489, 0.182379, -0.210725, 0.362276, 0.27223)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nkxxc"]
albedo_color = Color(1, 1, 0, 1)
[sub_resource type="SphereMesh" id="SphereMesh_gr1eg"]
material = SubResource("StandardMaterial3D_nkxxc")
[node name="Target" type="CharacterBody3D" groups=["Enemy"]]
collision_mask = 9
script = ExtResource("1_mc4da")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("ConvexPolygonShape3D_gfo2d")
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
mesh = SubResource("SphereMesh_gr1eg")
skeleton = NodePath("../..")

166
scenes/levels/World.tscn Normal file
View file

@ -0,0 +1,166 @@
[gd_scene load_steps=12 format=3 uid="uid://cdbhv0p0jfr75"]
[ext_resource type="Script" path="res://scripts/levels/World.gd" id="1_02ggb"]
[ext_resource type="Script" path="res://scripts/characters/CharacterBody3D.gd" id="1_77co2"]
[ext_resource type="Texture2D" uid="uid://mhv5qf7fdeig" path="res://assets/images/texture_08.png" id="1_s1bsx"]
[ext_resource type="Script" path="res://scripts/ui/Crosshair.gd" id="4_jkxyl"]
[ext_resource type="Script" path="res://scripts/levels/Pause.gd" id="5_4wxgd"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_hein3"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_i8euj"]
sky_material = SubResource("ProceduralSkyMaterial_hein3")
[sub_resource type="Environment" id="Environment_mlohy"]
background_mode = 2
sky = SubResource("Sky_i8euj")
tonemap_mode = 2
glow_enabled = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_glx82"]
albedo_texture = ExtResource("1_s1bsx")
uv1_scale = Vector3(0.1, 0.1, 0.1)
uv1_triplanar = true
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_trh1v"]
points = PackedVector3Array(-0.125207, -0.532801, -0.480507, 0.0227831, 0.47607, 0.498884, 0.169713, 0.559144, 0.464172, 0.231051, -0.803591, 0.320455, 0.40741, 0.651043, -0.243523, -0.482789, 0.594843, 0.0822132, -0.362868, -0.682312, 0.289697, 0.469044, -0.654529, -0.0662713, -0.127444, 0.842701, -0.338103, -0.393435, -0.683942, -0.244717, 0.438255, 0.623309, 0.200849, 0.0841477, 0.977454, 0.114795, -0.0682023, -0.976458, -0.12927, 0.20055, -0.563129, -0.451454, -0.185527, 0.595453, -0.453475, -0.273363, 0.592268, 0.407754, -0.00693649, -0.476823, 0.49966, 0.375821, -0.588614, 0.316955, 0.111579, 0.563059, -0.481177, -0.41725, 0.527866, -0.270497, -0.484546, -0.596972, -0.0665097, -0.279747, 0.908561, 0.0533361, -0.250197, -0.880712, 0.205319, 0.263647, -0.902771, -0.127394, 0.293368, 0.871526, -0.157196, 0.373412, -0.526319, -0.328246, 0.499663, 0.476641, -0.00688856, 0.0531056, 0.875001, 0.324703, -0.154543, -0.590854, 0.465879, -0.0972799, -0.782358, -0.398188, -0.387649, -0.498171, 0.31565, -0.30068, -0.587995, -0.388901)
[sub_resource type="CapsuleMesh" id="CapsuleMesh_41626"]
[node name="World" type="Node3D"]
script = ExtResource("1_02ggb")
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -0.920764, -0.390121, 0, 0.390121, -0.920764, 0, 19.0056, 0)
omni_range = 150.0
omni_attenuation = 0.0179484
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_mlohy")
[node name="Building" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 23, 0)
use_collision = true
size = Vector3(100, 50, 100)
[node name="CSGBox3D" type="CSGBox3D" parent="Building"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
operation = 2
size = Vector3(99, 50, 99)
material = SubResource("StandardMaterial3D_glx82")
[node name="PlayerPrison" type="CSGBox3D" parent="."]
transform = Transform3D(3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 0)
transparency = 1.0
use_collision = true
collision_layer = 4
size = Vector3(10, 20, 10)
[node name="CSGBox3D2" type="CSGBox3D" parent="PlayerPrison"]
operation = 2
use_collision = true
size = Vector3(9, 21, 9)
[node name="TargetPrison" type="CSGBox3D" parent="."]
transform = Transform3D(10, 0, 0, 0, 4, 0, 0, 0, 3, 2.08165e-12, 9, -35)
transparency = 1.0
use_collision = true
collision_layer = 8
size = Vector3(10, 20, 10)
[node name="CSGBox3D2" type="CSGBox3D" parent="TargetPrison"]
operation = 2
use_collision = true
size = Vector3(9, 19, 9)
[node name="Player" type="CharacterBody3D" parent="."]
collision_layer = 2
collision_mask = 5
script = ExtResource("1_77co2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 1, 0)
shape = SubResource("ConvexPolygonShape3D_trh1v")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Player/CollisionShape3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000550747, 0.00400865, -0.000956774)
mesh = SubResource("CapsuleMesh_41626")
skeleton = NodePath("../..")
[node name="Head" type="Node3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0)
[node name="Camera3D" type="Camera3D" parent="Player/Head"]
[node name="RayCast3D" type="RayCast3D" parent="Player/Head/Camera3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
target_position = Vector3(0, -1000, 0)
debug_shape_custom_color = Color(1, 0, 0, 1)
[node name="Crosshair" type="Control" parent="Player/Head/Camera3D"]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -0.5
offset_top = -0.5
offset_right = 0.5
offset_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 0
size_flags_vertical = 0
script = ExtResource("4_jkxyl")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Pause" type="Control" parent="CanvasLayer"]
process_mode = 2
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("5_4wxgd")
[node name="ColorRect" type="ColorRect" parent="CanvasLayer/Pause"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.0745098, 0.0745098, 0.0745098, 0.34902)
metadata/_edit_use_anchors_ = true
[node name="Buttons" type="VBoxContainer" parent="CanvasLayer/Pause"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -35.0
offset_top = -33.0
offset_right = 35.0
offset_bottom = 33.0
grow_horizontal = 2
grow_vertical = 2
[node name="Resume" type="Button" parent="CanvasLayer/Pause/Buttons"]
layout_mode = 2
text = "Resume"
[node name="Menu" type="Button" parent="CanvasLayer/Pause/Buttons"]
layout_mode = 2
text = "Menu"
[connection signal="pause_game" from="Player" to="CanvasLayer/Pause" method="_on_player_pause_game"]
[connection signal="pressed" from="CanvasLayer/Pause/Buttons/Resume" to="CanvasLayer/Pause" method="_on_resume_pressed"]
[connection signal="pressed" from="CanvasLayer/Pause/Buttons/Menu" to="CanvasLayer/Pause" method="_on_menu_pressed"]

25
scenes/ui/BulletHole.tscn Normal file
View file

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=3 uid="uid://dux8sd0scoqie"]
[ext_resource type="Script" path="res://scripts/ui/BulletHole.gd" id="1_a25ui"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nmsg0"]
albedo_color = Color(1, 0, 1, 1)
[sub_resource type="SphereMesh" id="SphereMesh_la6lu"]
material = SubResource("StandardMaterial3D_nmsg0")
radius = 0.15
height = 0.3
[node name="BulletHole" type="Node3D"]
script = ExtResource("1_a25ui")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1.00438, 0, 0, 0, 1.00438, 0, 0, 0, 1.00438, 0, 0, 0)
mesh = SubResource("SphereMesh_la6lu")
[node name="Timer" type="Timer" parent="."]
wait_time = 20.0
one_shot = true
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

52
scenes/ui/MainScreen.tscn Normal file
View file

@ -0,0 +1,52 @@
[gd_scene load_steps=2 format=3 uid="uid://c8on0ngoa3108"]
[ext_resource type="Script" path="res://scripts/ui/MainScreen.gd" id="1_lgjmg"]
[node name="MainScreen" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_lgjmg")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="Play" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Play"
[node name="ResolutionLabel" type="Label" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Resolution"
[node name="QualitySlider" type="HSlider" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
min_value = 0.25
max_value = 2.0
step = 0.05
value = 1.0
[node name="Options" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Options"
[node name="OptionButton" type="OptionButton" parent="MarginContainer/VBoxContainer"]
visible = false
layout_mode = 2
[node name="Quit" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Quit"
[connection signal="pressed" from="MarginContainer/VBoxContainer/Play" to="." method="_on_play_pressed"]
[connection signal="value_changed" from="MarginContainer/VBoxContainer/QualitySlider" to="." method="_on_quality_slider_value_changed"]
[connection signal="item_selected" from="MarginContainer/VBoxContainer/OptionButton" to="." method="_on_option_button_item_selected"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]

View file

@ -0,0 +1,88 @@
extends CharacterBody3D
signal pause_game(is_paused)
const SPEED = 20.0
const JUMP_VELOCITY = 25
const ACCELERATION = 50.0
const DECCELERATION = 5.0
var mouse_sensitivity = 0.0198125 / 2 #Valorant 0.14 - factor de conversió a 1080p: 0.141517857142857
var count_down_started = false
var damage = 10
var shot_count = 0
var direction = Vector3()
@onready var head = $Head
@onready var camera = $Head/Camera3D
@onready var raycast = $Head/Camera3D/RayCast3D
@onready var bullet_hole = preload("res://scenes/ui/BulletHole.tscn")
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready():
emit_signal("pause_game", false)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func fire():
if Input.is_action_just_pressed("fire"):
if raycast.is_colliding():
var target = raycast.get_collider()
var bullet_hole_instance = bullet_hole.instantiate()
target.add_child(bullet_hole_instance)
bullet_hole_instance.global_transform.origin = raycast.get_collision_point()
bullet_hole_instance.look_at(position + Vector3.FORWARD, raycast.get_collision_normal())
if target.is_in_group("Enemy"):
target.health -= damage
shot_count += 1
if (!count_down_started):
count_down_started = true
func _input(event):
if event is InputEventMouseMotion:
head.rotate_y(deg_to_rad(-event.relative.x * mouse_sensitivity))
camera.rotate_x(deg_to_rad(-event.relative.y * mouse_sensitivity))
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-89), deg_to_rad(89))
else:
if event.is_action_pressed("ui_cancel"):
emit_signal("pause_game", true)
func _physics_process(delta):
fire()
# Add the gravity.
if not is_on_floor():
velocity.y -= (gravity * 6) * delta
# Handle Jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("left", "right", "up", "down")
var thedirection = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if thedirection:
# Check if the direction has changed.
if thedirection.dot(velocity.normalized()) < 0:
# Instantly stop the velocity.
velocity = Vector3.ZERO
else:
# Add acceleration to the velocity.
velocity += thedirection * ACCELERATION * delta
# Limit the velocity to the maximum speed.
if velocity.length() > SPEED:
velocity = velocity.normalized() * SPEED
else:
# Decelerate the velocity.
velocity -= velocity * DECCELERATION * delta
move_and_slide()

View file

@ -0,0 +1,40 @@
extends CharacterBody3D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
signal target_kill
var id_spawn_target = null
var lavelocitat = null
var health = 10
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func init(size = 0.5, id_spawn = null, movement = false):
randomize()
self.scale = Vector3(size, size, size)
if movement:
lavelocitat = Vector3(randf_range(-10, 10), randf_range(-10, 10), randf_range(-10, 10))
id_spawn_target = id_spawn
func _process(_delta):
if health <= 0:
emit_signal("target_kill")
#DataManager.last_vectors.erase(id_spawn_target)
queue_free()
func _physics_process(delta):
if lavelocitat:
var collision_info = move_and_collide(lavelocitat * delta)
if collision_info:
lavelocitat = lavelocitat.bounce(collision_info.get_normal())

3
scripts/global.gd Normal file
View file

@ -0,0 +1,3 @@
extends Node
var game_type = ""

41
scripts/levels/Pause.gd Normal file
View file

@ -0,0 +1,41 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var the_new_pause_state = false
#
#func _input(event):
# if event.is_action_pressed("ui_cancel"):
# trigger_pause(not get_tree().paused)
func _notification(what):
if what == MainLoop.NOTIFICATION_APPLICATION_FOCUS_OUT:
trigger_pause(true)
func trigger_pause(new_pause_state):
the_new_pause_state = new_pause_state
get_tree().paused = the_new_pause_state
visible = the_new_pause_state
if (the_new_pause_state):
$Buttons/Resume.grab_focus()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _on_resume_pressed():
trigger_pause(false)
func _on_menu_pressed():
get_tree().paused = false
get_tree().change_scene_to_file("res://scenes/ui/MainScreen.tscn")
func _on_player_pause_game(is_paused):
trigger_pause(is_paused)

121
scripts/levels/World.gd Normal file
View file

@ -0,0 +1,121 @@
extends Node3D
var packed_target = preload("res://scenes/characters/target.tscn")
var location_target = Vector3()
var count_kills = 0
var id_spawn_target = 0
#Game parameters
var spawn_location_x_0 = 12
var spawn_location_x_1 = -12
var spawn_location_y_0 = 4
var spawn_location_y_1 = 20
var number_of_initial_targets = 1
var size = 0.5
var movment = false
#@onready var anim_hit = $FPS/Head/Camera3D/AnimationHit
# Called when the node enters the scene tree for the first time.
func _ready():
id_spawn_target = 0
count_kills = 0
var id_game = Global.game_type
if(id_game == "3d_head_level_v1"):
spawn_location_x_0 = 24
spawn_location_x_1 = -24
spawn_location_y_0 = 4
spawn_location_y_1 = 4
movment = false
size = 0.5
number_of_initial_targets = 1
elif(id_game == "3d_multiple_basic_targets_movement_v1"):
spawn_location_x_0 = 12
spawn_location_x_1 = -12
spawn_location_y_0 = 4
spawn_location_y_1 = 20
movment = true
size = 0.5
number_of_initial_targets = 6
elif(id_game == "3d_multiple_basic_targets_v1"):
spawn_location_x_0 = 12
spawn_location_x_1 = -12
spawn_location_y_0 = 4
spawn_location_y_1 = 20
movment = false
size = 0.5
number_of_initial_targets = 6
elif(id_game == "3d_multiple_medium_targets_v1"):
spawn_location_x_0 = 11
spawn_location_x_1 = -11
spawn_location_y_0 = 4
spawn_location_y_1 = 15
movment = false
size = 3
number_of_initial_targets = 3
else:
spawn_location_x_0 = 12
spawn_location_x_1 = -12
spawn_location_y_0 = 4
spawn_location_y_1 = 20
movment = false
size = 0.5
number_of_initial_targets = 1
for x in range(number_of_initial_targets):
spawn_target()
func target_killed():
messageHit()
spawn_target()
func randomize_vector():
randomize()
var location_x = randf_range(spawn_location_x_0, spawn_location_x_1)
var location_y = randf_range(spawn_location_y_0, spawn_location_y_1)
var location_z = -25
return Vector3(location_x, location_y, location_z)
func check_distance():
var vector_return = randomize_vector()
var distance = 0
var have_distance = true
#if (DataManager.last_vectors.keys().size() > 0):
# for last_key in DataManager.last_vectors.keys():
# distance = DataManager.last_vectors[last_key].distance_to(vector_return)
# if(distance < (size * 2)):
# have_distance = false
return [have_distance, vector_return, distance]
func spawn_target():
id_spawn_target += 1
var return_distance_array = check_distance()
var count_max = 0
while return_distance_array[0] != true and count_max < 100:
count_max += 1
return_distance_array = check_distance()
var vector_return = return_distance_array[1]
location_target.x = vector_return.x
location_target.y = vector_return.y
location_target.z = vector_return.z
#DataManager.last_vectors[id_spawn_target] = vector_return
var target = packed_target.instantiate()
target.init(size, id_spawn_target, movment)
target.connect("target_kill", Callable(self, "target_killed"))
target.set_position(location_target)
add_child(target)
func messageHit():
count_kills += 1
#$FPS/Head/Camera3D/LeftVBoxContainer/Kills.set_text((str(count_kills)))
#if not anim_hit.is_playing():
# anim_hit.play("animationHit")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func _on_menu_pressed():
pass # Replace with function body.

15
scripts/ui/BulletHole.gd Normal file
View file

@ -0,0 +1,15 @@
extends Node3D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func _on_timer_timeout():
queue_free()

90
scripts/ui/Crosshair.gd Normal file
View file

@ -0,0 +1,90 @@
extends Control
var global_color = Color(0, 255, 255, 1)
var global_outline_color = Color(0,0,0)
var enable_crosshair = true
var enable_outline = true
var crosshair_inner_enable = true
var dot_enable = false
#var global_crosshair_heigh = DataManager.get_options("heigh", "float")
#var global_crosshair_width = DataManager.get_options("width", "float")
var dot_size = 3
var global_outline_width = 0.5 * 2
var global_crosshair_heigh = 1 * 2
var global_crosshair_width = 4 * 2
var global_crosshair_space = 1.5 * 2
var dot_crosshair = [
Vector2(-dot_size,-dot_size), #top left
Vector2(dot_size,-dot_size), #top right
Vector2(dot_size,dot_size), #bottom right
Vector2(-dot_size,dot_size) #bottom left
]
var left_inner_crosshair = [
Vector2(-global_crosshair_width-global_crosshair_space,-global_crosshair_heigh), #top left
Vector2(0-global_crosshair_space,-global_crosshair_heigh),#top right
Vector2(0-global_crosshair_space,global_crosshair_heigh), #bottom right
Vector2(-global_crosshair_width-global_crosshair_space,global_crosshair_heigh) #bottom left
]
var top_inner_crosshair = [
Vector2(-global_crosshair_heigh,-global_crosshair_width-global_crosshair_space), #top left
Vector2(global_crosshair_heigh,-global_crosshair_width-global_crosshair_space),#top right
Vector2(global_crosshair_heigh,-global_crosshair_space), #bottom right
Vector2(-global_crosshair_heigh,-global_crosshair_space) #bottom left
]
var right_inner_crosshair = [
Vector2(0+global_crosshair_space,-global_crosshair_heigh), #top left
Vector2(global_crosshair_width+global_crosshair_space,-global_crosshair_heigh),#top right
Vector2(global_crosshair_width+global_crosshair_space,global_crosshair_heigh),#bottom right
Vector2(0+global_crosshair_space,global_crosshair_heigh) #bottom left
]
var bottom_inner_crosshair = [
Vector2(-global_crosshair_heigh, global_crosshair_space), #top left
Vector2(global_crosshair_heigh,global_crosshair_space),#top right
Vector2(global_crosshair_heigh,global_crosshair_space+global_crosshair_width), #bottom right
Vector2(-global_crosshair_heigh,global_crosshair_space+global_crosshair_width) #bottom left
]
func redraw(_value):
queue_redraw()
func _draw():
if dot_enable and enable_crosshair:
polygonDrawer(dot_crosshair, global_color, global_outline_width, global_outline_color)
if crosshair_inner_enable and enable_crosshair:
polygonDrawer(left_inner_crosshair, global_color, global_outline_width, global_outline_color)
polygonDrawer(top_inner_crosshair, global_color, global_outline_width, global_outline_color)
polygonDrawer(right_inner_crosshair, global_color, global_outline_width, global_outline_color)
polygonDrawer(bottom_inner_crosshair, global_color, global_outline_width, global_outline_color)
func polygonDrawer(polygon_points, color, outline_width, outline_color):
var points = PackedVector2Array()
var colour = PackedColorArray()
points = polygon_points
colour = [color]
draw_polygon(points,colour)
var polygon = Polygon2D.new()
polygon.set_polygon(points)
outlinePolygonDrawer(polygon, outline_width, outline_color)
func outlinePolygonDrawer(polygon, outline_width, outline_color):
if enable_outline:
var poly = polygon.get_polygon()
for i in range(1 , poly.size()):
draw_line(poly[i-1] , poly[i], outline_color , outline_width)
draw_line(poly[poly.size() - 1] , poly[0], outline_color , outline_width)

54
scripts/ui/MainScreen.gd Normal file
View file

@ -0,0 +1,54 @@
extends Control
@onready var ResOptionButton = $MarginContainer/VBoxContainer/OptionButton
@onready var resolution_label := $MarginContainer/VBoxContainer/ResolutionLabel
#var Resoltuions: Dictionary = {
# "3840x2160" : Vector2(3840,2160),
# "2560x1440" : Vector2(2560,1440),
# "1920x1080" : Vector2(1920,1080)
# }
# Called when the node enters the scene tree for the first time.
func _ready():
# AddResolutions()
get_viewport().size_changed.connect(self.update_resolution_label)
update_resolution_label()
#func AddResolutions():
# var count = 0
# for resolution in Resoltuions:
# ResOptionButton.add_item(resolution)
# if Resoltuions[resolution] == get_viewport().get_visible_rect().size:
# ResOptionButton.selected = count
# count += 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func update_resolution_label() -> void:
var viewport_render_size = get_viewport().size * get_viewport().scaling_3d_scale
resolution_label.text = "3D viewport resolution: %d × %d (%d%%)" \
% [viewport_render_size.x, viewport_render_size.y, round(get_viewport().scaling_3d_scale * 100)]
func _on_play_pressed():
get_tree().change_scene_to_file("res://scenes/levels/World.tscn")
Global.game_type = "3d_multiple_basic_targets_movement_v1"
#func _on_option_button_item_selected(index):
# var the_size = Resoltuions.get(ResOptionButton.get_item_text(index))
# DisplayServer.window_set_size(the_size)
func _on_quality_slider_value_changed(value: float) -> void:
get_viewport().scaling_3d_scale = value
update_resolution_label()
func _on_quit_pressed():
get_tree().quit()