1 Commits

Author SHA1 Message Date
02f04cc38a feat: shield
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 2m13s
2025-08-02 21:34:08 +02:00
6 changed files with 244 additions and 93 deletions

View File

@ -1,13 +1,20 @@
extends Node extends Node
class_name Damageable class_name Damageable
@export var health = 3 @export var health = 3
@export var hitback_velocity: float = 500 @export var hitback_velocity: float = 500
var active = true
signal got_hit signal got_hit
func set_active(new_active: bool):
active = new_active
func damage(value: int = 0, direction: Vector2 = Vector2.UP): func damage(value: int = 0, direction: Vector2 = Vector2.UP):
if not active:
return
health -= value health -= value
get_parent().velocity = hitback_velocity * direction get_parent().velocity = hitback_velocity * direction
got_hit.emit() got_hit.emit()

View File

@ -1,59 +1,181 @@
[gd_resource type="SpriteFrames" load_steps=13 format=3 uid="uid://i6035vm5ited"] [gd_resource type="SpriteFrames" load_steps=34 format=3 uid="uid://i6035vm5ited"]
[ext_resource type="Texture2D" uid="uid://dbruj2bdtjfmd" path="res://player/assets/char_blue.png" id="1_pbrcr"] [ext_resource type="Texture2D" uid="uid://dv7jhtoptk12r" path="res://player/assets/Danse.png" id="1_4wqev"]
[ext_resource type="Texture2D" uid="uid://cjruk5xlt3tyn" path="res://ennemy/MechantVol.png" id="2_pxh46"] [ext_resource type="Texture2D" uid="uid://dcyawv770lkhp" path="res://player/assets/Défense.png" id="2_b2lu2"]
[ext_resource type="Texture2D" uid="uid://dwn548x0n4bpd" path="res://player/assets/Outch.png" id="2_t0xqw"]
[ext_resource type="Texture2D" uid="uid://dpy6espwka35l" path="res://player/assets/RunArme.png" id="4_3w5np"]
[sub_resource type="AtlasTexture" id="AtlasTexture_pxh46"] [sub_resource type="AtlasTexture" id="AtlasTexture_tqiix"]
atlas = ExtResource("1_pbrcr") atlas = ExtResource("1_4wqev")
region = Rect2(112, 280, 56, 56) region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_b2lu2"] [sub_resource type="AtlasTexture" id="AtlasTexture_e7oew"]
atlas = ExtResource("1_pbrcr") atlas = ExtResource("1_4wqev")
region = Rect2(168, 280, 56, 56) region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_3w5np"] [sub_resource type="AtlasTexture" id="AtlasTexture_c35mf"]
atlas = ExtResource("1_pbrcr") atlas = ExtResource("1_4wqev")
region = Rect2(224, 280, 56, 56) region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_4wqev"] [sub_resource type="AtlasTexture" id="AtlasTexture_65viv"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("1_4wqev")
region = Rect2(96, 0, 32, 32) region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_t0xqw"] [sub_resource type="AtlasTexture" id="AtlasTexture_x7c3f"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("1_4wqev")
region = Rect2(128, 0, 32, 32) region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_bjvpn"]
atlas = ExtResource("1_4wqev")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_s7qer"]
atlas = ExtResource("1_4wqev")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ge24q"]
atlas = ExtResource("1_4wqev")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_pnw6m"]
atlas = ExtResource("1_4wqev")
region = Rect2(256, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_1so5t"]
atlas = ExtResource("1_4wqev")
region = Rect2(288, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_55jnj"]
atlas = ExtResource("1_4wqev")
region = Rect2(320, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dx5ib"]
atlas = ExtResource("1_4wqev")
region = Rect2(352, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_a2xo5"]
atlas = ExtResource("1_4wqev")
region = Rect2(384, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_art4l"]
atlas = ExtResource("1_4wqev")
region = Rect2(416, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hg6s5"]
atlas = ExtResource("2_t0xqw")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8t03j"]
atlas = ExtResource("2_t0xqw")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_3w5np"]
atlas = ExtResource("2_b2lu2")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_4wqev"]
atlas = ExtResource("4_3w5np")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_t0xqw"]
atlas = ExtResource("4_3w5np")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_7en50"] [sub_resource type="AtlasTexture" id="AtlasTexture_7en50"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("4_3w5np")
region = Rect2(64, 0, 32, 32) region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dcl6h"] [sub_resource type="AtlasTexture" id="AtlasTexture_dcl6h"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("4_3w5np")
region = Rect2(96, 0, 32, 32) region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_pbrcr"]
atlas = ExtResource("1_pbrcr")
region = Rect2(392, 168, 56, 56)
[sub_resource type="AtlasTexture" id="AtlasTexture_yp8g1"] [sub_resource type="AtlasTexture" id="AtlasTexture_yp8g1"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("4_3w5np")
region = Rect2(64, 0, 32, 32) region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_er5ay"] [sub_resource type="AtlasTexture" id="AtlasTexture_er5ay"]
atlas = ExtResource("2_pxh46") atlas = ExtResource("4_3w5np")
region = Rect2(96, 0, 32, 32) region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_x3djp"]
atlas = ExtResource("4_3w5np")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ko4fi"]
atlas = ExtResource("4_3w5np")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_i5cp7"]
atlas = ExtResource("4_3w5np")
region = Rect2(256, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0mkg8"]
atlas = ExtResource("4_3w5np")
region = Rect2(288, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_5lqr2"]
atlas = ExtResource("4_3w5np")
region = Rect2(320, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_nq0ey"]
atlas = ExtResource("4_3w5np")
region = Rect2(352, 0, 32, 32)
[resource] [resource]
animations = [{ animations = [{
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_pxh46") "texture": SubResource("AtlasTexture_tqiix")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_b2lu2") "texture": SubResource("AtlasTexture_e7oew")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_3w5np") "texture": SubResource("AtlasTexture_c35mf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_65viv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x7c3f")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bjvpn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_s7qer")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ge24q")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pnw6m")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1so5t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_55jnj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dx5ib")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a2xo5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_art4l")
}],
"loop": true,
"name": &"dance",
"speed": 6.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_hg6s5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8t03j")
}], }],
"loop": false, "loop": false,
"name": &"got_hit", "name": &"got_hit",
@ -61,21 +183,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_4wqev") "texture": SubResource("AtlasTexture_3w5np")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t0xqw")
}],
"loop": true,
"name": &"hit",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_7en50")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dcl6h")
}], }],
"loop": true, "loop": true,
"name": &"idle", "name": &"idle",
@ -83,20 +191,42 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_pbrcr") "texture": SubResource("AtlasTexture_4wqev")
}], }, {
"loop": true, "duration": 1.0,
"name": &"jump", "texture": SubResource("AtlasTexture_t0xqw")
"speed": 5.0 }, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7en50")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dcl6h")
}, { }, {
"frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_yp8g1") "texture": SubResource("AtlasTexture_yp8g1")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_er5ay") "texture": SubResource("AtlasTexture_er5ay")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x3djp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ko4fi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_i5cp7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0mkg8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5lqr2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nq0ey")
}], }],
"loop": true, "loop": true,
"name": &"run", "name": &"run",
"speed": 2.0 "speed": 14.0
}] }]

