diff --git a/ActionRPG-HeartBeast/Enemies/Bat.gd b/ActionRPG-HeartBeast/Enemies/Bat.gd new file mode 100644 index 0000000..c527f65 --- /dev/null +++ b/ActionRPG-HeartBeast/Enemies/Bat.gd @@ -0,0 +1,17 @@ +extends KinematicBody2D + +var knockback = Vector2.ZERO + +onready var stats = $Stats + +func _physics_process(delta): + knockback = knockback.move_toward(Vector2.ZERO, 200 * delta) + knockback = move_and_slide(knockback) + +func _on_Hurtbox_area_entered(area): + stats.health -= area.damage + knockback = area.knockback_vector * 120 + #queue_free() # Replace with function body. + +func _on_Stats_no_health(): + queue_free() diff --git a/ActionRPG-HeartBeast/Enemies/Bat.tscn b/ActionRPG-HeartBeast/Enemies/Bat.tscn new file mode 100644 index 0000000..1e4f4e7 --- /dev/null +++ b/ActionRPG-HeartBeast/Enemies/Bat.tscn @@ -0,0 +1,74 @@ +[gd_scene load_steps=14 format=2] + +[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1] +[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2] +[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3] +[ext_resource path="res://Enemies/Bat.gd" type="Script" id=4] +[ext_resource path="res://Stats.tscn" type="PackedScene" id=5] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 16, 24 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 16, 0, 16, 24 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 32, 0, 16, 24 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 48, 0, 16, 24 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 1 ) +region = Rect2( 64, 0, 16, 24 ) + +[sub_resource type="SpriteFrames" id=6] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ], +"loop": true, +"name": "Fly", +"speed": 10.0 +} ] + +[sub_resource type="CircleShape2D" id=7] +radius = 4.12311 + +[sub_resource type="CapsuleShape2D" id=8] +radius = 7.0 +height = 6.0 + +[node name="Bat" type="KinematicBody2D"] +collision_layer = 16 +script = ExtResource( 4 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +frames = SubResource( 6 ) +animation = "Fly" +frame = 4 +playing = true +offset = Vector2( 0, -12 ) + +[node name="ShadowSprite" type="Sprite" parent="."] +texture = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 7 ) + +[node name="Hurtbox" parent="." instance=ExtResource( 3 )] +collision_layer = 8 + +[node name="CollisionShape2D" parent="Hurtbox" index="0"] +position = Vector2( 0, -14 ) +shape = SubResource( 8 ) + +[node name="Stats" parent="." instance=ExtResource( 5 )] +max_health = 2 + +[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"] +[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"] + +[editable path="Hurtbox"] diff --git a/ActionRPG-HeartBeast/Overlap/Hitbox.gd b/ActionRPG-HeartBeast/Overlap/Hitbox.gd new file mode 100644 index 0000000..9432eae --- /dev/null +++ b/ActionRPG-HeartBeast/Overlap/Hitbox.gd @@ -0,0 +1,3 @@ +extends Area2D + +export var damage = 1 diff --git a/ActionRPG-HeartBeast/Overlap/Hitbox.tscn b/ActionRPG-HeartBeast/Overlap/Hitbox.tscn index 8571387..553cf52 100644 --- a/ActionRPG-HeartBeast/Overlap/Hitbox.tscn +++ b/ActionRPG-HeartBeast/Overlap/Hitbox.tscn @@ -1,7 +1,10 @@ -[gd_scene format=2] +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Overlap/Hitbox.gd" type="Script" id=1] [node name="Hitbox" type="Area2D"] collision_layer = 0 collision_mask = 0 +script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/ActionRPG-HeartBeast/Player/Player.gd b/ActionRPG-HeartBeast/Player/Player.gd index 28a086e..f04fd6e 100644 --- a/ActionRPG-HeartBeast/Player/Player.gd +++ b/ActionRPG-HeartBeast/Player/Player.gd @@ -20,9 +20,11 @@ var state = MOVE onready var animationPlayer = $AnimationPlayer onready var animationTree = $AnimationTree onready var animationState = animationTree.get("parameters/playback") +onready var swordHitbox = $HitboxPivot/SwordHitbox func _ready(): animationTree.active = true + swordHitbox.knockback_vector = roll_vector func _process(delta): match state: @@ -42,6 +44,7 @@ func move_state(delta): if input_vector != Vector2.ZERO: roll_vector = input_vector + swordHitbox.knockback_vector = input_vector animationTree.set("parameters/Idle/blend_position", input_vector) animationTree.set("parameters/Run/blend_position", input_vector) animationTree.set("parameters/Attack/blend_position", input_vector) diff --git a/ActionRPG-HeartBeast/Player/Player.tscn b/ActionRPG-HeartBeast/Player/Player.tscn index 4653b27..374adbb 100644 --- a/ActionRPG-HeartBeast/Player/Player.tscn +++ b/ActionRPG-HeartBeast/Player/Player.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=53 format=2] +[gd_scene load_steps=54 format=2] [ext_resource path="res://Player/Player.gd" type="Script" id=1] [ext_resource path="res://Player/Player.png" type="Texture" id=2] [ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=3] +[ext_resource path="res://Player/SwordHitbox.gd" type="Script" id=4] [sub_resource type="CapsuleShape2D" id=1] radius = 4.0 @@ -691,6 +692,7 @@ __meta__ = { [node name="SwordHitbox" parent="HitboxPivot" instance=ExtResource( 3 )] position = Vector2( 15, 0 ) collision_mask = 8 +script = ExtResource( 4 ) [node name="CollisionShape2D" parent="HitboxPivot/SwordHitbox" index="0"] shape = SubResource( 40 ) diff --git a/ActionRPG-HeartBeast/Player/SwordHitbox.gd b/ActionRPG-HeartBeast/Player/SwordHitbox.gd new file mode 100644 index 0000000..67957c4 --- /dev/null +++ b/ActionRPG-HeartBeast/Player/SwordHitbox.gd @@ -0,0 +1,3 @@ +extends "res://Overlap/Hitbox.gd" + +var knockback_vector = Vector2.ZERO diff --git a/ActionRPG-HeartBeast/Stats.gd b/ActionRPG-HeartBeast/Stats.gd new file mode 100644 index 0000000..5dd8dc2 --- /dev/null +++ b/ActionRPG-HeartBeast/Stats.gd @@ -0,0 +1,11 @@ +extends Node + +export(int) var max_health = 1 +onready var health = max_health setget set_health + +signal no_health + +func set_health(value): + health = value + if health <= 0: + emit_signal("no_health") diff --git a/ActionRPG-HeartBeast/Stats.tscn b/ActionRPG-HeartBeast/Stats.tscn new file mode 100644 index 0000000..39873a8 --- /dev/null +++ b/ActionRPG-HeartBeast/Stats.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Stats.gd" type="Script" id=1] + +[node name="Stats" type="Node"] +script = ExtResource( 1 ) diff --git a/ActionRPG-HeartBeast/World.tscn b/ActionRPG-HeartBeast/World.tscn index dabe062..860f3ab 100644 --- a/ActionRPG-HeartBeast/World.tscn +++ b/ActionRPG-HeartBeast/World.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=61 format=2] +[gd_scene load_steps=62 format=2] [ext_resource path="res://World/Bush.tscn" type="PackedScene" id=1] [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://World/CliffTileset.png" type="Texture" id=5] [ext_resource path="res://World/Grass.tscn" type="PackedScene" id=6] [ext_resource path="res://touch_controls/TouchControls.tscn" type="PackedScene" id=7] +[ext_resource path="res://Enemies/Bat.tscn" type="PackedScene" id=8] [sub_resource type="TileSet" id=1] 0/name = "DirtTileset.png 0" @@ -593,6 +594,15 @@ position = Vector2( 48, 112 ) [node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )] position = Vector2( 128, 121 ) +[node name="Bat" parent="YSort" instance=ExtResource( 8 )] +position = Vector2( 198, 35 ) + +[node name="Bat2" parent="YSort" instance=ExtResource( 8 )] +position = Vector2( 224, 122 ) + +[node name="Bat3" parent="YSort" instance=ExtResource( 8 )] +position = Vector2( 37, 90 ) + [node name="Control" type="Control" parent="."] margin_right = 40.0 margin_bottom = 40.0 diff --git a/ActionRPG-HeartBeast/build/web/.DS_Store b/ActionRPG-HeartBeast/build/web/.DS_Store index 25209c7..2fb2bd6 100644 Binary files a/ActionRPG-HeartBeast/build/web/.DS_Store and b/ActionRPG-HeartBeast/build/web/.DS_Store differ diff --git a/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip b/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip index dc38ed2..117e9ea 100644 Binary files a/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip and b/ActionRPG-HeartBeast/build/web/ActionRPG-web.zip differ diff --git a/ActionRPG-HeartBeast/build/web/index.html b/ActionRPG-HeartBeast/build/web/index.html index b00b701..0d880cd 100644 --- a/ActionRPG-HeartBeast/build/web/index.html +++ b/ActionRPG-HeartBeast/build/web/index.html @@ -139,7 +139,7 @@