Adding all the files
This commit is contained in:
69
ActionRPG-HeartBeast/Player/Player.gd
Normal file
69
ActionRPG-HeartBeast/Player/Player.gd
Normal file
@ -0,0 +1,69 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2.ZERO
|
||||
var input_vector = Vector2.ZERO
|
||||
|
||||
const ACCELERATION = 500
|
||||
const MAX_SPEED = 80
|
||||
const FRICTION = 500
|
||||
|
||||
enum {
|
||||
MOVE,
|
||||
ROLL,
|
||||
ATTACK
|
||||
}
|
||||
|
||||
var state = MOVE
|
||||
|
||||
onready var animationPlayer = $AnimationPlayer
|
||||
onready var animationTree = $AnimationTree
|
||||
onready var animationState = animationTree.get("parameters/playback")
|
||||
|
||||
func _ready():
|
||||
animationTree.active = true
|
||||
|
||||
func _physics_process(delta):
|
||||
match state:
|
||||
MOVE:
|
||||
move_state(delta)
|
||||
|
||||
ROLL:
|
||||
pass
|
||||
|
||||
ATTACK:
|
||||
attack_state(delta)
|
||||
|
||||
func move_state(delta):
|
||||
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
|
||||
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
|
||||
input_vector = input_vector.normalized()
|
||||
if input_vector != Vector2.ZERO:
|
||||
animationTree.set("parameters/Idle/blend_position", input_vector)
|
||||
animationTree.set("parameters/Run/blend_position", input_vector)
|
||||
animationState.travel("Run")
|
||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
else:
|
||||
#animationPlayer.play("IdleRight")
|
||||
animationState.travel("Idle")
|
||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
|
||||
if Input.is_action_just_pressed("attack"):
|
||||
state = ATTACK
|
||||
|
||||
func attack_state(delta):
|
||||
#velocity = Vector2.ZERO
|
||||
animationTree.set("parameters/Attack/blend_position", input_vector)
|
||||
animationState.travel("Attack")
|
||||
velocity = Vector2.ZERO
|
||||
#velocity = velocity.move_toward(Vector2.ZERO, FRICTION*delta)
|
||||
#velocity = move_and_slide(velocity)
|
||||
|
||||
|
||||
func attack_aninimation_finished():
|
||||
state = MOVE
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
BIN
ActionRPG-HeartBeast/Player/Player.png
Normal file
BIN
ActionRPG-HeartBeast/Player/Player.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
35
ActionRPG-HeartBeast/Player/Player.png.import
Normal file
35
ActionRPG-HeartBeast/Player/Player.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/Player.png-3d0801c65bdfc563657cfa304115f1c7.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Player/Player.png"
|
||||
dest_files=[ "res://.import/Player.png-3d0801c65bdfc563657cfa304115f1c7.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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
413
ActionRPG-HeartBeast/Player/Player.tscn
Normal file
413
ActionRPG-HeartBeast/Player/Player.tscn
Normal file
@ -0,0 +1,413 @@
|
||||
[gd_scene load_steps=40 format=2]
|
||||
|
||||
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 4.0
|
||||
height = 4.0
|
||||
|
||||
[sub_resource type="Animation" id=27]
|
||||
resource_name = "AttackDown"
|
||||
length = 0.4
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 36, 37, 38, 39 ]
|
||||
}
|
||||
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.4 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "attack_aninimation_finished"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=28]
|
||||
resource_name = "AttackLeft"
|
||||
length = 0.4
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 32, 33, 34, 35 ]
|
||||
}
|
||||
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.4 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "attack_aninimation_finished"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=29]
|
||||
resource_name = "AttackRight"
|
||||
length = 0.4
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 24, 25, 26, 27 ]
|
||||
}
|
||||
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.4 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "attack_aninimation_finished"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=30]
|
||||
resource_name = "AttackUp"
|
||||
length = 0.4
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 28, 29, 30, 31 ]
|
||||
}
|
||||
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.4 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "attack_aninimation_finished"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=9]
|
||||
resource_name = "IdleDown"
|
||||
length = 0.1
|
||||
loop = true
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 18 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=10]
|
||||
resource_name = "IdleLeft"
|
||||
length = 0.1
|
||||
loop = true
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 12 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
resource_name = "IdleRight"
|
||||
length = 0.1
|
||||
loop = true
|
||||
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.1 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
resource_name = "IdleUp"
|
||||
length = 0.1
|
||||
loop = true
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 6 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
length = 0.001
|
||||
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 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=6]
|
||||
resource_name = "RunDown"
|
||||
length = 0.6
|
||||
loop = true
|
||||
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, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 19, 19, 21, 22, 23, 18 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "RunLeft"
|
||||
length = 0.6
|
||||
loop = true
|
||||
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, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 13, 14, 15, 16, 17, 12 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "RunRight"
|
||||
length = 0.6
|
||||
loop = true
|
||||
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, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 1, 2, 3, 4, 5, 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "RunUp"
|
||||
length = 0.6
|
||||
loop = true
|
||||
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, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 7, 8, 9, 10, 11, 7 ]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=31]
|
||||
animation = "AttackLeft"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=32]
|
||||
animation = "AttackDown"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=33]
|
||||
animation = "AttackRight"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=34]
|
||||
animation = "AttackUp"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendSpace2D" id=35]
|
||||
blend_point_0/node = SubResource( 31 )
|
||||
blend_point_0/pos = Vector2( -1, 0 )
|
||||
blend_point_1/node = SubResource( 32 )
|
||||
blend_point_1/pos = Vector2( 0, 1.1 )
|
||||
blend_point_2/node = SubResource( 33 )
|
||||
blend_point_2/pos = Vector2( 1, 0 )
|
||||
blend_point_3/node = SubResource( 34 )
|
||||
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=11]
|
||||
animation = "IdleLeft"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=12]
|
||||
animation = "IdleDown"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=13]
|
||||
animation = "IdleRight"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=14]
|
||||
animation = "IdleUp"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendSpace2D" id=15]
|
||||
blend_point_0/node = SubResource( 11 )
|
||||
blend_point_0/pos = Vector2( -1, 0 )
|
||||
blend_point_1/node = SubResource( 12 )
|
||||
blend_point_1/pos = Vector2( 0, 1.1 )
|
||||
blend_point_2/node = SubResource( 13 )
|
||||
blend_point_2/pos = Vector2( 1, 0 )
|
||||
blend_point_3/node = SubResource( 14 )
|
||||
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=20]
|
||||
animation = "RunLeft"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=21]
|
||||
animation = "RunDown"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=22]
|
||||
animation = "RunRight"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id=23]
|
||||
animation = "RunUp"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendSpace2D" id=24]
|
||||
blend_point_0/node = SubResource( 20 )
|
||||
blend_point_0/pos = Vector2( -1, 0 )
|
||||
blend_point_1/node = SubResource( 21 )
|
||||
blend_point_1/pos = Vector2( 0, 1.1 )
|
||||
blend_point_2/node = SubResource( 22 )
|
||||
blend_point_2/pos = Vector2( 1, 0 )
|
||||
blend_point_3/node = SubResource( 23 )
|
||||
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=25]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=26]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=36]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=37]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=38]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=39]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachine" id=18]
|
||||
states/Attack/node = SubResource( 35 )
|
||||
states/Attack/position = Vector2( 321.375, 203.5 )
|
||||
states/Idle/node = SubResource( 15 )
|
||||
states/Idle/position = Vector2( 323.5, 96.2812 )
|
||||
states/Run/node = SubResource( 24 )
|
||||
states/Run/position = Vector2( 509.5, 96.5 )
|
||||
transitions = [ "Run", "Idle", SubResource( 25 ), "Idle", "Run", SubResource( 26 ), "Idle", "Attack", SubResource( 36 ), "Attack", "Idle", SubResource( 37 ), "Attack", "Run", SubResource( 38 ), "Run", "Attack", SubResource( 39 ) ]
|
||||
start_node = "Idle"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=19]
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -9 )
|
||||
texture = ExtResource( 2 )
|
||||
hframes = 60
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = -1.5708
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/AttackDown = SubResource( 27 )
|
||||
anims/AttackLeft = SubResource( 28 )
|
||||
anims/AttackRight = SubResource( 29 )
|
||||
anims/AttackUp = SubResource( 30 )
|
||||
anims/IdleDown = SubResource( 9 )
|
||||
anims/IdleLeft = SubResource( 10 )
|
||||
anims/IdleRight = SubResource( 7 )
|
||||
anims/IdleUp = SubResource( 8 )
|
||||
anims/RESET = SubResource( 2 )
|
||||
anims/RunDown = SubResource( 6 )
|
||||
anims/RunLeft = SubResource( 4 )
|
||||
anims/RunRight = SubResource( 3 )
|
||||
anims/RunUp = SubResource( 5 )
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||
tree_root = SubResource( 18 )
|
||||
anim_player = NodePath("../AnimationPlayer")
|
||||
parameters/playback = SubResource( 19 )
|
||||
parameters/Attack/blend_position = Vector2( 0, 0 )
|
||||
parameters/Idle/blend_position = Vector2( 0, 0 )
|
||||
parameters/Run/blend_position = Vector2( 0, 0 )
|
Reference in New Issue
Block a user