BIN
player/assets/RunArme.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dpy6espwka35l"
path="res://.godot/imported/RunArme.png-0ddf4bccde5c36d31728f6dfcc6c39c0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://player/assets/RunArme.png"
dest_files=["res://.godot/imported/RunArme.png-0ddf4bccde5c36d31728f6dfcc6c39c0.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

View File

@ -11,12 +11,18 @@ var jump_velocity = 400.0
@export_range(0, 10, 0.1, "or_greater") @export_range(0, 10, 0.1, "or_greater")
var gravity_modifier = 1 var gravity_modifier = 1
@onready var damageable: Damageable = $Damageable
@onready var shield: AnimatedSprite2D = $Shield
@onready var base: AnimatedSprite2D = $Base @onready var base: AnimatedSprite2D = $Base
var current_sprite: AnimatedSprite2D var current_sprite: AnimatedSprite2D
var is_in_cutscene = false # back to true on build var is_in_cutscene = false # back to true on build
var current_animation = "idle" var current_animation = "idle"
var has_shield = false
var has_sword = false
var has_armor = false
func play_anim(): func play_anim():
current_sprite.play(current_animation) current_sprite.play(current_animation)
@ -60,6 +66,8 @@ func _physics_process(delta: float) -> void:
velocity += get_gravity() * delta * gravity_modifier velocity += get_gravity() * delta * gravity_modifier
var direction := Input.get_axis("move_left", "move_right") var direction := Input.get_axis("move_left", "move_right")
damageable.set_active(has_shield and direction != 0)
if direction > 0 and is_on_floor(): if direction > 0 and is_on_floor():
look_right() look_right()
if direction < 0 and is_on_floor(): if direction < 0 and is_on_floor():
@ -94,5 +102,9 @@ func _on_start_dancing() -> void:
func _on_npc_shield_dialogue_dialogue_ended() -> void: func _on_npc_shield_dialogue_dialogue_ended() -> void:
set_in_play() set_in_play()
print("jget shield") current_sprite.visible = false
current_sprite = shield
shield.play("idle")
shield.visible = true
has_shield = true

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=45 format=3 uid="uid://yvp44oauis4n"] [gd_scene load_steps=40 format=3 uid="uid://yvp44oauis4n"]
[ext_resource type="Script" uid="uid://c1fqj3lba7wik" path="res://player/player.gd" id="1_yw30f"] [ext_resource type="Script" uid="uid://c1fqj3lba7wik" path="res://player/player.gd" id="1_yw30f"]
[ext_resource type="SpriteFrames" uid="uid://i6035vm5ited" path="res://player/armored_spritesheet.tres" id="2_qjkh3"] [ext_resource type="SpriteFrames" uid="uid://i6035vm5ited" path="res://player/armored_spritesheet.tres" id="2_qjkh3"]
@ -8,7 +8,6 @@
[ext_resource type="Texture2D" uid="uid://dsxvqsh3umw01" path="res://player/assets/RunCycle.png" id="5_boad6"] [ext_resource type="Texture2D" uid="uid://dsxvqsh3umw01" path="res://player/assets/RunCycle.png" id="5_boad6"]
[ext_resource type="PackedScene" uid="uid://djwoetcyvvofc" path="res://damageable/damageable.tscn" id="5_g6k8r"] [ext_resource type="PackedScene" uid="uid://djwoetcyvvofc" path="res://damageable/damageable.tscn" id="5_g6k8r"]
[ext_resource type="Shape2D" uid="uid://6rhdwj5jxbxn" path="res://player/player_collision.tres" id="5_qjkh3"] [ext_resource type="Shape2D" uid="uid://6rhdwj5jxbxn" path="res://player/player_collision.tres" id="5_qjkh3"]
[ext_resource type="Texture2D" uid="uid://dw6tn0grt2ajc" path="res://player/assets/WalkCycle.png" id="5_rgyib"]
[sub_resource type="AtlasTexture" id="AtlasTexture_tqiix"] [sub_resource type="AtlasTexture" id="AtlasTexture_tqiix"]
atlas = ExtResource("3_hg6s5") atlas = ExtResource("3_hg6s5")
@ -82,22 +81,6 @@ region = Rect2(0, 0, 32, 32)
atlas = ExtResource("4_rgyib") atlas = ExtResource("4_rgyib")
region = Rect2(32, 0, 32, 32) region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_2ieo8"]
atlas = ExtResource("5_rgyib")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ebec5"]
atlas = ExtResource("5_rgyib")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_yllr7"]
atlas = ExtResource("5_rgyib")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_kb6p2"]
atlas = ExtResource("5_rgyib")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_g4c7l"] [sub_resource type="AtlasTexture" id="AtlasTexture_g4c7l"]
atlas = ExtResource("5_boad6") atlas = ExtResource("5_boad6")
region = Rect2(0, 0, 32, 32) region = Rect2(0, 0, 32, 32)
@ -193,7 +176,7 @@ animations = [{
}], }],
"loop": true, "loop": true,
"name": &"dance", "name": &"dance",
"speed": 5.0 "speed": 6.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
@ -219,23 +202,6 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_2ieo8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ebec5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yllr7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kb6p2")
}],
"loop": true,
"name": &"jump",
"speed": 4.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_g4c7l") "texture": SubResource("AtlasTexture_g4c7l")
}, { }, {
"duration": 1.0, "duration": 1.0,
@ -285,11 +251,11 @@ acceleration = 0.177
[node name="AudioListener2D" type="AudioListener2D" parent="."] [node name="AudioListener2D" type="AudioListener2D" parent="."]
current = true current = true
[node name="Knight" type="AnimatedSprite2D" parent="."] [node name="Shield" type="AnimatedSprite2D" parent="."]
visible = false visible = false
position = Vector2(1, -28) position = Vector2(0, -16)
sprite_frames = ExtResource("2_qjkh3") sprite_frames = ExtResource("2_qjkh3")
animation = &"jump" animation = &"dance"
autoplay = "idle" autoplay = "idle"
[node name="Base" type="AnimatedSprite2D" parent="."] [node name="Base" type="AnimatedSprite2D" parent="."]
@ -297,7 +263,6 @@ position = Vector2(0, -16)
sprite_frames = SubResource("SpriteFrames_mmwog") sprite_frames = SubResource("SpriteFrames_mmwog")
animation = &"dance" animation = &"dance"
autoplay = "idle" autoplay = "idle"
frame_progress = 0.0683317
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false visible = false