Add the hit/hurt boxes, grass interactions and rolls

This commit is contained in:
Sameer Rahmani 2021-03-13 21:51:42 +00:00
parent 4adafe5813
commit 2bb6012f83
11 changed files with 600 additions and 144 deletions

5
AI/HitBox.tscn Normal file
View File

@ -0,0 +1,5 @@
[gd_scene format=2]
[node name="HitBox" type="Area2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

5
AI/HurtBox.tscn Normal file
View File

@ -0,0 +1,5 @@
[gd_scene format=2]
[node name="HurtBox" type="Area2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

12
Effects/GrassEffect.gd Normal file
View File

@ -0,0 +1,12 @@
extends Node2D
onready var animated_sprite = $AnimatedSprite
func _ready():
animated_sprite.frame = 0
animated_sprite.play("animate")
func _on_AnimatedSprite_animation_finished():
queue_free()

View File

@ -1 +0,0 @@
lxsameer@ou.767:1609785721

View File

@ -3,6 +3,7 @@ extends KinematicBody2D
const FRICTION = 800
const ACCL = 300
const MAX_SPEED = 100
const ROLL_SPEED = MAX_SPEED * 1.2
enum {
MOVE,
@ -12,37 +13,54 @@ enum {
var state = MOVE
var velocity = Vector2.ZERO
# At the Player scense, player has to be faced to the right for this
# vector to be correct
var roll_vector = Vector2.RIGHT
onready var animation_tree = $AnimationTree
onready var animation_state = animation_tree.get("parameters/playback")
func move():
velocity = move_and_slide(velocity)
func _ready():
animation_tree.active = true
func _physics_process(delta):
match state:
MOVE:
move(delta)
move_state(delta)
ROLL:
roll()
roll_state()
ATTACK:
attack()
attack_state()
func roll():
pass
func roll_state():
velocity = roll_vector * ROLL_SPEED
move()
animation_state.travel("Roll")
func attack():
func attack_state():
# don't slide and attack
velocity = Vector2.ZERO
animation_state.travel("Attack")
# I call this call back in a track on each roll animation
func roll_finished():
velocity = velocity * 0.8
state = MOVE
# I call this call back in a track on each attack animation
func attack_finished():
state = MOVE
func move(delta):
func move_state(delta):
var input_velocity = Vector2.ZERO
input_velocity.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
@ -50,9 +68,13 @@ func move(delta):
input_velocity = input_velocity.normalized()
if input_velocity != Vector2.ZERO:
# We want to roll in direction of our movement and rememebr which direction was it
roll_vector = input_velocity
animation_tree.set("parameters/Idle/blend_position", input_velocity)
animation_tree.set("parameters/Run/blend_position", input_velocity)
animation_tree.set("parameters/Attack/blend_position", input_velocity)
animation_tree.set("parameters/Roll/blend_position", input_velocity)
animation_state.travel("Run")
velocity = velocity.move_toward(input_velocity * MAX_SPEED, ACCL * delta)
@ -60,7 +82,10 @@ func move(delta):
animation_state.travel("Idle")
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)
move()
if Input.is_action_just_pressed("ui_attack"):
state = ATTACK
if Input.is_action_just_pressed("ui_roll"):
state = ROLL

View File

@ -1,13 +1,14 @@
[gd_scene load_steps=37 format=2]
[gd_scene load_steps=50 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://AI/HitBox.tscn" type="PackedScene" id=3]
[sub_resource type="CapsuleShape2D" id=1]
radius = 3.21513
height = 3.37022
[sub_resource type="Animation" id=35]
[sub_resource type="Animation" id=2]
resource_name = "AttackDown"
length = 0.4
tracks/0/type = "value"
@ -36,8 +37,32 @@ tracks/1/keys = {
"method": "attack_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitBoxPosition:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 90.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitBoxPosition/SwordHitBox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=36]
[sub_resource type="Animation" id=3]
resource_name = "AttackLeft"
length = 0.4
tracks/0/type = "value"
@ -66,8 +91,32 @@ tracks/1/keys = {
"method": "attack_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitBoxPosition:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 180.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitBoxPosition/SwordHitBox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=37]
[sub_resource type="Animation" id=4]
resource_name = "AttackRight"
length = 0.4
tracks/0/type = "value"
@ -96,8 +145,32 @@ tracks/1/keys = {
"method": "attack_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitBoxPosition/SwordHitBox/CollisionShape2D:disabled")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitBoxPosition:rotation_degrees")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
[sub_resource type="Animation" id=38]
[sub_resource type="Animation" id=5]
resource_name = "AttackUp"
length = 0.4
tracks/0/type = "value"
@ -126,8 +199,32 @@ tracks/1/keys = {
"method": "attack_finished"
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("HitBoxPosition:rotation_degrees")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ -90.0 ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("HitBoxPosition/SwordHitBox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.1, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=39]
[sub_resource type="Animation" id=6]
length = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
@ -142,7 +239,7 @@ tracks/0/keys = {
"values": [ 18 ]
}
[sub_resource type="Animation" id=40]
[sub_resource type="Animation" id=7]
length = 0.1
loop = true
tracks/0/type = "value"
@ -158,7 +255,7 @@ tracks/0/keys = {
"values": [ 12 ]
}
[sub_resource type="Animation" id=41]
[sub_resource type="Animation" id=8]
length = 0.1
loop = true
tracks/0/type = "value"
@ -174,7 +271,7 @@ tracks/0/keys = {
"values": [ 0 ]
}
[sub_resource type="Animation" id=42]
[sub_resource type="Animation" id=9]
length = 0.1
loop = true
tracks/0/type = "value"
@ -190,7 +287,127 @@ tracks/0/keys = {
"values": [ 6 ]
}
[sub_resource type="Animation" id=43]
[sub_resource type="Animation" id=36]
resource_name = "RollDown"
length = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 55, 56, 57, 58, 59 ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "roll_finished"
} ]
}
[sub_resource type="Animation" id=39]
resource_name = "RollLeft"
length = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 50, 51, 52, 53, 54 ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "roll_finished"
} ]
}
[sub_resource type="Animation" id=37]
resource_name = "RollRight"
length = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 40, 41, 42, 43, 44 ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "roll_finished"
} ]
}
[sub_resource type="Animation" id=38]
resource_name = "RollUp"
length = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 45, 46, 47, 48, 49 ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "roll_finished"
} ]
}
[sub_resource type="Animation" id=10]
length = 0.6
loop = true
tracks/0/type = "value"
@ -206,7 +423,7 @@ tracks/0/keys = {
"values": [ 19, 20, 21, 22, 23, 18 ]
}
[sub_resource type="Animation" id=44]
[sub_resource type="Animation" id=11]
length = 0.6
loop = true
tracks/0/type = "value"
@ -222,7 +439,7 @@ tracks/0/keys = {
"values": [ 13, 14, 15, 16, 17, 12 ]
}
[sub_resource type="Animation" id=45]
[sub_resource type="Animation" id=12]
length = 0.6
loop = true
tracks/0/type = "value"
@ -238,7 +455,7 @@ tracks/0/keys = {
"values": [ 1, 2, 3, 4, 5, 0 ]
}
[sub_resource type="Animation" id=46]
[sub_resource type="Animation" id=13]
length = 0.6
loop = true
tracks/0/type = "value"
@ -254,42 +471,17 @@ tracks/0/keys = {
"values": [ 7, 8, 9, 10, 11, 6 ]
}
[sub_resource type="AnimationNodeAnimation" id=28]
[sub_resource type="AnimationNodeAnimation" id=14]
animation = "AttackLeft"
[sub_resource type="AnimationNodeAnimation" id=29]
[sub_resource type="AnimationNodeAnimation" id=15]
animation = "AttackDown"
[sub_resource type="AnimationNodeAnimation" id=30]
[sub_resource type="AnimationNodeAnimation" id=16]
animation = "AttackRight"
[sub_resource type="AnimationNodeAnimation" id=31]
animation = "AttackUp"
[sub_resource type="AnimationNodeBlendSpace2D" id=32]
blend_point_0/node = SubResource( 28 )
blend_point_0/pos = Vector2( -1, 0 )
blend_point_1/node = SubResource( 29 )
blend_point_1/pos = Vector2( 0, 1.1 )
blend_point_2/node = SubResource( 30 )
blend_point_2/pos = Vector2( 1, 0 )
blend_point_3/node = SubResource( 31 )
blend_point_3/pos = Vector2( 0, -1.1 )
min_space = Vector2( -1, -1.1 )
max_space = Vector2( 1, 1.1 )
blend_mode = 1
[sub_resource type="AnimationNodeAnimation" id=14]
animation = "IdleLeft"
[sub_resource type="AnimationNodeAnimation" id=15]
animation = "IdleDown"
[sub_resource type="AnimationNodeAnimation" id=16]
animation = "IdleRight"
[sub_resource type="AnimationNodeAnimation" id=17]
animation = "IdleUp"
animation = "AttackUp"
[sub_resource type="AnimationNodeBlendSpace2D" id=18]
blend_point_0/node = SubResource( 14 )
@ -305,16 +497,16 @@ max_space = Vector2( 1, 1.1 )
blend_mode = 1
[sub_resource type="AnimationNodeAnimation" id=19]
animation = "RunLeft"
animation = "IdleLeft"
[sub_resource type="AnimationNodeAnimation" id=20]
animation = "RunDown"
animation = "IdleDown"
[sub_resource type="AnimationNodeAnimation" id=21]
animation = "RunRight"
animation = "IdleRight"
[sub_resource type="AnimationNodeAnimation" id=22]
animation = "RunUp"
animation = "IdleUp"
[sub_resource type="AnimationNodeBlendSpace2D" id=23]
blend_point_0/node = SubResource( 19 )
@ -329,57 +521,135 @@ min_space = Vector2( -1, -1.1 )
max_space = Vector2( 1, 1.1 )
blend_mode = 1
[sub_resource type="AnimationNodeStateMachineTransition" id=24]
[sub_resource type="AnimationNodeAnimation" id=40]
animation = "RollLeft"
[sub_resource type="AnimationNodeStateMachineTransition" id=25]
[sub_resource type="AnimationNodeAnimation" id=41]
animation = "RollDown"
[sub_resource type="AnimationNodeStateMachineTransition" id=33]
[sub_resource type="AnimationNodeAnimation" id=42]
animation = "RollRight"
[sub_resource type="AnimationNodeStateMachineTransition" id=34]
[sub_resource type="AnimationNodeAnimation" id=43]
animation = "RollUp"
[sub_resource type="AnimationNodeStateMachine" id=26]
states/Attack/node = SubResource( 32 )
[sub_resource type="AnimationNodeBlendSpace2D" id=44]
blend_point_0/node = SubResource( 40 )
blend_point_0/pos = Vector2( -1, 0 )
blend_point_1/node = SubResource( 41 )
blend_point_1/pos = Vector2( 0, 1.1 )
blend_point_2/node = SubResource( 42 )
blend_point_2/pos = Vector2( 1, 0 )
blend_point_3/node = SubResource( 43 )
blend_point_3/pos = Vector2( 0, -1.1 )
min_space = Vector2( -1, -1.1 )
max_space = Vector2( 1, 1.1 )
blend_mode = 1
[sub_resource type="AnimationNodeAnimation" id=24]
animation = "RunLeft"
[sub_resource type="AnimationNodeAnimation" id=25]
animation = "RunDown"
[sub_resource type="AnimationNodeAnimation" id=26]
animation = "RunRight"
[sub_resource type="AnimationNodeAnimation" id=27]
animation = "RunUp"
[sub_resource type="AnimationNodeBlendSpace2D" id=28]
blend_point_0/node = SubResource( 24 )
blend_point_0/pos = Vector2( -1, 0 )
blend_point_1/node = SubResource( 25 )
blend_point_1/pos = Vector2( 0, 1.1 )
blend_point_2/node = SubResource( 26 )
blend_point_2/pos = Vector2( 1, 0 )
blend_point_3/node = SubResource( 27 )
blend_point_3/pos = Vector2( 0, -1.1 )
min_space = Vector2( -1, -1.1 )
max_space = Vector2( 1, 1.1 )
blend_mode = 1
[sub_resource type="AnimationNodeStateMachineTransition" id=29]
[sub_resource type="AnimationNodeStateMachineTransition" id=30]
[sub_resource type="AnimationNodeStateMachineTransition" id=31]
[sub_resource type="AnimationNodeStateMachineTransition" id=32]
[sub_resource type="AnimationNodeStateMachineTransition" id=45]
[sub_resource type="AnimationNodeStateMachineTransition" id=46]
[sub_resource type="AnimationNodeStateMachine" id=33]
states/Attack/node = SubResource( 18 )
states/Attack/position = Vector2( 285, 201 )
states/Idle/node = SubResource( 18 )
states/Idle/node = SubResource( 23 )
states/Idle/position = Vector2( 285, 91 )
states/Run/node = SubResource( 23 )
states/Roll/node = SubResource( 44 )
states/Roll/position = Vector2( 75, 91 )
states/Run/node = SubResource( 28 )
states/Run/position = Vector2( 544, 91 )
transitions = [ "Idle", "Run", SubResource( 24 ), "Run", "Idle", SubResource( 25 ), "Attack", "Idle", SubResource( 33 ), "Idle", "Attack", SubResource( 34 ) ]
transitions = [ "Idle", "Run", SubResource( 29 ), "Run", "Idle", SubResource( 30 ), "Attack", "Idle", SubResource( 31 ), "Idle", "Attack", SubResource( 32 ), "Roll", "Idle", SubResource( 45 ), "Idle", "Roll", SubResource( 46 ) ]
start_node = "Idle"
[sub_resource type="AnimationNodeStateMachinePlayback" id=27]
[sub_resource type="AnimationNodeStateMachinePlayback" id=34]
[sub_resource type="CapsuleShape2D" id=35]
height = 12.0
[node name="player" type="KinematicBody2D"]
collision_layer = 2
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0.5, -10 )
texture = ExtResource( 2 )
hframes = 60
frame = 31
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
rotation = -1.5708
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/AttackDown = SubResource( 35 )
anims/AttackLeft = SubResource( 36 )
anims/AttackRight = SubResource( 37 )
anims/AttackUp = SubResource( 38 )
anims/IdleDown = SubResource( 39 )
anims/IdleLeft = SubResource( 40 )
anims/IdleRight = SubResource( 41 )
anims/IdleUp = SubResource( 42 )
anims/RunDown = SubResource( 43 )
anims/RunLeft = SubResource( 44 )
anims/RunRight = SubResource( 45 )
anims/RunUp = SubResource( 46 )
anims/AttackDown = SubResource( 2 )
anims/AttackLeft = SubResource( 3 )
anims/AttackRight = SubResource( 4 )
anims/AttackUp = SubResource( 5 )
anims/IdleDown = SubResource( 6 )
anims/IdleLeft = SubResource( 7 )
anims/IdleRight = SubResource( 8 )
anims/IdleUp = SubResource( 9 )
anims/RollDown = SubResource( 36 )
anims/RollLeft = SubResource( 39 )
anims/RollRight = SubResource( 37 )
anims/RollUp = SubResource( 38 )
anims/RunDown = SubResource( 10 )
anims/RunLeft = SubResource( 11 )
anims/RunRight = SubResource( 12 )
anims/RunUp = SubResource( 13 )
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = SubResource( 26 )
tree_root = SubResource( 33 )
anim_player = NodePath("../AnimationPlayer")
parameters/playback = SubResource( 27 )
parameters/playback = SubResource( 34 )
parameters/Attack/blend_position = Vector2( 0, 0 )
parameters/Idle/blend_position = Vector2( 0, 0 )
parameters/Roll/blend_position = Vector2( 0, 0 )
parameters/Run/blend_position = Vector2( 0, 0 )
[node name="HitBoxPosition" type="Position2D" parent="."]
position = Vector2( 0, -5 )
[node name="SwordHitBox" parent="HitBoxPosition" instance=ExtResource( 3 )]
position = Vector2( 16, 0 )
collision_layer = 0
collision_mask = 8
[node name="CollisionShape2D" parent="HitBoxPosition/SwordHitBox" index="0"]
shape = SubResource( 35 )
disabled = true
[editable path="HitBoxPosition/SwordHitBox"]

