Skip to content

Commit

Permalink
coucou
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocrp committed Jan 24, 2024
1 parent 4a9e5a6 commit d01d10b
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 44 deletions.
3 changes: 3 additions & 0 deletions entities/enemies/orc/orc.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ func take_dmg(damage: int = 1) -> void:
health -= damage
if health <= 0:
queue_free()

func is_orc():
return true;
123 changes: 83 additions & 40 deletions entities/player/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ region = Rect2(0, 64, 64, 64)
atlas = ExtResource("4_pw3kn")
region = Rect2(64, 64, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_ftvn8"]
atlas = ExtResource("7_7n4b4")
region = Rect2(64, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_sru21"]
atlas = ExtResource("5_svamw")
region = Rect2(0, 0, 64, 64)
Expand Down Expand Up @@ -105,10 +109,6 @@ region = Rect2(0, 64, 64, 64)
atlas = ExtResource("7_7n4b4")
region = Rect2(0, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_ftvn8"]
atlas = ExtResource("7_7n4b4")
region = Rect2(64, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_2dau0"]
atlas = ExtResource("7_7n4b4")
region = Rect2(128, 0, 64, 64)
Expand Down Expand Up @@ -145,6 +145,10 @@ region = Rect2(0, 64, 64, 64)
atlas = ExtResource("8_pqlsi")
region = Rect2(64, 64, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_21pmc"]
atlas = ExtResource("10_gbdaa")
region = Rect2(0, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_obl77"]
atlas = ExtResource("9_5e32d")
region = Rect2(0, 0, 64, 64)
Expand All @@ -157,10 +161,6 @@ region = Rect2(64, 0, 64, 64)
atlas = ExtResource("9_5e32d")
region = Rect2(0, 64, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_21pmc"]
atlas = ExtResource("10_gbdaa")
region = Rect2(0, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_5lpnx"]
atlas = ExtResource("10_gbdaa")
region = Rect2(64, 0, 64, 64)
Expand Down Expand Up @@ -261,6 +261,17 @@ animations = [{
"speed": 10.0
}, {
"frames": [{
"duration": 2.0,
"texture": SubResource("AtlasTexture_vgmmn")
}, {
"duration": 3.0,
"texture": SubResource("AtlasTexture_ftvn8")
}],
"loop": false,
"name": &"hit",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_sru21")
}, {
Expand Down Expand Up @@ -339,6 +350,23 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_vgmmn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jpu6i")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_21pmc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jpu6i")
}],
"loop": true,
"name": &"mort",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_obl77")
}, {
"duration": 1.0,
Expand Down Expand Up @@ -398,18 +426,18 @@ animations = [{
[sub_resource type="RectangleShape2D" id="RectangleShape2D_porep"]
size = Vector2(37, 40)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_ryj7v"]
size = Vector2(66.5, 20)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_e8x0y"]
size = Vector2(19.75, 53)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0ivq8"]
bg_color = Color(0.352941, 0.27451, 0.392157, 0.509804)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_y00jh"]
bg_color = Color(0.909804, 0.145098, 0.313726, 1)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_hfyxv"]
size = Vector2(62, 40)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_r5yw1"]
size = Vector2(40.5, 43)

[node name="Player" type="CharacterBody2D"]
texture_filter = 1
position = Vector2(479, 215)
Expand All @@ -424,39 +452,14 @@ position = Vector2(-4, 2)
position = Vector2(-1.99999, -20)
scale = Vector2(2.5, 2.5)
sprite_frames = SubResource("SpriteFrames_0qt2h")
animation = &"up_walk"
animation = &"mort"
autoplay = "down_idle"

[node name="Hurtbox" type="CollisionShape2D" parent="."]
position = Vector2(-0.5, -1)
shape = SubResource("RectangleShape2D_porep")
debug_color = Color(0.67451, 0.278431, 0.203922, 0.419608)

[node name="UpInteractCollision" type="CollisionShape2D" parent="."]
texture_filter = 1
position = Vector2(-0.5, -32)
shape = SubResource("RectangleShape2D_ryj7v")
disabled = true
debug_color = Color(0.239216, 0.529412, 0.4, 0.419608)

[node name="DownInteractCollision" type="CollisionShape2D" parent="."]
position = Vector2(0, 28)
shape = SubResource("RectangleShape2D_ryj7v")
disabled = true
debug_color = Color(0.239216, 0.529412, 0.4, 0.419608)

[node name="LeftInteractCollision" type="CollisionShape2D" parent="."]
position = Vector2(-30, -2.5)
shape = SubResource("RectangleShape2D_e8x0y")
disabled = true
debug_color = Color(0.329412, 0.407843, 0.882353, 0.419608)

[node name="RightInteractCollision" type="CollisionShape2D" parent="."]
position = Vector2(27, -3)
shape = SubResource("RectangleShape2D_e8x0y")
disabled = true
debug_color = Color(0.329412, 0.407843, 0.882353, 0.419608)

[node name="HealthBar" type="ProgressBar" parent="."]
offset_left = -555.0
offset_top = -299.0
Expand Down Expand Up @@ -499,3 +502,43 @@ offset_top = 104.0
offset_right = 1068.0
offset_bottom = 574.0
theme_override_font_sizes/normal_font_size = 24

[node name="GameOver" type="Label" parent="DialogueBox"]
layout_mode = 0
offset_left = 242.0
offset_top = 81.0
offset_right = 938.0
offset_bottom = 440.0
theme_override_font_sizes/font_size = 64
text = "GAME OVER !!!"
horizontal_alignment = 1
vertical_alignment = 1

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

[node name="CollisionShape2D" type="CollisionShape2D" parent="DownArea"]
position = Vector2(2, 38)
shape = SubResource("RectangleShape2D_hfyxv")

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

[node name="CollisionShape2D" type="CollisionShape2D" parent="LeftArea"]
position = Vector2(-34, -5)
shape = SubResource("RectangleShape2D_r5yw1")

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

[node name="CollisionShape2D" type="CollisionShape2D" parent="UpArea"]
position = Vector2(0, -48)
shape = SubResource("RectangleShape2D_hfyxv")

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

[node name="CollisionShape2D" type="CollisionShape2D" parent="RightArea"]
position = Vector2(36, -5)
shape = SubResource("RectangleShape2D_r5yw1")

[connection signal="body_entered" from="DownArea" to="." method="_on_down_area_body_entered"]
[connection signal="body_entered" from="LeftArea" to="." method="_on_left_area_body_entered"]
[connection signal="body_entered" from="UpArea" to="." method="_on_up_area_body_entered"]
[connection signal="body_entered" from="RightArea" to="." method="_on_right_area_body_entered"]
50 changes: 46 additions & 4 deletions scripts/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ var walkingSpeed = 1.0
var directionOfPlayer = "up"
var playerState = "idle"
var arc = false
var canOpenChest = false
var chest = null;
var chest = null
var up = false
var left = false
var right = false
var down = false
var enemyU = null
var enemyL = null
var enemyR = null
var enemyD = null

func show_message(text):
$DialogueBox/GameOver.text = text
Expand Down Expand Up @@ -56,17 +63,24 @@ func interacted() -> bool:
func animationInteractionUpdate(anim_name: String = "") -> void:
if Input.is_anything_pressed():
if swung_sword():
playerState = "swung_sword"

playerState = "swung_sword"
match (directionOfPlayer):
"up":
animation_player.play("up_attack")
if(up):
enemyU.take_dmg()
"down":
animation_player.play("down_attack")
if(down):
enemyD.take_dmg()
"left":
animation_player.play("left_attack")
if(left):
enemyL.take_dmg()
"right":
animation_player.play("left_attack")
if(right):
enemyR.take_dmg()
elif interacted():
playerState = "interacting"
animation_player.play("left_pick_up")
Expand Down Expand Up @@ -190,5 +204,33 @@ func update_health_bar() -> void:
healthBar.value = PlayerInfo.healthPoints


func _on_up_area_body_entered(body):
if(body.has_method("is_orc")):
up = true
enemyU = body
else:
up = false


func _on_down_area_body_entered(body):
if(body.has_method("is_orc")):
down = true
enemyD = body
else:
down = false


func _on_left_area_body_entered(body):
if(body.has_method("is_orc")):
left = true
enemyL = body
else:
left = false


func _on_right_area_body_entered(body):
if(body.has_method("is_orc")):
right = true
enemyR = body
else:
right = false

0 comments on commit d01d10b

Please sign in to comment.