mirror of
https://github.com/Nokorpo/LibreAim.git
synced 2025-06-11 02:13:43 +09:00
Refactor game world code
This commit is contained in:
parent
0ca1617448
commit
a4974999b0
23 changed files with 111 additions and 146 deletions
|
@ -73,13 +73,13 @@ func load_all_data(file_directory: String = FILE_PATH) -> void:
|
|||
result = json.data
|
||||
game_data = result
|
||||
|
||||
func set_parameter_if_exists(category, parameter, key: String):
|
||||
func set_parameter_if_exists(category: categories, parameter, key: String):
|
||||
var new_value = DataManager.get_data(category, key)
|
||||
if new_value != null:
|
||||
return new_value
|
||||
return parameter
|
||||
|
||||
func set_color_if_exists(category, parameter, key: String) -> Color:
|
||||
func set_color_if_exists(category: categories, parameter: Color, key: String) -> Color:
|
||||
var new_color = set_parameter_if_exists(category, parameter, key)
|
||||
if new_color != null and new_color is String:
|
||||
new_color = Global.string_to_color(new_color)
|
||||
|
|
|
@ -3,11 +3,11 @@ extends Node
|
|||
var gamemodes : Dictionary
|
||||
var current_gamemode : Dictionary
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
Input.set_use_accumulated_input(false)
|
||||
load_gamemodes()
|
||||
|
||||
func load_gamemodes():
|
||||
func load_gamemodes() -> void:
|
||||
const PATH = "res://assets/gamemodes/"
|
||||
|
||||
var dir = DirAccess.open(PATH)
|
||||
|
@ -60,7 +60,6 @@ func get_current_world_texture() -> Texture2D:
|
|||
if !current_texture:
|
||||
current_texture = "checkerboard.png"
|
||||
return load(get_world_textures_path() + current_texture)
|
||||
|
||||
|
||||
func get_world_textures_path() -> String:
|
||||
return "res://assets/images/world/"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
extends Node3D
|
||||
## Bullet hole decals when user shoots
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
var tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SINE)
|
||||
tween.tween_property(self, "modulate:a", 0, 20)
|
||||
await tween.finished
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
extends Control
|
||||
## Renders the user crosshair
|
||||
|
||||
var color := Color(0, 255, 255, 1)
|
||||
var outline_color := Color(0,0,0)
|
||||
|
@ -12,7 +13,7 @@ var thickness := 2.0
|
|||
var length := 12.0
|
||||
var gap := 5.0
|
||||
|
||||
var current_crosshair = {
|
||||
var current_crosshair := {
|
||||
"top": [],
|
||||
"right": [],
|
||||
"bottom": [],
|
||||
|
@ -20,20 +21,21 @@ var current_crosshair = {
|
|||
"dot": []
|
||||
}
|
||||
|
||||
func _draw():
|
||||
load_save()
|
||||
func _draw() -> void:
|
||||
_load_save()
|
||||
_load_crosshair()
|
||||
|
||||
draw_part(current_crosshair["top"])
|
||||
draw_part(current_crosshair["right"])
|
||||
draw_part(current_crosshair["bottom"])
|
||||
draw_part(current_crosshair["left"])
|
||||
_draw_part(current_crosshair["top"])
|
||||
_draw_part(current_crosshair["right"])
|
||||
_draw_part(current_crosshair["bottom"])
|
||||
_draw_part(current_crosshair["left"])
|
||||
if dot_enable:
|
||||
draw_part(current_crosshair["dot"])
|
||||
_draw_part(current_crosshair["dot"])
|
||||
|
||||
func _on_options_refresh_crosshair():
|
||||
func _on_options_refresh_crosshair() -> void:
|
||||
queue_redraw()
|
||||
|
||||
func load_save():
|
||||
func _load_save() -> void:
|
||||
var category = DataManager.categories.CROSSHAIR
|
||||
dot_enable = DataManager.set_parameter_if_exists(category, dot_enable, "dot")
|
||||
dot_size = DataManager.set_parameter_if_exists(category, dot_size, "dot_size")
|
||||
|
@ -44,46 +46,47 @@ func load_save():
|
|||
outline_width = DataManager.set_parameter_if_exists(category, outline_width, "outline_width")
|
||||
color = DataManager.set_color_if_exists(category, color, "color")
|
||||
outline_color = DataManager.set_color_if_exists(category, outline_color, "outline_color")
|
||||
|
||||
|
||||
func _load_crosshair() -> void:
|
||||
current_crosshair["dot"] = [
|
||||
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
|
||||
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
|
||||
]
|
||||
current_crosshair["left"] = [
|
||||
Vector2(-length-gap, -thickness), #top left
|
||||
Vector2(-gap, -thickness), #top right
|
||||
Vector2(-gap, thickness), #bottom right
|
||||
Vector2(-length-gap, thickness) #bottom left
|
||||
Vector2(-length-gap, -thickness), # top left
|
||||
Vector2(-gap, -thickness), # top right
|
||||
Vector2(-gap, thickness), # bottom right
|
||||
Vector2(-length-gap, thickness) # bottom left
|
||||
]
|
||||
current_crosshair["top"] = [
|
||||
Vector2(-thickness, -length-gap), #top left
|
||||
Vector2(thickness, -length-gap), #top right
|
||||
Vector2(thickness, -gap), #bottom right
|
||||
Vector2(-thickness, -gap) #bottom left
|
||||
Vector2(-thickness, -length-gap), # top left
|
||||
Vector2(thickness, -length-gap), # top right
|
||||
Vector2(thickness, -gap), # bottom right
|
||||
Vector2(-thickness, -gap) # bottom left
|
||||
]
|
||||
current_crosshair["right"] = [
|
||||
Vector2(gap,-thickness), #top left
|
||||
Vector2(length+gap,-thickness), #top right
|
||||
Vector2(length+gap,thickness), #bottom right
|
||||
Vector2(gap,thickness) #bottom left
|
||||
Vector2(gap,-thickness), # top left
|
||||
Vector2(length+gap,-thickness), # top right
|
||||
Vector2(length+gap,thickness), # bottom right
|
||||
Vector2(gap,thickness) # bottom left
|
||||
]
|
||||
current_crosshair["bottom"] = [
|
||||
Vector2(-thickness, gap), #top left
|
||||
Vector2(thickness,gap), #top right
|
||||
Vector2(thickness,gap+length), #bottom right
|
||||
Vector2(-thickness,gap+length) #bottom left
|
||||
Vector2(-thickness, gap), # top left
|
||||
Vector2(thickness,gap), # top right
|
||||
Vector2(thickness,gap+length), # bottom right
|
||||
Vector2(-thickness,gap+length) # bottom left
|
||||
]
|
||||
|
||||
func draw_part(points: PackedVector2Array):
|
||||
func _draw_part(points: PackedVector2Array) -> void:
|
||||
draw_polygon(points, [color])
|
||||
var polygon := Polygon2D.new()
|
||||
polygon.set_polygon(points)
|
||||
if enable_outline:
|
||||
draw_outline(polygon)
|
||||
|
||||
func draw_outline(polygon: Polygon2D):
|
||||
_draw_outline(polygon)
|
||||
|
||||
func _draw_outline(polygon: Polygon2D) -> void:
|
||||
var poly = polygon.get_polygon()
|
||||
for i in range(1 , poly.size()):
|
||||
draw_line(poly[i-1] , poly[i], outline_color , outline_width)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
extends AudioStreamPlayer
|
||||
## Sound played on target destroyed
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
update_hit_sound()
|
||||
|
||||
func _on_volume_updated(_value: float):
|
||||
func _on_volume_updated(_value: float) -> void:
|
||||
update_hit_sound()
|
||||
|
||||
func update_hit_sound():
|
||||
func update_hit_sound() -> void:
|
||||
var volume = DataManager.get_data(DataManager.categories.SETTINGS, "volume")
|
||||
if volume != null:
|
||||
var this_bus = AudioServer.get_bus_index("Master")
|
||||
var this_bus := AudioServer.get_bus_index("Master")
|
||||
AudioServer.set_bus_volume_db(this_bus, lerpf(-20, 0, volume))
|
||||
AudioServer.set_bus_mute(this_bus, volume == 0)
|
||||
var category = DataManager.categories.SETTINGS
|
||||
var category := DataManager.categories.SETTINGS
|
||||
if DataManager.get_data(category, "hit_sound") != null:
|
||||
var selected = DataManager.get_data(category, "hit_sound")
|
||||
stream = load(Audio.hit_sounds[selected])
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
extends Control
|
||||
## Canvas shown when game ends
|
||||
|
||||
func set_score(score: int, high_score: int) -> void:
|
||||
$Button.grab_focus()
|
||||
|
|
|
@ -54,7 +54,7 @@ func spawn_target() -> void:
|
|||
target.set_position(spawn_position)
|
||||
add_child(target)
|
||||
|
||||
func update_world_environment():
|
||||
func update_world_environment() -> void:
|
||||
var world_material = preload("res://assets/images/mat_filldummy.tres")
|
||||
world_material.albedo_texture = Global.get_current_world_texture()
|
||||
const CATEGORY = DataManager.categories.SETTINGS
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=32 format=3 uid="uid://cdbhv0p0jfr75"]
|
||||
[gd_scene load_steps=31 format=3 uid="uid://cdbhv0p0jfr75"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/game_world/game_world.gd" id="1_4pv4x"]
|
||||
[ext_resource type="Material" uid="uid://dsqe2mx1kgicf" path="res://assets/images/mat_filldummy.tres" id="2_ldkna"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/player_manager.gd" id="3_cvlpu"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/player/player_manager.gd" id="3_cvlpu"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/crosshair.gd" id="4_pc15u"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/gameplay_ui.gd" id="5_of43n"]
|
||||
[ext_resource type="Texture2D" uid="uid://1xnrooyjmggn" path="res://assets/images/hit_marker.svg" id="6_efh5s"]
|
||||
|
@ -10,7 +10,6 @@
|
|||
[ext_resource type="Script" path="res://scenes/game_world/pause.gd" id="7_ffgmh"]
|
||||
[ext_resource type="Theme" uid="uid://caf1fphx2xqt0" path="res://assets/themes/main_menu.tres" id="7_gwa7l"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmrheauks0nru" path="res://assets/images/icons/cross.svg" id="8_6pksd"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/mouse_capture.gd" id="10_vngrv"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/end_game_canvas.gd" id="12_w3gpo"]
|
||||
[ext_resource type="AudioStream" uid="uid://c1ons03xoggga" path="res://scenes/enemies/beep.ogg" id="12_xv1t2"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/destroyed_sound.gd" id="13_mss18"]
|
||||
|
@ -446,41 +445,6 @@ text = "Menu"
|
|||
icon = ExtResource("8_6pksd")
|
||||
alignment = 0
|
||||
|
||||
[node name="MouseCapturedRequest" 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("10_vngrv")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="CanvasLayer/MouseCapturedRequest"]
|
||||
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)
|
||||
|
||||
[node name="MouseCapturedNeeded" type="Button" parent="CanvasLayer/MouseCapturedRequest"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -503.5
|
||||
offset_top = -60.0
|
||||
offset_right = 503.5
|
||||
offset_bottom = 60.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "Mouse captured is needed."
|
||||
|
||||
[node name="EndGameCanvas" type="Control" parent="CanvasLayer"]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
|
@ -559,5 +523,4 @@ script = ExtResource("13_mss18")
|
|||
[connection signal="shooted" from="Player" to="CanvasLayer/GameplayUI" method="_on_player_shoot"]
|
||||
[connection signal="pressed" from="CanvasLayer/PauseManager/Pause/Buttons/Resume" to="CanvasLayer/PauseManager" method="_on_resume_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/PauseManager/Pause/Buttons/Menu" to="CanvasLayer/PauseManager" method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/MouseCapturedRequest/MouseCapturedNeeded" to="CanvasLayer/MouseCapturedRequest" method="_on_mouse_captured_needed_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/EndGameCanvas/Button" to="CanvasLayer/EndGameCanvas" method="_on_button_pressed"]
|
||||
|
|
|
@ -6,12 +6,12 @@ extends Control
|
|||
@onready var timer = $"../../Timer"
|
||||
@onready var timer_label = $MarginContainer/Panel/MarginContainer/VBoxContainer/time/label2
|
||||
|
||||
func update_kills(value: int):
|
||||
func update_kills(value: int) -> void:
|
||||
kills.set_text((str(value)))
|
||||
if not animation_kill.is_playing():
|
||||
animation_kill.play("kill")
|
||||
|
||||
func update_timer_ui(time_left):
|
||||
func update_timer_ui(time_left) -> void:
|
||||
timer_label.set_text("%.f s" % time_left)
|
||||
|
||||
func _on_player_shoot() -> void:
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
extends Control
|
||||
|
||||
func _on_mouse_captured_needed_pressed():
|
||||
get_tree().paused = false
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
visible = false
|
|
@ -1,14 +1,14 @@
|
|||
extends Node
|
||||
|
||||
func _input(event):
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
trigger_pause(true)
|
||||
|
||||
func _notification(what):
|
||||
func _notification(what: int) -> void:
|
||||
if what == MainLoop.NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
trigger_pause(true)
|
||||
|
||||
func trigger_pause(new_pause_state):
|
||||
func trigger_pause(new_pause_state: bool) -> void:
|
||||
get_tree().paused = new_pause_state
|
||||
$Pause.visible = new_pause_state
|
||||
if (new_pause_state):
|
||||
|
@ -17,9 +17,9 @@ func trigger_pause(new_pause_state):
|
|||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
func _on_resume_pressed():
|
||||
func _on_resume_pressed() -> void:
|
||||
trigger_pause(false)
|
||||
|
||||
func _on_menu_pressed():
|
||||
func _on_menu_pressed() -> void:
|
||||
get_tree().paused = false
|
||||
get_tree().change_scene_to_file("res://scenes/main_menu/main_menu.tscn")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://dkiet13jnna2m"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/game_world/player_manager.gd" id="1_txs4e"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/player/player_manager.gd" id="1_txs4e"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/crosshair.gd" id="2_w1fsa"]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_trh1v"]
|
|
@ -1,7 +1,9 @@
|
|||
extends CharacterBody3D
|
||||
## First person character controller
|
||||
|
||||
signal shooted
|
||||
|
||||
const SHOOT_COOLDOWN = 0.2
|
||||
const SPEED := 5
|
||||
const JUMP_FORCE := 8
|
||||
const MAX_CAMERA_ANGLE := 89 ## Max vertical angle of the camera
|
||||
|
@ -10,48 +12,43 @@ var mouse_sensitivity := 0.01
|
|||
|
||||
var jumps := [true, true]
|
||||
var gravity := 0.0
|
||||
var current_shoot_cooldown: float
|
||||
|
||||
@onready var camera = $Head/Camera3D
|
||||
@onready var raycast = $Head/Camera3D/RayCast3D
|
||||
@onready var bullet_hole = preload("res://scenes/game_world/bullet_hole.tscn")
|
||||
|
||||
func _ready() -> void:
|
||||
var user_sensitivity := 1
|
||||
var conversion_sensitivity := 0.022
|
||||
var category := DataManager.categories.SETTINGS
|
||||
|
||||
conversion_sensitivity = DataManager.set_parameter_if_exists(category, conversion_sensitivity, "sensitivity_game_value")
|
||||
user_sensitivity = DataManager.set_parameter_if_exists(category, user_sensitivity, "sensitivity")
|
||||
camera.fov = DataManager.set_parameter_if_exists(category, camera.fov, "camera_fov")
|
||||
mouse_sensitivity = user_sensitivity * conversion_sensitivity
|
||||
print(str(user_sensitivity) + " " + str(conversion_sensitivity))
|
||||
const CATEGORY := DataManager.categories.SETTINGS
|
||||
camera.fov = DataManager.set_parameter_if_exists(CATEGORY, camera.fov, "camera_fov")
|
||||
mouse_sensitivity = _get_mouse_sensitivity()
|
||||
|
||||
func _input(event) -> void:
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
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(-MAX_CAMERA_ANGLE), deg_to_rad(MAX_CAMERA_ANGLE))
|
||||
if Global.current_gamemode and Global.current_gamemode.health == 0:
|
||||
if event.is_action_pressed("shoot"):
|
||||
shoot(1)
|
||||
if event.is_action_pressed("jump") and ((Global.current_gamemode and Global.current_gamemode.player_movement) or Global.current_gamemode.is_empty()):
|
||||
jump()
|
||||
_shoot(1)
|
||||
if event.is_action_pressed("jump") \
|
||||
and ((Global.current_gamemode and Global.current_gamemode.player_movement) \
|
||||
or Global.current_gamemode.is_empty()):
|
||||
_jump()
|
||||
|
||||
var elapsed: float
|
||||
func _process(delta):
|
||||
const COOLDOWN = .2
|
||||
func _process(delta: float) -> void:
|
||||
if Global.current_gamemode and Global.current_gamemode.health > 0:
|
||||
elapsed += delta
|
||||
if elapsed > COOLDOWN:
|
||||
current_shoot_cooldown += delta
|
||||
if current_shoot_cooldown > SHOOT_COOLDOWN:
|
||||
if Input.is_action_pressed("shoot"):
|
||||
shoot(COOLDOWN)
|
||||
elapsed = 0
|
||||
_shoot(SHOOT_COOLDOWN)
|
||||
current_shoot_cooldown = 0
|
||||
|
||||
handle_joypad_rotation(delta)
|
||||
_handle_joypad_rotation(delta)
|
||||
|
||||
func _physics_process(delta) -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
if (Global.current_gamemode and Global.current_gamemode.player_movement) or Global.current_gamemode.is_empty():
|
||||
handle_gravity(delta)
|
||||
_handle_gravity(delta)
|
||||
var input := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
||||
var movement_velocity := Vector3(input.x, 0, input.y) * SPEED
|
||||
movement_velocity = transform.basis * movement_velocity
|
||||
|
@ -62,28 +59,36 @@ func _physics_process(delta) -> void:
|
|||
velocity = applied_velocity
|
||||
move_and_slide()
|
||||
|
||||
func handle_joypad_rotation(delta):
|
||||
func _get_mouse_sensitivity() -> float:
|
||||
const CATEGORY := DataManager.categories.SETTINGS
|
||||
var user_sensitivity := 1
|
||||
var conversion_sensitivity := 0.022
|
||||
conversion_sensitivity = DataManager.set_parameter_if_exists(CATEGORY, conversion_sensitivity, "sensitivity_game_value")
|
||||
user_sensitivity = DataManager.set_parameter_if_exists(CATEGORY, user_sensitivity, "sensitivity")
|
||||
return user_sensitivity * conversion_sensitivity
|
||||
|
||||
func _handle_joypad_rotation(delta: float) -> void:
|
||||
var joypad_dir: Vector2 = Input.get_vector("look_left", "look_right", "look_up", "look_down")
|
||||
if joypad_dir.length() > 0:
|
||||
rotate_y(deg_to_rad(-joypad_dir.x * mouse_sensitivity * delta * 1000))
|
||||
camera.rotate_x(deg_to_rad(-joypad_dir.y * mouse_sensitivity * delta * 1000))
|
||||
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-MAX_CAMERA_ANGLE), deg_to_rad(MAX_CAMERA_ANGLE))
|
||||
|
||||
func handle_gravity(delta):
|
||||
func _handle_gravity(delta: float) -> void:
|
||||
gravity += 20 * delta
|
||||
if gravity > 0 and is_on_floor():
|
||||
for i in range(jumps.size()):
|
||||
jumps[i] = true
|
||||
gravity = 0
|
||||
|
||||
func jump():
|
||||
func _jump() -> void:
|
||||
for i in range(jumps.size()):
|
||||
if jumps[i]:
|
||||
jumps[i] = false
|
||||
gravity = -JUMP_FORCE
|
||||
return
|
||||
|
||||
func shoot(damage: float):
|
||||
func _shoot(damage: float) -> void:
|
||||
shooted.emit()
|
||||
if raycast.is_colliding():
|
||||
var target = raycast.get_collider()
|
|
@ -3,17 +3,16 @@ extends CharacterBody3D
|
|||
signal destroyed
|
||||
|
||||
@onready var mesh := $CollisionShape3D/MeshInstance3D
|
||||
var color: Color
|
||||
|
||||
var current_velocity = null
|
||||
var health = 0.0:
|
||||
var health: float = 0.0:
|
||||
set(value):
|
||||
health = value
|
||||
if health < 0.0:
|
||||
emit_signal("destroyed")
|
||||
queue_free()
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
health = Global.current_gamemode.health
|
||||
var category = DataManager.categories.SETTINGS
|
||||
if DataManager.get_data(category, "target_color") != null:
|
||||
|
@ -22,16 +21,16 @@ func _ready():
|
|||
material_override.set_emission(Global.string_to_color(DataManager.get_data(category, "target_color")))
|
||||
mesh.material_override = material_override
|
||||
|
||||
func init(size = {"radius": .5, "height": 1}, movement = {"x": 0, "y": 0}):
|
||||
func _physics_process(delta: float) -> void:
|
||||
if current_velocity:
|
||||
var collision_info = move_and_collide(current_velocity * delta)
|
||||
if collision_info:
|
||||
current_velocity = current_velocity.bounce(collision_info.get_normal())
|
||||
|
||||
func init(size = {"radius": .5, "height": 1}, movement = {"x": 0, "y": 0}) -> void:
|
||||
$CollisionShape3D.shape.radius = size.radius
|
||||
$CollisionShape3D.shape.height = size.height
|
||||
$CollisionShape3D/MeshInstance3D.mesh.radius = size.radius
|
||||
$CollisionShape3D/MeshInstance3D.mesh.height = size.height
|
||||
current_velocity = Vector3(randf_range(-movement.x, movement.x),\
|
||||
randf_range(-movement.y, movement.y), 0)
|
||||
|
||||
func _physics_process(delta):
|
||||
if current_velocity:
|
||||
var collision_info = move_and_collide(current_velocity * delta)
|
||||
if collision_info:
|
||||
current_velocity = current_velocity.bounce(collision_info.get_normal())
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://cmrheauks0nru" path="res://assets/images/icons/cross.svg" id="5_nidys"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/select_gamemode.gd" id="6_5wgje"]
|
||||
[ext_resource type="Texture2D" uid="uid://db8p3tq5cc85j" path="res://assets/images/icons/play-big.svg" id="7_o4hi3"]
|
||||
[ext_resource type="PackedScene" uid="uid://cropshnueuiqr" path="res://scenes/main_menu/settings.tscn" id="8_1n7gf"]
|
||||
[ext_resource type="PackedScene" uid="uid://cropshnueuiqr" path="res://scenes/main_menu/settings/settings.tscn" id="8_1n7gf"]
|
||||
[ext_resource type="Texture2D" uid="uid://drihvhiutdffn" path="res://assets/images/gamemodes/random.svg" id="9_am488"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nqr84"]
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://cropshnueuiqr"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings.gd" id="1_4ilr3"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings.gd" id="1_4ilr3"]
|
||||
[ext_resource type="Texture2D" uid="uid://ql8v8tau18u1" path="res://assets/images/icons/checkbox_checked.svg" id="2_gf318"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/crosshair.gd" id="2_iu82h"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_crosshair.gd" id="3_1x3bu"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_crosshair.gd" id="3_1x3bu"]
|
||||
[ext_resource type="Texture2D" uid="uid://dfccfxiw0aqif" path="res://assets/images/icons/export-file.svg" id="3_ljukx"]
|
||||
[ext_resource type="Texture2D" uid="uid://btgrnb8ku7dyk" path="res://assets/images/icons/import-file.svg" id="4_e248v"]
|
||||
[ext_resource type="PackedScene" uid="uid://db0ivgs28q5rr" path="res://scenes/main_menu/settings/slider_setting.tscn" id="6_bpfs5"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_video.gd" id="6_tj5ad"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_controls.gd" id="7_1g678"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_world_appareance.gd" id="9_78isq"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_audio.gd" id="10_0bjg8"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_video.gd" id="6_tj5ad"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_controls.gd" id="7_1g678"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_world_appareance.gd" id="9_78isq"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_audio.gd" id="10_0bjg8"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6xs7w20eke54" path="res://assets/images/checkerboard.png" id="10_tgbab"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings_fps_limit.gd" id="11_8bk84"]
|
||||
[ext_resource type="Script" path="res://scenes/main_menu/settings/settings_fps_limit.gd" id="11_8bk84"]
|
||||
[ext_resource type="Script" path="res://scenes/game_world/destroyed_sound.gd" id="11_yfmwu"]
|
||||
[ext_resource type="Texture2D" uid="uid://nng31j22g6fh" path="res://assets/images/icons/play.svg" id="13_8vd46"]
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue