Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/collectables/armor-pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/collectables/armor-pack.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bdk54kv51ny4c"
path="res://.godot/imported/armor-pack.png-8dc79f18c20314a344821163c0faf35d.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/collectables/armor-pack.png"
dest_files=["res://.godot/imported/armor-pack.png-8dc79f18c20314a344821163c0faf35d.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
24 changes: 24 additions & 0 deletions scenes/collectables/armor_pack.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://dk0fef5g4cr4k"]

[ext_resource type="Script" uid="uid://d4aqsx366je2g" path="res://scenes/collectables/collectable.gd" id="1_g0v23"]
[ext_resource type="Texture2D" uid="uid://bdk54kv51ny4c" path="res://assets/collectables/armor-pack.png" id="2_wdav1"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_pbrkj"]
size = Vector2(61, 33)

[node name="ArmorPack" type="Node2D"]
script = ExtResource("1_g0v23")
type = "armor"

[node name="Sprite2D" type="Sprite2D" parent="."]
z_index = 5
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_wdav1")

[node name="Area2D" type="Area2D" parent="."]

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(-0.5, 0.5)
shape = SubResource("RectangleShape2D_pbrkj")

[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
3 changes: 3 additions & 0 deletions scenes/enemies/acid_slug.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ avoidance_mask = 3
wait_time = 0.5
autostart = true

[node name="RayCast2D" type="RayCast2D" parent="." index="7"]
rotation = 1.5708

[connection signal="velocity_computed" from="NavigationAgent2D" to="." method="_on_navigation_agent_2d_velocity_computed"]
[connection signal="timeout" from="AcidTimer" to="." method="_on_acid_timer_timeout"]
19 changes: 18 additions & 1 deletion scenes/enemies/enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ var player_near: bool = false
var navigating: bool
var home_pos: Vector2
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
var attacking: bool = false
var melee_damage: int = 1

@onready var ray: RayCast2D = $RayCast2D

enum {
IDLE,
Expand Down Expand Up @@ -58,6 +62,7 @@ func _process(_delta):
navigation_agent_2d.target_position = target.position
navigating = true

var melee_count = 0
func _physics_process(_delta: float) -> void:
if navigating:
var next_path_position = navigation_agent_2d.get_next_path_position()
Expand All @@ -71,9 +76,21 @@ func _physics_process(_delta: float) -> void:
animated_sprite_2d.frame = 0
elif direction.y <= -0.25:
animated_sprite_2d.frame = 1

velocity = direction * speed
move_and_slide()

if not attacking:
if ray.is_colliding():
var collider = ray.get_collider()
if collider is Hero:
attacking = true
collider.hit(melee_damage)
if attacking and melee_count < 60:
melee_count += 1
else:
attacking = false
melee_count = 0


func _on_attack_area_2d_body_entered(body):
if body.name == "Hero":
Expand Down
3 changes: 3 additions & 0 deletions scenes/enemies/ice_beetle.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ texture = ExtResource("6_shxcu")
[node name="NozzleOffset" type="Marker2D" parent="Weapon"]
position = Vector2(-17, 31)

[node name="RayCast2D" type="RayCast2D" parent="."]
rotation = 1.5708

[connection signal="body_entered" from="AttackArea2D" to="." method="_on_attack_area_2d_body_entered"]
[connection signal="body_exited" from="AttackArea2D" to="." method="_on_attack_area_2d_body_exited"]
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
Expand Down
3 changes: 3 additions & 0 deletions scenes/enemies/lava_ant.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ position = Vector2(9, -12)
scale = Vector2(0.2, 0.2)
texture = ExtResource("9_ckxfm")

[node name="RayCast2D" type="RayCast2D" parent="."]
rotation = 1.5708

[connection signal="body_entered" from="AttackArea2D" to="." method="_on_attack_area_2d_body_entered"]
[connection signal="body_exited" from="AttackArea2D" to="." method="_on_attack_area_2d_body_exited"]
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
Expand Down
25 changes: 19 additions & 6 deletions scenes/hero.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class_name Hero
var can_shoot: bool = true
var can_melee: bool = true
var currently_in_lava: bool = false
var alive: bool = true
var crystals_collected: int = 0
var teleporting: bool = false

Expand Down Expand Up @@ -57,19 +56,24 @@ func _on_collectable_collected(type: String):
crystals_collected += 1
#print("num collected: ", crystals_collected)
$Hud/HBoxContainer/CrystalLabel.text = str(crystals_collected)
if type == "armor":
Globals.player_armor = Globals.player_max_armor

func die():
if alive:
#print("Player died.")
alive=false
get_tree().change_scene_to_file("res://scenes/utility/title.tscn")

func hit(damage: int):
if Globals.player_health<=damage:
die()
else:
animation_player.play("hit")
Globals.player_health -= damage
#print("Player has "+str(Globals.player_health)+" health.")
var cur_armor = Globals.player_armor
if cur_armor > damage:
Globals.player_armor -= damage
else:
var remainder = damage - cur_armor
Globals.player_armor = 0
Globals.player_health -= damage

func teleport_in():
teleporting = true
Expand Down Expand Up @@ -119,6 +123,9 @@ func burn(input:call_state):
burn(call_state.Hold)
call_state.Hold:
if is_in_lava:
if Globals.player_health <= 1:
die()
return
Globals.player_health -= 1
animation_player.play("burning")
await get_tree().create_timer(1.0).timeout
Expand All @@ -139,6 +146,9 @@ func acidify(input: call_state):
acidify(call_state.Hold)
call_state.Hold:
if is_in_acid:
if Globals.player_health <= 2:
die()
return
Globals.player_health -= 2
animation_player.play("acidic")
await get_tree().create_timer(1.0).timeout
Expand All @@ -150,6 +160,9 @@ func acidify(input: call_state):
func damage_over_time(damage: int, num_hits: int, wait_time: float, effect: String):
$Label.text = effect
for i in num_hits:
if Globals.player_health <= damage:
die()
return
Globals.player_health -= damage
if effect == "Burning":
animation_player.play("burning")
Expand Down
6 changes: 5 additions & 1 deletion scenes/levels/level1.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://b4u4kyf0gc6ly"]
[gd_scene load_steps=3 format=3 uid="uid://b4u4kyf0gc6ly"]

[ext_resource type="PackedScene" uid="uid://drmiw8rcswdmk" path="res://scenes/levels/level.tscn" id="1_x6ivy"]
[ext_resource type="PackedScene" uid="uid://dk0fef5g4cr4k" path="res://scenes/collectables/armor_pack.tscn" id="2_4tcl0"]

[node name="Level1" instance=ExtResource("1_x6ivy")]
current_level = 1
jungle_ground = true

[node name="ArmorPack" parent="." index="6" instance=ExtResource("2_4tcl0")]
position = Vector2(529, 586)