22
World/Grass.gd Normal file
View File

@ -0,0 +1,22 @@
extends Node2D
func destroy_effect():
var GrassEffect = load("res://World/GrassEffect.tscn")
var grass_effect = GrassEffect.instance()
var world_node = get_tree().current_scene
# We add the effect to the world and not to the grass itself since
# we're going to free the current node later.
# The better way to do it is to add the animated sprite in the same seen
# as the grass statically and just play the animation here and disable the it's
# interaction with the world such as hurt box
world_node.add_child(grass_effect)
# set the position of the effect to the global_position of the current grass
grass_effect.global_position = global_position
func _on_HurtBox_area_entered(_area):
destroy_effect()
queue_free()

27
World/Grass.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://World/Grass.png" type="Texture" id=1]
[ext_resource path="res://World/Grass.gd" type="Script" id=2]
[ext_resource path="res://AI/HurtBox.tscn" type="PackedScene" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 6.73923, 7.14616 )
[node name="Grass" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
offset = Vector2( -8, -8 )
[node name="HurtBox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
collision_mask = 2147483648
[node name="CollisionShape2D" parent="HurtBox" index="0"]
position = Vector2( 8, 8 )
shape = SubResource( 1 )
[connection signal="area_entered" from="HurtBox" to="." method="_on_HurtBox_area_entered"]
[editable path="HurtBox"]

43
World/GrassEffect.tscn Normal file
View File

@ -0,0 +1,43 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Effects/GrassEffect.png" type="Texture" id=1]
[ext_resource path="res://Effects/GrassEffect.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": false,
"name": "animate",
"speed": 15.0
} ]
[node name="GrassEffect" type="Node2D"]
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 6 )
animation = "animate"
frame = 4
centered = false
offset = Vector2( -8, -8 )
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]

