Skip to content

Commit

Permalink
Finishing Touches + Balancing
Browse files Browse the repository at this point in the history
- Fullscreen mode is now the default
- Bullet speed increased to 300
- Bullet damage increased to 3
- Fixed: bullets don't always collide with enemies
- Dynamite no longer explodes on impact. It now stops moving when it hits something and explodes after the same 1 second delay.
- Added cooldowns for each of the three tools: pickaxe = 0.5 seconds, revolver and dynamite = 1 second.
- Decreased enemy attack timer to 0.5 seconds (2 attacks per second).
- Increased player's pickaxe attack range.
  • Loading branch information
AyUpItsAli committed Oct 22, 2022
1 parent 1962fda commit fe9c6c5
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 38 deletions.
6 changes: 4 additions & 2 deletions Actors/Enemies/RockHermit.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ext_resource path="res://Actors/Enemies/RockHermit.gd" type="Script" id=2]
[ext_resource path="res://Actors/SoftCollision.tscn" type="PackedScene" id=3]

[sub_resource type="CapsuleShape2D" id=5]
[sub_resource type="CapsuleShape2D" id=1]
radius = 8.0
height = 8.0

Expand All @@ -31,7 +31,7 @@ texture = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape2D" parent="."]
modulate = Color( 0, 0.6, 0.701961, 0.839216 )
position = Vector2( 0, -1 )
shape = SubResource( 5 )
shape = SubResource( 1 )

[node name="SearchRadius" type="Area2D" parent="."]
visible = false
Expand All @@ -56,6 +56,8 @@ shape = SubResource( 3 )
visible = false

[node name="AttackTimer" type="Timer" parent="."]
wait_time = 0.5
one_shot = true

[node name="Hurtbox" type="Area2D" parent="."]
collision_layer = 0
Expand Down
5 changes: 3 additions & 2 deletions Actors/Player/Bullet.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extends Area2D

# Constants
const BULLET_SPEED = 200
const BULLET_DAMAGE = 1
const BULLET_SPEED = 300
const BULLET_DAMAGE = 3

# Variables
var velocity: Vector2
Expand All @@ -25,3 +25,4 @@ func on_area_entered_hurtbox(area):
var node = area.get_parent()
if node.has_method("take_damage"):
node.take_damage(BULLET_DAMAGE)
on_collision(node) # Bullet has collided with enemy
2 changes: 1 addition & 1 deletion Actors/Player/Bullet.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ height = 4.0

[node name="Bullet" type="Area2D"]
collision_layer = 0
collision_mask = 11
collision_mask = 3
script = ExtResource( 2 )

[node name="Sprite" type="Sprite" parent="."]
Expand Down
2 changes: 1 addition & 1 deletion Actors/Player/Dynamite.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func _physics_process(delta):
func on_collision(body):
if destination_reached: return
if body.name == "WallsLayer": return # Pass freely over wall tiles
call_deferred("explode") # Call explode() during idle time
reach_destination() # Dynamite stops moving when it hits something

# Called when the explosion timer times out, OR
# when the dynamite collides with something
Expand Down
1 change: 1 addition & 0 deletions Actors/Player/Dynamite.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ modulate = Color( 0, 0.6, 0.701961, 0.839216 )
shape = SubResource( 1 )

[node name="ExplosionTimer" type="Timer" parent="."]
one_shot = true

[node name="ExplosionRadius" type="Area2D" parent="."]
collision_layer = 0
Expand Down
12 changes: 9 additions & 3 deletions Actors/Player/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ onready var body_sprite: Sprite = $BodySprite
onready var item_sprite: Sprite = $ItemSprite
onready var player_animations: AnimationPlayer = $PlayerAnimations
onready var hitbox: Area2D = $Hitbox
onready var pickaxe_cooldown: Timer = $PickaxeCooldown
onready var revolver_cooldown: Timer = $RevolverCooldown
onready var dynamite_cooldown: Timer = $DynamiteCooldown
onready var attacking_hurtbox: Area2D = $AttackingHurtbox
onready var mining_hurtbox: Area2D = $MiningHurtbox

Expand Down Expand Up @@ -123,7 +126,7 @@ func damage_enemies():
# Called when the user presses left-click.
# Carrys out the action specific to the currently equipped tool.
func use_tool():
if equipped == Tools.PICKAXE:
if equipped == Tools.PICKAXE and pickaxe_cooldown.is_stopped():
attacking = true

match facing:
Expand All @@ -137,22 +140,25 @@ func use_tool():

yield(player_animations, "animation_finished")
attacking = false
elif equipped == Tools.REVOLVER:
pickaxe_cooldown.start()
elif equipped == Tools.REVOLVER and revolver_cooldown.is_stopped():
if PlayerData.remove_item(Globals.ItemIDs.REVOLVER_AMMO):
var clicked_pos = get_global_mouse_position()
var bullet = BULLET.instance()
bullet.position = position
bullet.velocity = position.direction_to(clicked_pos)
bullet.look_at(clicked_pos)
get_parent().add_child(bullet)
elif equipped == Tools.DYNAMITE:
revolver_cooldown.start()
elif equipped == Tools.DYNAMITE and dynamite_cooldown.is_stopped():
if PlayerData.remove_item(Globals.ItemIDs.DYNAMITE_STICK):
var clicked_pos = get_global_mouse_position()
var dynamite = DYNAMITE.instance()
dynamite.position = position
dynamite.destination = clicked_pos
dynamite.rotation_degrees = rand_range(0, 360)
get_parent().add_child(dynamite)
dynamite_cooldown.start()

