Skip to content
Snippets Groups Projects
Commit 8cf00582 authored by Jannik Rosendahl's avatar Jannik Rosendahl
Browse files

mergen macht spass

parent cba44707
No related branches found
No related tags found
No related merge requests found
......@@ -63,9 +63,15 @@ 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:
......@@ -205,7 +211,7 @@ func attack_process():
if attack_state == ATTACK_STATES.RANGED:
var b = FireBall.instance()
b.position = self.position
b.direction = self.last_look_direction
b.set_direction(self.last_look_direction)
get_tree().current_scene.add_child(b)
if attack_state == ATTACK_STATES.MELEE:
print("melee")
......@@ -228,13 +234,20 @@ 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)
......@@ -268,9 +281,13 @@ func update_animation():
$AnimatedSprite.offset.x = 0
$MeleeDetector/CollisionShape2D.position.x = abs($MeleeDetector/CollisionShape2D.position.x)
$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)
$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 """
......@@ -309,3 +326,4 @@ func _on_StompDetector_body_entered(body):
func _on_MeleeDetector_body_entered(body):
if body.is_in_group("enemy"):
body.take_damage(5)
[gd_scene load_steps=35 format=2]
[gd_scene load_steps=56 format=2]
[ext_resource path="res://src/assets/actors/Player/player_attack_melee.png" type="Texture" id=1]
[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]
[ext_resource path="res://src/assets/actors/Player/player_idle.png" type="Texture" id=4]
[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
......@@ -27,6 +33,26 @@ flags = 4
atlas = ExtResource( 4 )
region = Rect2( 144, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=13]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=14]
flags = 4
atlas = ExtResource( 5 )
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 )
......@@ -97,31 +123,86 @@ flags = 4
atlas = ExtResource( 6 )
region = Rect2( 336, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=13]
[sub_resource type="AtlasTexture" id=17]
flags = 4
atlas = ExtResource( 5 )
atlas = ExtResource( 8 )
region = Rect2( 0, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=14]
[sub_resource type="AtlasTexture" id=18]
flags = 4
atlas = ExtResource( 5 )
atlas = ExtResource( 8 )
region = Rect2( 48, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=15]
[sub_resource type="AtlasTexture" id=19]
flags = 4
atlas = ExtResource( 5 )
atlas = ExtResource( 8 )
region = Rect2( 96, 0, 48, 48 )
[sub_resource type="AtlasTexture" id=16]
[sub_resource type="AtlasTexture" id=20]
flags = 4
atlas = ExtResource( 5 )
atlas = ExtResource( 8 )
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 ) ],
......@@ -129,6 +210,11 @@ animations = [ {
"name": "idle",
"speed": 5.0
}, {
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "jump",
"speed": 2.0
}, {
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ],
"loop": true,
"name": "move",
......@@ -139,15 +225,20 @@ animations = [ {
"name": "attack1",
"speed": 20.0
}, {
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "jump",
"speed": 2.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( 29 ) ],
"frames": [ SubResource( 29 ), SubResource( 42 ), SubResource( 29 ), SubResource( 42 ), SubResource( 29 ), SubResource( 29 ), SubResource( 42 ) ],
"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]
......@@ -165,19 +256,18 @@ extents = Vector2( 12.751, 6.23259 )
[node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 3
collision_mask = 249
collision/safe_margin = 0.5
collision/safe_margin = 0.01
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 = 7
animation = "melee"
frame = 5
playing = true
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2( 0, 50 )
offset = Vector2( 0, -75 )
current = true
zoom = Vector2( 0.9, 0.9 )
......@@ -187,12 +277,13 @@ drag_margin_v_enabled = true
smoothing_enabled = true
smoothing_speed = 10.0
[node name="InfoLabel" type="Label" parent="Camera2D"]
visible = false
[node name="InfoLabel" type="Label" parent="."]
margin_left = -18.3265
margin_top = -144.037
margin_right = 21.6735
margin_bottom = -130.037
margin_bottom = -113.037
text = "test
"
__meta__ = {
"_edit_use_anchors_": false
}
......@@ -223,6 +314,30 @@ 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"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment