Skip to content

Commit

Permalink
Теперь враг шлёпает мечом героя
Browse files Browse the repository at this point in the history
Именно шлёпает. Шлёпает потому что пока не смог сделать нормальный удар.
  • Loading branch information
Allespro committed Jul 13, 2019
1 parent 62163e9 commit 3d542b1
Show file tree
Hide file tree
Showing 11 changed files with 456 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .import/Wooden_sword.png-5b2d518d7ba176daa681b994606cc83b.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="426cdc1f72a1a968d6c5bc4771f56445"
dest_md5="291b35e22065f46e999fb828cbe4a7b9"

Binary file not shown.
52 changes: 31 additions & 21 deletions Enemy1.tscn
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://KinematicEnemy1.gd" type="Script" id=1]
[ext_resource path="res://enemy/amg1_lf1.png" type="Texture" id=2]
[ext_resource path="res://enemy/amg1_lf2.png" type="Texture" id=3]
[ext_resource path="res://enemy/amg1_rt1.png" type="Texture" id=4]
[ext_resource path="res://enemy/amg1_rt2.png" type="Texture" id=5]
[ext_resource path="res://enemy/amg1_bk1.png" type="Texture" id=6]
[ext_resource path="res://enemy/amg1_bk2.png" type="Texture" id=7]
[ext_resource path="res://enemy/amg1_fr1.png" type="Texture" id=8]
[ext_resource path="res://enemy/amg1_fr2.png" type="Texture" id=9]
[ext_resource path="res://Enemy/KnightBody.gd" type="Script" id=10]
[ext_resource path="res://images/pixel_under_health.png" type="Texture" id=11]
[ext_resource path="res://images/health_bar.png" type="Texture" id=12]
[ext_resource path="res://images/pixel_health.png" type="Texture" id=13]
[ext_resource path="res://waepons/Wooden_sword.tscn" type="PackedScene" id=2]
[ext_resource path="res://enemy/amg1_lf1.png" type="Texture" id=3]
[ext_resource path="res://enemy/amg1_lf2.png" type="Texture" id=4]
[ext_resource path="res://enemy/amg1_rt1.png" type="Texture" id=5]
[ext_resource path="res://enemy/amg1_rt2.png" type="Texture" id=6]
[ext_resource path="res://enemy/amg1_bk1.png" type="Texture" id=7]
[ext_resource path="res://enemy/amg1_bk2.png" type="Texture" id=8]
[ext_resource path="res://enemy/amg1_fr1.png" type="Texture" id=9]
[ext_resource path="res://enemy/amg1_fr2.png" type="Texture" id=10]
[ext_resource path="res://Enemy/KnightBody.gd" type="Script" id=11]
[ext_resource path="res://images/pixel_under_health.png" type="Texture" id=12]
[ext_resource path="res://images/health_bar.png" type="Texture" id=13]
[ext_resource path="res://images/pixel_health.png" type="Texture" id=14]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 13.272, 16.0447 )