# Calls the "on_player_interact" method on the first interactable object
# that is currently overlapping with the player's hitbox
Expand Down
14 changes: 13 additions & 1 deletion Actors/Player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,25 @@ shape = SubResource( 2 )

[node name="SoftCollision" parent="." instance=ExtResource( 16 )]

[node name="PickaxeCooldown" type="Timer" parent="."]
wait_time = 0.1
one_shot = true

[node name="RevolverCooldown" type="Timer" parent="."]
wait_time = 0.5
one_shot = true

[node name="DynamiteCooldown" type="Timer" parent="."]
wait_time = 0.5
one_shot = true

[node name="AttackingHurtbox" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 8

[node name="CollisionShape" type="CollisionShape2D" parent="AttackingHurtbox"]
modulate = Color( 0.945098, 0.129412, 0.129412, 0.839216 )
position = Vector2( 17, 0 )
position = Vector2( 19, 0 )
shape = SubResource( 3 )

[node name="MiningHurtbox" type="Area2D" parent="."]
Expand Down
2 changes: 1 addition & 1 deletion GUI/HUD/HUD.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ default_color = Color( 0.0392157, 0.960784, 0.0313726, 1 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
color = Color( 0, 0, 0, 1 )
color = Color( 0, 0, 0, 0 )
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down
1 change: 1 addition & 0 deletions GUI/MainMenu/MainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ onready var quit_button = $QuitButton
onready var loading_screen = $LoadingScreen

func _ready():
loading_screen.color.a = 0 # Ensure the loading screen is transparent
play_button.connect("pressed", self, "on_play_button_pressed")
quit_button.connect("pressed", self, "on_quit_button_pressed")

Expand Down
31 changes: 9 additions & 22 deletions World/Level/Level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ onready var level_title = $HUD/UI/LevelTitle
func _ready():
generate_level() # Generate a new level when this scene is loaded

func _unhandled_input(event):
# DEBUGGING:
# Instantly executes the "on_player_exited_cave" procedure,
# when the Enter key is pressed
if event.is_action_pressed("force_exit_cave"):
on_player_exited_cave()
# DEBUGGING:
# Simulates the loading of the magpie level,
# when the "M" key is pressed
elif event.is_action_pressed("load_magpie_level"):
if not loading_screen.visible:
var animations = loading_screen.get_node("LoadingScreenAnimations")
animations.play("Fade_In")
yield(animations, "animation_finished")
get_tree().change_scene("res://World/MagpieLevel/MagpieLevel.tscn")

func _process(delta):
if objects.player_exists():
var player_pos = objects.get_player().position
Expand All @@ -38,6 +22,10 @@ func _process(delta):

# Generates a new level
func generate_level():
# Ensure the loading screen is visible and fully opaque
loading_screen.visible = true
loading_screen.color.a = 1

# Randomise the rng
GameManager.rng.randomize()

Expand Down Expand Up @@ -66,12 +54,11 @@ func generate_level():
objects.spawn_cave_exit()

# Fade out the loading screen AFTER the level has finished generating
if loading_screen.visible:
var animations = loading_screen.get_node("LoadingScreenAnimations")
animations.play("Fade_Out")
yield(animations, "animation_finished")
GameManager.increase_cave_depth()
level_title.add_title_to_queue("Cave Depth\n" + str(GameManager.cave_depth))
var animations = loading_screen.get_node("LoadingScreenAnimations")
animations.play("Fade_Out")
yield(animations, "animation_finished")
GameManager.increase_cave_depth()
level_title.add_title_to_queue("Cave Depth\n" + str(GameManager.cave_depth))

# Called when the player enters the CaveExit detection radius
func on_player_exited_cave():
Expand Down
13 changes: 8 additions & 5 deletions World/MagpieLevel/MagpieLevel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ onready var loading_screen = $HUD/LoadingScreen
func _ready():
cave_exit.connect("player_entered", self, "on_player_exited_cave")

# Ensure the loading screen is visible and fully opaque
loading_screen.visible = true
loading_screen.color.a = 1

# Reset the number of caves since the magpie level spawned
GameManager.caves_since_magpie = 0

Expand All @@ -28,11 +32,10 @@ func _ready():
camera.limit_bottom = (rect.position.y + rect.size.y - 1) * Globals.CAVE_TILE_SIZE

# Fade out the loading screen
if loading_screen.visible:
var animations = loading_screen.get_node("LoadingScreenAnimations")
animations.play("Fade_Out")
yield(animations, "animation_finished")
level_title.add_title_to_queue("The Magpie")
var animations = loading_screen.get_node("LoadingScreenAnimations")
animations.play("Fade_Out")
yield(animations, "animation_finished")
level_title.add_title_to_queue("The Magpie")

func _process(delta):
var player_tile_pos = rock_layer.world_to_map(player.position)
Expand Down
2 changes: 2 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ shapes/collision/shape_color=Color( 1, 1, 1, 0.419608 )

window/size/width=1920
window/size/height=1080
window/size/resizable=false
window/size/fullscreen=true
window/stretch/mode="2d"
window/stretch/aspect="keep"

Expand Down

0 comments on commit fe9c6c5

Please sign in to comment.