Added bat enemies with stats and better touch controls
This commit is contained in:
parent
f398efdcff
commit
6555ebe4c2
17
ActionRPG-HeartBeast/Enemies/Bat.gd
Normal file
17
ActionRPG-HeartBeast/Enemies/Bat.gd
Normal file
@ -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()
|
74
ActionRPG-HeartBeast/Enemies/Bat.tscn
Normal file
74
ActionRPG-HeartBeast/Enemies/Bat.tscn
Normal file
@ -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"]
|
3
ActionRPG-HeartBeast/Overlap/Hitbox.gd
Normal file
3
ActionRPG-HeartBeast/Overlap/Hitbox.gd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
extends Area2D
|
||||||
|
|
||||||
|
export var damage = 1
|
@ -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"]
|
[node name="Hitbox" type="Area2D"]
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
@ -20,9 +20,11 @@ var state = MOVE
|
|||||||
onready var animationPlayer = $AnimationPlayer
|
onready var animationPlayer = $AnimationPlayer
|
||||||
onready var animationTree = $AnimationTree
|
onready var animationTree = $AnimationTree
|
||||||
onready var animationState = animationTree.get("parameters/playback")
|
onready var animationState = animationTree.get("parameters/playback")
|
||||||
|
onready var swordHitbox = $HitboxPivot/SwordHitbox
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
animationTree.active = true
|
animationTree.active = true
|
||||||
|
swordHitbox.knockback_vector = roll_vector
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
match state:
|
match state:
|
||||||
@ -42,6 +44,7 @@ func move_state(delta):
|
|||||||
|
|
||||||
if input_vector != Vector2.ZERO:
|
if input_vector != Vector2.ZERO:
|
||||||
roll_vector = input_vector
|
roll_vector = input_vector
|
||||||
|
swordHitbox.knockback_vector = input_vector
|
||||||
animationTree.set("parameters/Idle/blend_position", input_vector)
|
animationTree.set("parameters/Idle/blend_position", input_vector)
|
||||||
animationTree.set("parameters/Run/blend_position", input_vector)
|
animationTree.set("parameters/Run/blend_position", input_vector)
|
||||||
animationTree.set("parameters/Attack/blend_position", input_vector)
|
animationTree.set("parameters/Attack/blend_position", input_vector)
|
||||||
|
@ -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.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
[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://Overlap/Hitbox.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://Player/SwordHitbox.gd" type="Script" id=4]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 4.0
|
radius = 4.0
|
||||||
@ -691,6 +692,7 @@ __meta__ = {
|
|||||||
[node name="SwordHitbox" parent="HitboxPivot" instance=ExtResource( 3 )]
|
[node name="SwordHitbox" parent="HitboxPivot" instance=ExtResource( 3 )]
|
||||||
position = Vector2( 15, 0 )
|
position = Vector2( 15, 0 )
|
||||||
collision_mask = 8
|
collision_mask = 8
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" parent="HitboxPivot/SwordHitbox" index="0"]
|
[node name="CollisionShape2D" parent="HitboxPivot/SwordHitbox" index="0"]
|
||||||
shape = SubResource( 40 )
|
shape = SubResource( 40 )
|
||||||
|
3
ActionRPG-HeartBeast/Player/SwordHitbox.gd
Normal file
3
ActionRPG-HeartBeast/Player/SwordHitbox.gd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
extends "res://Overlap/Hitbox.gd"
|
||||||
|
|
||||||
|
var knockback_vector = Vector2.ZERO
|
11
ActionRPG-HeartBeast/Stats.gd
Normal file
11
ActionRPG-HeartBeast/Stats.gd
Normal file
@ -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")
|
6
ActionRPG-HeartBeast/Stats.tscn
Normal file
6
ActionRPG-HeartBeast/Stats.tscn
Normal file
@ -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 )
|
@ -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://World/Bush.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
|
[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/CliffTileset.png" type="Texture" id=5]
|
||||||
[ext_resource path="res://World/Grass.tscn" type="PackedScene" id=6]
|
[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://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]
|
[sub_resource type="TileSet" id=1]
|
||||||
0/name = "DirtTileset.png 0"
|
0/name = "DirtTileset.png 0"
|
||||||
@ -593,6 +594,15 @@ position = Vector2( 48, 112 )
|
|||||||
[node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )]
|
[node name="Grass10" parent="YSort/Grass" instance=ExtResource( 6 )]
|
||||||
position = Vector2( 128, 121 )
|
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="."]
|
[node name="Control" type="Control" parent="."]
|
||||||
margin_right = 40.0
|
margin_right = 40.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 40.0
|
||||||
|
BIN
ActionRPG-HeartBeast/build/web/.DS_Store
vendored
BIN
ActionRPG-HeartBeast/build/web/.DS_Store
vendored
Binary file not shown.
Binary file not shown.
@ -139,7 +139,7 @@
|
|||||||
<script type='text/javascript' src='index.js'></script>
|
<script type='text/javascript' src='index.js'></script>
|
||||||
<script type='text/javascript'>//<![CDATA[
|
<script type='text/javascript'>//<![CDATA[
|
||||||
|
|
||||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2272176,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
|
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2277296,"index.wasm":13790961},"focusCanvas":true,"gdnativeLibs":[]};
|
||||||
var engine = new Engine(GODOT_CONFIG);
|
var engine = new Engine(GODOT_CONFIG);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
Binary file not shown.
@ -104,6 +104,7 @@ pointing/emulate_mouse_from_touch=false
|
|||||||
2d_physics/layer_2="Player"
|
2d_physics/layer_2="Player"
|
||||||
2d_physics/layer_3="PlayerHurtbox"
|
2d_physics/layer_3="PlayerHurtbox"
|
||||||
2d_physics/layer_4="EnemyHurtbox"
|
2d_physics/layer_4="EnemyHurtbox"
|
||||||
|
2d_physics/layer_5="Enemy"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
@ -12,21 +12,25 @@
|
|||||||
[node name="Left" type="TouchScreenButton" parent="."]
|
[node name="Left" type="TouchScreenButton" parent="."]
|
||||||
position = Vector2( 4, 133 )
|
position = Vector2( 4, 133 )
|
||||||
normal = ExtResource( 4 )
|
normal = ExtResource( 4 )
|
||||||
|
passby_press = true
|
||||||
action = "ui_left"
|
action = "ui_left"
|
||||||
|
|
||||||
[node name="Right" type="TouchScreenButton" parent="."]
|
[node name="Right" type="TouchScreenButton" parent="."]
|
||||||
position = Vector2( 43, 133 )
|
position = Vector2( 43, 133 )
|
||||||
normal = ExtResource( 2 )
|
normal = ExtResource( 2 )
|
||||||
|
passby_press = true
|
||||||
action = "ui_right"
|
action = "ui_right"
|
||||||
|
|
||||||
[node name="Up" type="TouchScreenButton" parent="."]
|
[node name="Up" type="TouchScreenButton" parent="."]
|
||||||
position = Vector2( 23, 113 )
|
position = Vector2( 23, 113 )
|
||||||
normal = ExtResource( 5 )
|
normal = ExtResource( 5 )
|
||||||
|
passby_press = true
|
||||||
action = "ui_up"
|
action = "ui_up"
|
||||||
|
|
||||||
[node name="Down" type="TouchScreenButton" parent="."]
|
[node name="Down" type="TouchScreenButton" parent="."]
|
||||||
position = Vector2( 23, 153 )
|
position = Vector2( 23, 153 )
|
||||||
normal = ExtResource( 6 )
|
normal = ExtResource( 6 )
|
||||||
|
passby_press = true
|
||||||
action = "ui_down"
|
action = "ui_down"
|
||||||
|
|
||||||
[node name="Attack" type="TouchScreenButton" parent="."]
|
[node name="Attack" type="TouchScreenButton" parent="."]
|
||||||
|
Loading…
Reference in New Issue
Block a user