[sub_resource type="SpriteFrames" id=2]
animations = [ {
"frames": [ ExtResource( 2 ), ExtResource( 3 ) ],
"frames": [ ExtResource( 3 ), ExtResource( 4 ) ],
"loop": true,
"name": "LEFT",
"speed": 5.0
}, {
"frames": [ ExtResource( 4 ), ExtResource( 5 ) ],
"frames": [ ExtResource( 5 ), ExtResource( 6 ) ],
"loop": true,
"name": "RIGHT",
"speed": 5.0
}, {
"frames": [ ExtResource( 6 ), ExtResource( 7 ) ],
"frames": [ ExtResource( 7 ), ExtResource( 8 ) ],
"loop": true,
"name": "UP",
"speed": 5.0
}, {
"frames": [ ExtResource( 8 ), ExtResource( 9 ) ],
"frames": [ ExtResource( 9 ), ExtResource( 10 ) ],
"loop": true,
"name": "DOWN",
"speed": 5.0
Expand All @@ -55,6 +56,9 @@ extents = Vector2( 14.0223, 16.4362 )
scale = Vector2( 0.7, 0.7 )
script = ExtResource( 1 )

[node name="Sword" parent="KinematicEnemy1" instance=ExtResource( 2 )]
scale = Vector2( 0.714286, 0.714286 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicEnemy1" groups=[
"noheavy",
]]
Expand All @@ -67,7 +71,9 @@ animation = "RIGHT"
[node name="Body" type="Area2D" parent="KinematicEnemy1" groups=[
"noheavy",
]]
script = ExtResource( 10 )
editor/display_folded = true
visible = false
script = ExtResource( 11 )

[node name="CollisionShape2D2" type="CollisionShape2D" parent="KinematicEnemy1/Body"]
position = Vector2( -0.71698, 0 )
Expand All @@ -88,9 +94,9 @@ margin_right = 11.2376
margin_bottom = -18.5248
max_value = 150.0
value = 20.0
texture_under = ExtResource( 11 )
texture_over = ExtResource( 12 )
texture_progress = ExtResource( 13 )
texture_under = ExtResource( 12 )
texture_over = ExtResource( 13 )
texture_progress = ExtResource( 14 )
fill_mode = 1
nine_patch_stretch = true

Expand All @@ -100,6 +106,10 @@ editor/display_folded = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicEnemy1/Area2D"]
shape = SubResource( 5 )

[node name="Camera2D" type="Camera2D" parent="."]
scale = Vector2( 0.791308, 1.34034 )
current = true
zoom = Vector2( 0.3, 0.3 )
[connection signal="area_entered" from="KinematicEnemy1/Body" to="KinematicEnemy1/Body" method="_on_Body_area_entered"]
[connection signal="area_exited" from="KinematicEnemy1/Body" to="KinematicEnemy1/Body" method="_on_Body_area_exited"]
[connection signal="area_entered" from="KinematicEnemy1/HitZone" to="KinematicEnemy1" method="_on_HitZone_area_entered"]
Expand Down
20 changes: 20 additions & 0 deletions KinematicEnemy1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ var health:int = 150
var PlayerPos = Vector2(0,0)
var CanHitPlayer:bool = false
var BulletDamage:int = 10
var side

#
#func _ready():
# $"../Sword".set_sword_position(17, "right")

func _physics_process(delta):
$HealthBar.set_value(health)
Expand All @@ -29,29 +34,37 @@ func rotation_loop(): # Супер сложная математическая
if(PlayerPos.x < 0 && PlayerPos.y < 0): # 1 ая четверть окружности
if(abs(PlayerPos.y) < abs(PlayerPos.x)):# нижняя половина четверти
$AnimatedSprite.play("LEFT") # Начать проигрывать анимацию
side = "left"
elif(abs(PlayerPos.y) > abs(PlayerPos.x)):# верхняя половина четверти
$AnimatedSprite.play("UP")
side = "up"
else:
$AnimatedSprite.stop()
elif(PlayerPos.x > 0 && PlayerPos.y < 0): # 2 ая четверть четверти
if(abs(PlayerPos.y) < abs(PlayerPos.x)):# нижняя половина четверти
$AnimatedSprite.play("RIGHT")
side = "right"
elif(abs(PlayerPos.y) > abs(PlayerPos.x)):# верхняя половина четверти
$AnimatedSprite.play("UP")
side = "up"
else:
$AnimatedSprite.stop()
elif(PlayerPos.x > 0 && PlayerPos.y > 0): # 3 ая четверть четверти
if(abs(PlayerPos.y) < abs(PlayerPos.x)):# верхняя половина четверти
$AnimatedSprite.play("RIGHT")
side = "right"
elif(abs(PlayerPos.y) > abs(PlayerPos.x)):# нижняя половина четверти
$AnimatedSprite.play("DOWN")
side = "down"
else:
$AnimatedSprite.stop()
elif(PlayerPos.x < 0 && PlayerPos.y > 0): # 4 ая четверть четверти
if(abs(PlayerPos.y) > abs(PlayerPos.x)):# нижняя половина четверти
$AnimatedSprite.play("DOWN")
side = "down"
elif(abs(PlayerPos.y) < abs(PlayerPos.x)):# верхняя половина четверти
$AnimatedSprite.play("LEFT")
side = "left"
else:
$AnimatedSprite.stop() # Перестать проигрывать анимацию
else:
Expand All @@ -60,6 +73,7 @@ func rotation_loop(): # Супер сложная математическая

func attack():
IsPlayerNear = true

func stop_attack():
$AnimatedSprite.stop()
IsPlayerNear = false
Expand All @@ -68,6 +82,10 @@ func _on_HitZone_area_entered(area): # Функция будущей атаки,
var groups = area.get_groups()
if (groups.has("player")):
CanHitPlayer = true
print(side)
$Sword.set_sword_position(20, side)
$Sword.show()
$Sword.enable_sword()

func _on_Area2D_area_entered(area):
var groups = area.get_groups()
Expand All @@ -79,3 +97,5 @@ func _on_HitZone_area_exited(area):
var groups = area.get_groups()
if (groups.has("player")):
CanHitPlayer = false
$Sword.hide()
$Sword.disable_sword()
Binary file added enemy/waepons/Wooden_sword.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 enemy/waepons/Wooden_sword.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/Wooden_sword.png-5b2d518d7ba176daa681b994606cc83b.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://enemy/waepons/Wooden_sword.png"
dest_files=[ "res://.import/Wooden_sword.png-5b2d518d7ba176daa681b994606cc83b.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Loading

0 comments on commit 3d542b1

Please sign in to comment.