fixed hud, moved weapon and ammo penalties to gamemode

This commit is contained in:
derek
2025-03-18 10:16:09 -05:00
parent d17bc56ca2
commit 891ae8a7f2
10 changed files with 79 additions and 42 deletions

BIN
App Icons/Icon1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6svuq1l83al5"
path="res://.godot/imported/Icon1.png-6bc1f7b30a53163cad4e949176271bb8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://App Icons/Icon1.png"
dest_files=["res://.godot/imported/Icon1.png-6bc1f7b30a53163cad4e949176271bb8.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
App Icons/Icon1.psd Normal file

Binary file not shown.

View File

@@ -36,3 +36,22 @@ class_name gamemode
@export var stamina_drop_enabled = true
@export var health_drop_enabled = true
@export var money_drop_enabled = true
func apply_weapon_penalty():
for i in GameGlobals.ammo_reserve:
GameGlobals.ammo_reserve[i] *= ammo_drop_percentage
match weapon_penalty:
0: #Drop All
GameGlobals.held_guns = []
1: #Drop Percentage
var weapons_lost = GameGlobals.held_guns.size() * weapon_drop_percentage
for weapon in weapons_lost:
GameGlobals.held_guns.erase(GameGlobals.held_guns.pick_random())
2: #Do Nothing
pass
func apply_money_penalty():
#Do money penalty
GameGlobals.money *= money_lost_multiplier
GameGlobals.deposited_money = GameGlobals.money

View File

@@ -89,17 +89,16 @@ texture_progress = ExtResource("4_ooaul")
[node name="WobbleItems" type="Control" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -1152.0
offset_bottom = -648.0
grow_horizontal = 2
grow_vertical = 2
[node name="Money" type="Label" parent="WobbleItems"]
layout_mode = 1
anchors_preset = 2
layout_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 44.975
@@ -114,8 +113,7 @@ text = "$"
[node name="HealthBar" type="ProgressBar" parent="WobbleItems"]
custom_minimum_size = Vector2(300, 50)
layout_mode = 1
anchors_preset = 2
layout_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 50.38
@@ -130,8 +128,7 @@ value = 30.45
show_percentage = false
[node name="LeftMargin" type="MarginContainer" parent="WobbleItems"]
layout_mode = 1
anchors_preset = 2
layout_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = 483.0
@@ -148,8 +145,7 @@ layout_mode = 2
theme_override_constants/separation = 10
[node name="GunInfo" type="MarginContainer" parent="WobbleItems"]
layout_mode = 1
anchors_preset = 3
layout_mode = 2
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0

View File

@@ -14,7 +14,7 @@ config/name="First Person Test"
config/tags=PackedStringArray("fps")
run/main_scene="uid://f7e0v1r6ra6c"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="uid://gx3iw54iemho"
config/icon="uid://6svuq1l83al5"
[autoload]

View File

@@ -163,8 +163,8 @@ func cleared():
func die():
SignalBus.emit_signal("player_exiting_tree")
#record stats
GameGlobals.money_penalty()
GameGlobals.weapon_penalty()
gamemode.apply_money_penalty()
gamemode.apply_weapon_penalty()
if GameGlobals.player_deaths:
GameGlobals.player_deaths += 1
SaveLoad.save_user_data()

View File

@@ -43,23 +43,3 @@ func deposit_money():
func _process(delta: float) -> void:
pass
#print("current level : ",get_tree().current_scene.scene_file_path)
func money_penalty():
var level_control = get_tree().current_scene
#Do money penalty
money = money * level_control.gamemode.money_lost_multiplier
deposited_money = money
func weapon_penalty():
var level_control = get_tree().current_scene
GameGlobals.ammo_reserve = {}
match level_control.gamemode.weapon_penalty:
0: #Drop All
GameGlobals.held_guns = []
1: #Drop Percentage
var weapons_lost = GameGlobals.held_guns.size() * level_control.gamemode.weapon_drop_percentage
for weapon in weapons_lost:
GameGlobals.held_guns.erase(GameGlobals.held_guns.pick_random())
2: #Do Nothing
pass

View File

@@ -42,6 +42,8 @@ const CROSSHAIR_SIZE = Vector2(40,40)
var pickup_notifs = []
var can_spawn = true
var dir_clamped = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Get Viewport size
@@ -227,16 +229,21 @@ func player_hit():
func hud_wobble(delta):
var viewport_height_adj = (get_viewport().size.y/1080)
var HUD_WOBBLE_MAX : float = 40 * viewport_height_adj
var MOUSE_AMT = 10 * viewport_height_adj
var HUD_WOBBLE_MAX : float = 4 * viewport_height_adj
var MOUSE_AMT = 1 * viewport_height_adj
var VELOCITY_AMT = 100 * viewport_height_adj
var HUD_SPEED = 10 * viewport_height_adj
var HUD_MOVE_SPEED = 1 * viewport_height_adj
var HUD_RETURN_SPEED = 10 * viewport_height_adj
var dir_mouse = Vector2(-player.mouse_input.x * MOUSE_AMT,-player.mouse_input.y * MOUSE_AMT)
var velocity_dir_transformed = player.velocity.normalized() * player.global_basis
var velocity_lengh_clamped = clamp(player.velocity.length(),-VELOCITY_AMT,VELOCITY_AMT)
var dir_velocity = Vector2(-velocity_dir_transformed.x * velocity_lengh_clamped,velocity_dir_transformed.y * velocity_lengh_clamped)
var dir_clamped = clamp(dir_mouse + dir_velocity,Vector2(-HUD_WOBBLE_MAX,-HUD_WOBBLE_MAX),Vector2(HUD_WOBBLE_MAX,HUD_WOBBLE_MAX))
var offset = lerp(position, dir_clamped, delta * HUD_SPEED)
return offset
#add movement
dir_clamped += clamp(dir_mouse + dir_velocity,Vector2(-HUD_WOBBLE_MAX,-HUD_WOBBLE_MAX),Vector2(HUD_WOBBLE_MAX,HUD_WOBBLE_MAX))
#return to zero over time
dir_clamped = lerp(dir_clamped,Vector2.ZERO,delta * HUD_RETURN_SPEED)
#apply offset
return dir_clamped

View File

@@ -1,4 +1,5 @@
extends Node
class_name SwitchBasic
@export var switch_override : bool = false
@export var start_on : bool = false