Skip to content
Snippets Groups Projects
Commit cba44707 authored by ee6-wz3-u1's avatar ee6-wz3-u1
Browse files

fixed bug

parent f324ec7f
No related branches found
No related tags found
No related merge requests found
......@@ -63,15 +63,9 @@ func _ready():
hitpoints = 10
is_alive = true
$Control/HealthBar.max_value = hitpoints
$Control/HealthBar.value = hitpoints
$Control/HealthBar.tint_progress = Color.green
$MeleeDetector.monitoring = false
print("ready")
set_black_white(false)
func _process(delta):
if not is_alive:
......@@ -211,7 +205,7 @@ func attack_process():
if attack_state == ATTACK_STATES.RANGED:
var b = FireBall.instance()
b.position = self.position
b.set_direction(self.last_look_direction)
b.direction = self.last_look_direction
get_tree().current_scene.add_child(b)
if attack_state == ATTACK_STATES.MELEE:
print("melee")
......@@ -234,20 +228,13 @@ func take_damage(n : int):
animation_state = ANIMATION_STATES.HURT
hitpoints -= n
if hitpoints >= 7:
$Control/HealthBar.tint_progress = Color.green
elif hitpoints >= 3:
$Control/HealthBar.tint_progress = Color.orange
else:
$Control/HealthBar.tint_progress = Color.red
$Control/HealthBar.value = hitpoints
if hitpoints <= 0:
print("dying")
animation_state = ANIMATION_STATES.DEATH
is_alive = false
update_animation()
func take_damage_player(n : int):
take_damage(n)
......@@ -281,13 +268,9 @@ func update_animation():
$AnimatedSprite.offset.x = 0
$MeleeDetector/CollisionShape2D.position.x = abs($MeleeDetector/CollisionShape2D.position.x)
$InfoLabel.text = "is_moving: " + str(is_moving) + "\nis_jumping: " + str(is_jumping) + "\nis_attacking: " + str(is_attacking) + "\nvh: " + str(velocity.x) + "\nvv" + str(velocity.y) + "\nhp: " + str(hitpoints)
$Camera2D/InfoLabel.text = "is_moving: " + str(is_moving) + "\nis_jumping: " + str(is_jumping) + "\nis_attacking: " + str(is_attacking) + "\nvh: " + str(velocity.x) + "\nvv" + str(velocity.y) + "\nhp: " + str(hitpoints)
func set_black_white(boolean: bool):
if boolean:
$AnimatedSprite.material = load("res://src/actors/player/PlayerShader.tres")
else:
$AnimatedSprite.material = null
""" SECTION SIGNAL FUNCTIONS """
......
[gd_scene load_steps=56 format=2]
[gd_scene load_steps=35 format=2]
[ext_resource path="res://src/actors/player/Player.gd" type="Script" id=2]
[ext_resource path="res://src/assets/actors/Player/player_run.png" type="Texture" id=3]
......@@ -6,11 +6,6 @@
[ext_resource path="res://src/assets/actors/Player/player_jump.png" type="Texture" id=5]
[ext_resource path="res://src/assets/actors/Player/player_attack3.png" type="Texture" id=6]
[ext_resource path="res://src/assets/actors/Player/player_hurt.png" type="Texture" id=7]
[ext_resource path="res://src/assets/actors/Player/player_death.png" type="Texture" id=8]
[ext_resource path="res://src/assets/actors/Player/health-bar-under.png" type="Texture" id=9]
[ext_resource path="res://src/assets/actors/Player/health-bar-over.png" type="Texture" id=10]
[ext_resource path="res://src/assets/actors/Player/health_bar_health.png" type="Texture" id=11]
[ext_resource path="res://src/actors/player/PlayerShader.tres" type="Material" id=12]
[sub_resource type="AtlasTexture" id=1]
flags = 4
......@@ -32,21 +27,6 @@ flags = 4
atlas = ExtResource( 4 )
region = Rect2( 144, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=29]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 48, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=15]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 96, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=16]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 144, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=23]
flags = 4
atlas = ExtResource( 3 )
......@@ -117,86 +97,31 @@ flags = 4
atlas = ExtResource( 6 )
region = Rect2( 336, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=17]
[sub_resource type="AtlasTexture" id=13]
flags = 4
atlas = ExtResource( 8 )
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=18]
[sub_resource type="AtlasTexture" id=14]
flags = 4
atlas = ExtResource( 8 )
atlas = ExtResource( 5 )
region = Rect2( 48, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=19]
[sub_resource type="AtlasTexture" id=15]
flags = 4
atlas = ExtResource( 8 )
atlas = ExtResource( 5 )
region = Rect2( 96, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=20]
[sub_resource type="AtlasTexture" id=16]
flags = 4
atlas = ExtResource( 8 )
atlas = ExtResource( 5 )
region = Rect2( 144, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=21]
flags = 4
atlas = ExtResource( 8 )
region = Rect2( 192, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=22]
flags = 4
atlas = ExtResource( 8 )
region = Rect2( 240, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=29]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 48, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=42]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=43]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=44]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 48, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=45]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=46]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 144, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=47]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=48]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 240, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=49]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 288, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=50]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 336, 0, 48, 48 )
[sub_resource type="SpriteFrames" id=38]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ],
......@@ -204,11 +129,6 @@ animations = [ {
"name": "idle",
"speed": 5.0
}, {
"frames": [ SubResource( 29 ) ],
"loop": true,
"name": "hurt",
"speed": 5.0
}, {
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ],
"loop": true,
"name": "move",
......@@ -219,20 +139,15 @@ animations = [ {
"name": "attack1",
"speed": 20.0
}, {
"frames": [ SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 22 ), SubResource( 22 ), SubResource( 22 ), SubResource( 22 ), SubResource( 22 ) ],
"loop": false,
"name": "death",
"speed": 7.0
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "jump",
"speed": 2.0
}, {
"frames": [ SubResource( 29 ), SubResource( 42 ), SubResource( 29 ), SubResource( 42 ), SubResource( 29 ), SubResource( 29 ), SubResource( 42 ) ],
"frames": [ SubResource( 29 ) ],
"loop": true,
"name": "hurt",
"speed": 5.0
}, {
"frames": [ SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ) ],
"loop": true,
"name": "melee",
"speed": 17.0
} ]
[sub_resource type="RectangleShape2D" id=39]
......@@ -250,16 +165,15 @@ extents = Vector2( 12.751, 6.23259 )
[node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 3
collision_mask = 249
collision/safe_margin = 0.01
collision/safe_margin = 0.5
script = ExtResource( 2 )
velocity_cap_v = 800
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = ExtResource( 12 )
position = Vector2( 10, -24 )
frames = SubResource( 38 )
animation = "attack1"
frame = 5
frame = 7
playing = true
[node name="Camera2D" type="Camera2D" parent="."]
......@@ -273,13 +187,12 @@ drag_margin_v_enabled = true
smoothing_enabled = true
smoothing_speed = 10.0
[node name="InfoLabel" type="Label" parent="."]
[node name="InfoLabel" type="Label" parent="Camera2D"]
visible = false
margin_left = -18.3265
margin_top = -144.037
margin_right = 21.6735
margin_bottom = -113.037
text = "test
"
margin_bottom = -130.037
__meta__ = {
"_edit_use_anchors_": false
}
......@@ -310,30 +223,6 @@ shape = SubResource( 41 )
position = Vector2( 22.3487, -20.622 )
shape = SubResource( 51 )
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Control" type="Control" parent="."]
margin_left = -24.5817
margin_top = -103.502
margin_right = 15.4183
margin_bottom = -63.502
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HealthBar" type="TextureProgress" parent="Control"]
margin_left = -4.83041
margin_top = 40.0753
margin_right = 54.1696
margin_bottom = 49.0753
max_value = 10.0
texture_under = ExtResource( 9 )
texture_over = ExtResource( 10 )
texture_progress = ExtResource( 11 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
[connection signal="area_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_area_entered"]
[connection signal="body_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_body_entered"]
......
......@@ -179,7 +179,6 @@ __meta__ = {
position = Vector2( 755.822, 322.431 )
scale = Vector2( 2.81113, 2.31242 )
frames = SubResource( 18 )
frame = 2
speed_scale = 0.8
playing = true
......
......@@ -1357,8 +1357,7 @@ position = Vector2( 5780, 417 )
position = Vector2( 10776, 258 )
[node name="Player" parent="Level1" instance=ExtResource( 1 )]
position = Vector2( 11778, -36 )
collision_mask = 16
position = Vector2( 486, 445 )
[node name="Level" type="TileMap" parent="Level1"]
tile_set = SubResource( 29 )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment