fuzzyworld

godot-shooter / commit

Add some comments to the world scene and change the radar behavior so the alpha of items ranges are .2-1, instead of 0-1, where the radar item sometimes disappears.

660d0c9dd9c1df85463d7ad385695be9a7228341 · Pavel Safronov · 2023-11-29 14:07:33 -0800 · parents a2c953357dc6

Add some comments to the world scene and change the radar behavior so the alpha of items ranges are .2-1, instead of 0-1, where the radar item sometimes disappears.
 actors/Player.gd | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/actors/Player.gd b/actors/Player.gd
index 95d8e59..2d3dd1c 100644
--- a/actors/Player.gd
+++ b/actors/Player.gd
@@ -61,7 +61,10 @@ func _process(_delta: float) -> void:
 	if dead:
 		return
 
-#	health_label.text = "%s / %s" % [health, max_health]
+	# set the rotation for static controls
+	static_controls.global_rotation = 0
+
+	# set progress bar value and color
 	var pb: ProgressBar = $Graphics/Alive/StaticControls/ProgressBar
 	var health_ratio = float(health) / float(max_health)
 	var health_percentage = health_ratio * 100
@@ -72,17 +75,23 @@ func _process(_delta: float) -> void:
 		pb.modulate = Color.yellow
 	else:
 		pb.modulate = Color.blue
-		
-	static_controls.global_rotation = 0
+
+	# add history to the trail
 	trails.add_position(global_position)
+
+	# set HUD info, like score and current weapon
 	hud.set_current_weapon(weapon)
 	hud.score = score
 
 func _physics_process(delta: float) -> void:
 	if dead:
 		return
+
+	# turn toward target
 	if is_destination_set:
 		turn_towards(destination, delta)
+
+	# limit movement speed
 	var speed = velocity.length()
 	if speed < move_speed:
 		velocity = velocity * (1 + delta * accel_rate)
@@ -90,6 +99,8 @@ func _physics_process(delta: float) -> void:
 	if speed > move_speed:
 		velocity = velocity.normalized() * move_speed
 	velocity = move_and_slide(velocity)
+
+	# rotate to match velocity
 	global_rotation = velocity.angle() + PI/2.0
 
 func show_intro() -> void:
@@ -107,7 +118,7 @@ func update_radar(items: Array, color: Color):
 		var item: Node = i
 		var diff = item.global_position - global_position
 		var dist = diff.length()
-		var ratio = Utils.dist_to_ratio(dist, radar_min_radius, radar_max_radius)
+		var ratio = Utils.dist_to_ratio(dist, radar_min_radius, radar_max_radius) * .8 + .2
 		if dist < radar_min_radius:
 			ratio = 0
 		var angle_to = Vector2.UP.angle_to(diff)