View File

@ -57,6 +57,18 @@ ui_attack={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
ui_roll={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
]
}
[layer_names]
2d_physics/layer_1="World"
2d_physics/layer_2="Player"
2d_physics/layer_3="PlayerHurtBox"
2d_physics/layer_4="EnemyHurtBox"
[rendering]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=56 format=2]
[gd_scene load_steps=57 format=2]
[ext_resource path="res://World/Bush.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player/player.tscn" type="PackedScene" id=2]
@ -6,6 +6,13 @@
[ext_resource path="res://World/Tree.tscn" type="PackedScene" id=4]
[ext_resource path="res://World/DirtTileset.png" type="Texture" id=5]
[ext_resource path="res://World/CliffTileset.png" type="Texture" id=6]
[ext_resource path="res://World/Grass.tscn" type="PackedScene" id=7]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
@ -142,13 +149,7 @@ points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=47]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=48]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=49]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="TileSet" id=2]
[sub_resource type="TileSet" id=48]
0/name = "CliffTileset.png 0"
0/texture = ExtResource( 6 )
0/tex_offset = Vector2( 0, 0 )
@ -168,295 +169,295 @@ points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 3 )
0/shape = SubResource( 1 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 4 ),
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 5 ),
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 6 ),
"shape": SubResource( 4 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 7 ),
"shape": SubResource( 5 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 8 ),
"shape": SubResource( 6 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 9 ),
"shape": SubResource( 7 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 10 ),
"shape": SubResource( 8 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 11 ),
"shape": SubResource( 9 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 12 ),
"shape": SubResource( 10 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 13 ),
"shape": SubResource( 11 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 14 ),
"shape": SubResource( 12 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 15 ),
"shape": SubResource( 13 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 16 ),
"shape": SubResource( 14 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 17 ),
"shape": SubResource( 15 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 18 ),
"shape": SubResource( 16 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 19 ),
"shape": SubResource( 17 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 20 ),
"shape": SubResource( 18 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 21 ),
"shape": SubResource( 19 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 22 ),
"shape": SubResource( 20 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 23 ),
"shape": SubResource( 21 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 24 ),
"shape": SubResource( 22 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 25 ),
"shape": SubResource( 23 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 26 ),
"shape": SubResource( 24 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 27 ),
"shape": SubResource( 25 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 28 ),
"shape": SubResource( 26 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 6, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 29 ),
"shape": SubResource( 27 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 6, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 30 ),
"shape": SubResource( 28 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 6, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 31 ),
"shape": SubResource( 29 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 6, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 32 ),
"shape": SubResource( 30 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 6, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 33 ),
"shape": SubResource( 31 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 7, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 34 ),
"shape": SubResource( 32 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 7, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 35 ),
"shape": SubResource( 33 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 7, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 36 ),
"shape": SubResource( 34 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 7, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 37 ),
"shape": SubResource( 35 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 7, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 38 ),
"shape": SubResource( 36 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 39 ),
"shape": SubResource( 37 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 40 ),
"shape": SubResource( 38 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 41 ),
"shape": SubResource( 39 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 42 ),
"shape": SubResource( 40 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 43 ),
"shape": SubResource( 41 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 44 ),
"shape": SubResource( 42 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 45 ),
"shape": SubResource( 43 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 46 ),
"shape": SubResource( 44 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 47 ),
"shape": SubResource( 45 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 10, 3 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 48 ),
"shape": SubResource( 46 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 10, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 49 ),
"shape": SubResource( 47 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0
[sub_resource type="TileSet" id=1]
[sub_resource type="TileSet" id=49]
0/name = "DirtTileset.png 0"
0/texture = ExtResource( 5 )
0/tex_offset = Vector2( 0, 0 )
@ -490,13 +491,14 @@ region_enabled = true
region_rect = Rect2( 0, 0, 320, 180 )
[node name="CliffTileMap" type="TileMap" parent="."]
tile_set = SubResource( 2 )
tile_set = SubResource( 48 )
cell_size = Vector2( 32, 32 )
collision_mask = 0
format = 1
tile_data = PoolIntArray( -1, 0, 0, -65536, 0, 1, -65535, 0, 1, -65534, 0, 1, -65533, 0, 1, -65532, 0, 1, -65531, 0, 1, -65530, 0, 1, -65529, 0, 1, -65528, 0, 1, -65527, 0, 2, 65535, 0, 131072, 0, 0, 131073, 1, 0, 131073, 2, 0, 131073, 3, 0, 131073, 4, 0, 65542, 5, 0, 65541, 6, 0, 131073, 7, 0, 131073, 8, 0, 65542, 9, 0, 131077, 10, 0, 2, 65540, 0, 65536, 65541, 0, 65538, 65544, 0, 131072, 65545, 0, 131073, 65546, 0, 131074, 131076, 0, 131072, 131077, 0, 131074, 196617, 0, 0, 196618, 0, 2, 262146, 0, 3, 262150, 0, 3, 262152, 0, 0, 262153, 0, 131078, 262154, 0, 65538, 393215, 0, 196608, 327680, 0, 196609, 327681, 0, 196609, 327682, 0, 196616, 327683, 0, 196610, 327686, 0, 196612, 327687, 0, 196609, 327688, 0, 196614, 327689, 0, 131073, 327690, 0, 131074 )
[node name="DirtTileMap" type="TileMap" parent="."]
tile_set = SubResource( 1 )
tile_set = SubResource( 49 )
cell_size = Vector2( 16, 16 )
format = 1
tile_data = PoolIntArray( 196614, 0, 131077, 327679, 0, 131074, 262144, 0, 131075, 262145, 0, 131075, 262146, 0, 131075, 262147, 0, 131076, 262149, 0, 131074, 262150, 0, 262154, 262151, 0, 131076, 262156, 0, 131074, 262157, 0, 131075, 262158, 0, 131075, 262159, 0, 131079, 262160, 0, 327683, 262161, 0, 131080, 262162, 0, 131075, 262163, 0, 131075, 262164, 0, 131076, 393215, 0, 262146, 327680, 0, 262147, 327681, 0, 262147, 327682, 0, 262147, 327683, 0, 327687, 327684, 0, 327683, 327685, 0, 327688, 327686, 0, 262147, 327687, 0, 196617, 327692, 0, 196614, 327693, 0, 262147, 327694, 0, 262147, 327695, 0, 262148, 327697, 0, 262146, 327698, 0, 262147, 327699, 0, 262147, 327700, 0, 262148, 393223, 0, 327686, 393224, 0, 327683, 393225, 0, 131080, 393226, 0, 131079, 393227, 0, 327683, 393228, 0, 327689, 458761, 0, 196610, 458762, 0, 196612, 524297, 0, 196610, 524298, 0, 196612, 589833, 0, 196610, 589834, 0, 196612, 655369, 0, 196610, 655370, 0, 196612, 720905, 0, 196614, 720906, 0, 262148, 786441, 0, 262149 )
@ -506,14 +508,48 @@ tile_data = PoolIntArray( 196614, 0, 131077, 327679, 0, 131074, 262144, 0, 13107
[node name="player" parent="Ground" instance=ExtResource( 2 )]
position = Vector2( 32, 88 )
[node name="Bush" parent="Ground" instance=ExtResource( 1 )]
position = Vector2( 48, 56 )
[node name="Tree" parent="Ground" instance=ExtResource( 4 )]
position = Vector2( 248, 104 )
[node name="Bush2" parent="Ground" instance=ExtResource( 1 )]
[node name="Bushes" type="YSort" parent="Ground"]
[node name="Bush" parent="Ground/Bushes" instance=ExtResource( 1 )]
position = Vector2( 48, 56 )
[node name="Bush2" parent="Ground/Bushes" instance=ExtResource( 1 )]
position = Vector2( 128, 120 )
[node name="Bush3" parent="Ground" instance=ExtResource( 1 )]
[node name="Bush3" parent="Ground/Bushes" instance=ExtResource( 1 )]
position = Vector2( 240, 40 )
[node name="Grass" type="YSort" parent="Ground"]
[node name="Grass" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 48, 136 )
[node name="Grass4" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 48, 144 )
[node name="Grass5" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 32, 144 )
[node name="Grass6" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 112, 48 )
[node name="Grass7" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 208, 40 )
[node name="Grass8" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 224, 112 )
[node name="Grass9" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 176, 136 )
[node name="Grass10" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 72, 96 )
[node name="Grass2" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 32, 128 )
[node name="Grass3" parent="Ground/Grass" instance=ExtResource( 7 )]
position = Vector2( 16, 144 )