forked from team-sg/hero-mark-2
first commit
This commit is contained in:
commit
096ebe5aa4
275 changed files with 3937 additions and 0 deletions
10
objects/Camera2D.tscn
Normal file
10
objects/Camera2D.tscn
Normal file
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://objects/camera.gd" type="Script" id=1]
|
||||
|
||||
[node name="Camera2D" type="Camera2D"]
|
||||
offset = Vector2( 128, 96 )
|
||||
current = true
|
||||
smoothing_enabled = true
|
||||
smoothing_speed = 8.0
|
||||
script = ExtResource( 1 )
|
16
objects/barrier/barrier.gd
Normal file
16
objects/barrier/barrier.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends Node2D
|
||||
|
||||
export var cost = 0
|
||||
onready var label = $Label
|
||||
|
||||
func _ready():
|
||||
label.visible = true
|
||||
label.set_text(str(cost))
|
||||
|
||||
func _physics_process(delta):
|
||||
#Open
|
||||
if Game.golds >= cost: $AnimationPlayer.play("open")
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
if anim_name == "open":
|
||||
queue_free()
|
122
objects/barrier/barrier.tscn
Normal file
122
objects/barrier/barrier.tscn
Normal file
|
@ -0,0 +1,122 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://objects/barrier/barrier.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/barrier/barrier.png" type="Texture" id=2]
|
||||
[ext_resource path="res://fonts/2ndpuberty..fnt" type="BitmapFont" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 2, 8 )
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "initial"
|
||||
length = 0.4
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
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": [ Rect2( 0, 0, 16, 16 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("StaticBody2D/CollisionShape2D:disabled")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("StaticBody2D:scale")
|
||||
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": [ Vector2( 1, 1 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "open"
|
||||
length = 0.4
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.4 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Rect2( 0, 0, 16, 16 ), Rect2( 0, 0, 16, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("StaticBody2D/CollisionShape2D:disabled")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.4 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ false, true ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("StaticBody2D:scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.4 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Theme" id=5]
|
||||
default_font = ExtResource( 3 )
|
||||
|
||||
[node name="Barrier" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
centered = false
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 16, 16 )
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2( 8, 8 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/initial = SubResource( 4 )
|
||||
anims/open = SubResource( 3 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = -12.0
|
||||
margin_top = -15.0
|
||||
margin_right = 28.0
|
||||
margin_bottom = 5.0
|
||||
theme = SubResource( 5 )
|
||||
text = "0"
|
||||
align = 1
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
24
objects/camera.gd
Normal file
24
objects/camera.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends Camera2D
|
||||
|
||||
onready var resolution = Game.resolution
|
||||
onready var player = get_parent().get_node("Player")
|
||||
onready var current_sector = (player.global_position / resolution).floor()
|
||||
onready var last_sector = current_sector
|
||||
|
||||
func _ready():
|
||||
set_as_toplevel(true)
|
||||
Game.current_sector = current_sector
|
||||
|
||||
func _process(delta):
|
||||
#Scroll screen when player is on different sector
|
||||
current_sector = (player.global_position / resolution).floor()
|
||||
if current_sector != last_sector:
|
||||
position = current_sector * resolution
|
||||
last_sector = current_sector
|
||||
Game.current_sector = current_sector
|
||||
|
||||
##Delete enemies when offscreen
|
||||
#func _on_CullArea_area_exited(area):
|
||||
# #delete offscreen enemies
|
||||
# if area.is_in_group("enemy"):
|
||||
# area.get_parent().queue_free()
|
13
objects/collectibles/gold.gd
Normal file
13
objects/collectibles/gold.gd
Normal file
|
@ -0,0 +1,13 @@
|
|||
extends Node2D
|
||||
|
||||
export var value = 1
|
||||
|
||||
func _ready():
|
||||
#Sync all coinframes
|
||||
$AnimatedSprite.play()
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Collect
|
||||
if area.is_in_group("player"):
|
||||
Game.golds += value
|
||||
queue_free()
|
53
objects/collectibles/gold.tscn
Normal file
53
objects/collectibles/gold.tscn
Normal file
|
@ -0,0 +1,53 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://objects/collectibles/gold.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=2]
|
||||
[ext_resource path="res://graphics/collectibles/coin.png" type="Texture" id=3]
|
||||
[ext_resource path="res://graphics/collectibles/pal_penny.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
shader_param/palette = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 0, 0, 8, 8 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 8, 0, 8, 8 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 16, 0, 8, 8 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=5]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 7.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[node name="Gold" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
frames = SubResource( 5 )
|
||||
frame = 1
|
||||
playing = true
|
||||
centered = false
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4, 4 )
|
||||
shape = SubResource( 6 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
12
objects/collectibles/shard.gd
Normal file
12
objects/collectibles/shard.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
export var value = 1
|
||||
|
||||
func _ready():
|
||||
$AnimationPlayer.play("glow")
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Collect
|
||||
if area.is_in_group("player"):
|
||||
Game.shards += value
|
||||
queue_free()
|
50
objects/collectibles/shard.tscn
Normal file
50
objects/collectibles/shard.tscn
Normal file
|
@ -0,0 +1,50 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
|
||||
[ext_resource path="res://graphics/collectibles/shard.png" type="Texture" id=2]
|
||||
[ext_resource path="res://objects/collectibles/shard.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=7]
|
||||
shader = ExtResource( 1 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
extents = Vector2( 5.5, 5.5 )
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
resource_name = "glow"
|
||||
length = 0.8
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.4, 0.8 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 0.329412, 0.360784, 0.847059, 1 ), Color( 1, 1, 1, 1 ), Color( 0.329412, 0.360784, 0.847059, 1 ) ]
|
||||
}
|
||||
|
||||
[node name="Shard" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
modulate = Color( 0.861621, 0.868095, 0.96844, 1 )
|
||||
material = SubResource( 7 )
|
||||
position = Vector2( 5, 3 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4.5, 2.5 )
|
||||
shape = SubResource( 6 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/glow = SubResource( 8 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
15
objects/collectibles/star.gd
Normal file
15
objects/collectibles/star.gd
Normal file
|
@ -0,0 +1,15 @@
|
|||
extends Node2D
|
||||
|
||||
export var value = 1
|
||||
|
||||
func _ready():
|
||||
#Sync all coinframes
|
||||
$AnimatedSprite.play()
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Collect
|
||||
if area.is_in_group("player"):
|
||||
Game.stars += value
|
||||
#5 Star reward
|
||||
if Game.stars == 5: Game.shards += 1
|
||||
queue_free()
|
67
objects/collectibles/star.tscn
Normal file
67
objects/collectibles/star.tscn
Normal file
|
@ -0,0 +1,67 @@
|
|||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/collectibles/pal_star_red.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=2]
|
||||
[ext_resource path="res://objects/collectibles/star.gd" type="Script" id=3]
|
||||
[ext_resource path="res://graphics/collectibles/star.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
shader_param/palette = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 0, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 11, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 22, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 33, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=6]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 44, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=7]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 55, 0, 11, 11 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=8]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 8.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=9]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[node name="Star" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( -1, -3 )
|
||||
frames = SubResource( 8 )
|
||||
frame = 3
|
||||
playing = true
|
||||
centered = false
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
visible = false
|
||||
position = Vector2( 4, 4 )
|
||||
shape = SubResource( 9 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
52
objects/enemy/enemy_move_sidesideupdown.gd
Normal file
52
objects/enemy/enemy_move_sidesideupdown.gd
Normal file
|
@ -0,0 +1,52 @@
|
|||
extends Node2D
|
||||
|
||||
#How far to move
|
||||
export var left_up_boundry = 0.0
|
||||
export var right_down_boundry = 0.0
|
||||
#Start direction
|
||||
export var direction = 1
|
||||
export var speed = 50
|
||||
#Move horizontal or vertical
|
||||
export(int, "Horizontal", "Vertical") var move_direction
|
||||
export var flip_sprite = true
|
||||
export var can_be_killed_by_sword = true
|
||||
#Onreadys
|
||||
onready var startpos = position
|
||||
onready var sprite = $AnimatedSprite
|
||||
|
||||
func _physics_process(delta):
|
||||
if move_direction == 0:
|
||||
move_side_to_side(delta)
|
||||
else: move_up_and_down(delta)
|
||||
|
||||
func move_side_to_side(delta):
|
||||
#Move
|
||||
position.x += direction * (speed * delta)
|
||||
#Switch dir
|
||||
if position.x >= startpos.x + (right_down_boundry * 8):
|
||||
direction = -1
|
||||
if flip_sprite == true: sprite.scale.x = -1
|
||||
if position.x <= startpos.x + (-left_up_boundry * 8):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.x = 1
|
||||
|
||||
func move_up_and_down(delta):
|
||||
#Move
|
||||
position.y += direction * (speed * delta)
|
||||
#Switch dir
|
||||
if position.y >= startpos.y + (right_down_boundry * 8):
|
||||
direction = -1
|
||||
if flip_sprite == true: sprite.scale.y = 1
|
||||
if position.y <= startpos.y + (-left_up_boundry * 8):
|
||||
direction = 1
|
||||
if flip_sprite == true: sprite.scale.y = -1
|
||||
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Kill player
|
||||
if area.is_in_group("player"):
|
||||
area.get_parent().die()
|
||||
#Die from sword
|
||||
if area.is_in_group("sword"):
|
||||
if can_be_killed_by_sword:
|
||||
queue_free()
|
12
objects/enemy/enemy_stationary.gd
Normal file
12
objects/enemy/enemy_stationary.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
export var can_be_killed_by_sword = true
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
#Kill player
|
||||
if area.is_in_group("player"):
|
||||
area.get_parent().die()
|
||||
#Die from sword
|
||||
if area.is_in_group("sword"):
|
||||
if can_be_killed_by_sword:
|
||||
queue_free()
|
49
objects/enemy/slime.tscn
Normal file
49
objects/enemy/slime.tscn
Normal file
|
@ -0,0 +1,49 @@
|
|||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/enemy/slime.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=2]
|
||||
[ext_resource path="res://graphics/enemy/slime_purple.png" type="Texture" id=3]
|
||||
[ext_resource path="res://objects/enemy/enemy_stationary.gd" type="Script" id=4]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
shader_param/palette = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 13, 13 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 13, 0, 13, 13 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=4]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 7.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=5]
|
||||
extents = Vector2( 5.5, 4.5 )
|
||||
|
||||
[node name="Slime" type="Node2D"]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 5, -5 )
|
||||
frames = SubResource( 4 )
|
||||
playing = true
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4.5, -4.5 )
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
45
objects/enemy/snake.tscn
Normal file
45
objects/enemy/snake.tscn
Normal file
|
@ -0,0 +1,45 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/enemy/snake.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=2]
|
||||
[ext_resource path="res://objects/enemy/enemy_move_sidesideupdown.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 16, 16 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 0, 16, 16 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=4]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 7.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=5]
|
||||
extents = Vector2( 8, 8 )
|
||||
|
||||
[node name="Snake" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
frames = SubResource( 4 )
|
||||
playing = true
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
4
objects/ladder/ladder.gd
Normal file
4
objects/ladder/ladder.gd
Normal file
|
@ -0,0 +1,4 @@
|
|||
extends Node2D
|
||||
onready var left_snap = $LeftSnap
|
||||
onready var right_snap = $RightSnap
|
||||
onready var middle = position.x + 4
|
23
objects/ladder/ladder.tscn
Normal file
23
objects/ladder/ladder.tscn
Normal file
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://objects/ladder/ladder.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[node name="Ladder" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4, 4 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="LeftSnap" type="Position2D" parent="."]
|
||||
position = Vector2( 0, 4 )
|
||||
|
||||
[node name="RightSnap" type="Position2D" parent="."]
|
||||
position = Vector2( 8, 4 )
|
171
objects/player/player.gd
Normal file
171
objects/player/player.gd
Normal file
|
@ -0,0 +1,171 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
##Children
|
||||
onready var sprite = $Sprite
|
||||
onready var climb_ray = $ClimbRay
|
||||
onready var anims = $AnimationPlayer
|
||||
onready var sword_sprite = $SwordSprite
|
||||
onready var sword_hitbox = $SwordArea
|
||||
##States
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD}
|
||||
var current_state = State.IDLE
|
||||
var axis = Vector2.ZERO
|
||||
##Physics
|
||||
var velocity = Vector2.ZERO
|
||||
var walk_speed = 50
|
||||
var gravity = 12.50
|
||||
var jump_pressure = 0
|
||||
var jump_force = 200
|
||||
var current_ladder = null
|
||||
##Attacking
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
axis = Vector2(Input.get_axis("ui_left","ui_right"),Input.get_axis("ui_up","ui_down"))
|
||||
#Check ladder
|
||||
check_ladder()
|
||||
match current_state:
|
||||
State.IDLE:
|
||||
_process_idle()
|
||||
continue
|
||||
State.WALK:
|
||||
_process_walk()
|
||||
continue
|
||||
State.IDLE, State.WALK:
|
||||
_process_idle_walk()
|
||||
State.JUMP:
|
||||
_process_jump()
|
||||
continue
|
||||
State.FALL:
|
||||
_process_fall()
|
||||
continue
|
||||
State.CLIMB:
|
||||
_process_climb()
|
||||
continue
|
||||
State.SWORD:
|
||||
_process_sword()
|
||||
#Gravity
|
||||
if current_state != State.CLIMB: velocity.y += gravity
|
||||
#Apply velocity
|
||||
move_and_slide(velocity,Vector2.UP)
|
||||
|
||||
print(Game.shards)
|
||||
if Input.is_action_just_pressed("debug_1"): $AnimationPlayer.play("Stab")
|
||||
|
||||
func _process_idle():
|
||||
if anims.get_current_animation() != "idle": anims.play("idle")
|
||||
#Stop
|
||||
velocity.x = 0
|
||||
#Goto Walk
|
||||
if axis.x != 0: current_state = State.WALK
|
||||
|
||||
func _process_walk():
|
||||
if anims.get_current_animation() != "walk": anims.play("walk")
|
||||
#Move
|
||||
move(walk_speed,0,true)
|
||||
#Goto Idle
|
||||
if axis.x == 0: current_state = State.IDLE
|
||||
#Push Blocks
|
||||
for i in get_slide_count():
|
||||
var collision = get_slide_collision(i)
|
||||
if collision.get_collider().is_in_group("pushable"):
|
||||
print(collision.get_collider())
|
||||
collision.get_collider().push(collision.normal)
|
||||
|
||||
func _process_idle_walk():
|
||||
velocity.y = 0
|
||||
#Goto Fall
|
||||
if !is_on_floor(): current_state = State.FALL
|
||||
#Goto Jump
|
||||
check_jump()
|
||||
#Goto Sword
|
||||
if Input.is_action_just_pressed("sword"):
|
||||
current_state = State.SWORD
|
||||
return
|
||||
|
||||
func _process_jump():
|
||||
jump_pressure += 1
|
||||
#Pressure sensitive jump
|
||||
if jump_pressure == 15 or Input.is_action_just_released("jump"):
|
||||
velocity.y = -jump_force / 4
|
||||
#velocity.y = 0
|
||||
current_state = State.FALL
|
||||
|
||||
func _process_fall():
|
||||
anims.play("jump")
|
||||
#anims.play("jump")
|
||||
move(walk_speed,0,true)
|
||||
#Return to idle
|
||||
if is_on_floor():
|
||||
current_state = State.IDLE
|
||||
return
|
||||
|
||||
func _process_climb():
|
||||
#Graphics
|
||||
anims.play("climb")
|
||||
anims.set_speed_scale(abs(axis.y))
|
||||
#Climb
|
||||
position.y += axis.y * 0.65
|
||||
#Manual Jump,, only works when holding neutral or away from ladder
|
||||
if axis.x != sprite.scale.x: check_jump()
|
||||
#Auto Jump
|
||||
if climb_ray.get_collider() == null:
|
||||
velocity.y = -jump_force
|
||||
current_state = State.FALL
|
||||
return
|
||||
|
||||
func _process_sword():
|
||||
anims.play("stab")
|
||||
#Stop
|
||||
velocity.x = 0
|
||||
sword_sprite.scale.x = sprite.scale.x
|
||||
#Move hitbox with flip
|
||||
sword_hitbox.position.x = 10 * sprite.scale.x
|
||||
#Return to idle after animationplayer end anim signal
|
||||
|
||||
|
||||
|
||||
func check_jump():
|
||||
if Input.is_action_just_pressed("jump") && !Input.is_action_pressed("ui_down"):
|
||||
#Detach ladder
|
||||
if current_state == State.CLIMB: position.x -= sprite.scale.x * 5
|
||||
anims.set_speed_scale(1)
|
||||
# Jump
|
||||
jump_pressure = 0
|
||||
current_state = State.JUMP
|
||||
anims.play("jump")
|
||||
velocity.y = -jump_force
|
||||
move(walk_speed,0,true)
|
||||
|
||||
|
||||
func move(hsp,vsp,flip:bool):
|
||||
velocity.x = hsp * axis.x
|
||||
#Flip
|
||||
if flip: if sign(axis.x) != 0: sprite.scale.x = axis.x
|
||||
|
||||
func check_ladder():
|
||||
if climb_ray.get_collider() != null:
|
||||
current_ladder = climb_ray.get_collider().get_parent()
|
||||
#Stop the velocity
|
||||
velocity = Vector2.ZERO
|
||||
#Snap to closest side
|
||||
if position.x < current_ladder.middle:
|
||||
position.x = current_ladder.left_snap.global_position.x
|
||||
sprite.scale.x = 1
|
||||
else:
|
||||
position.x = current_ladder.right_snap.global_position.x
|
||||
sprite.scale.x = -1
|
||||
#Start Climbing
|
||||
current_state = State.CLIMB
|
||||
#Move the raycast
|
||||
climb_ray.position.x = 4 * sprite.scale.x
|
||||
|
||||
func die():
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
#Return to idle after slash
|
||||
if anim_name == "stab":
|
||||
current_state = State.IDLE
|
||||
return
|
496
objects/player/player.tscn
Normal file
496
objects/player/player.tscn
Normal file
|
@ -0,0 +1,496 @@
|
|||
[gd_scene load_steps=43 format=2]
|
||||
|
||||
[ext_resource path="res://objects/player/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/player/sg_walk.png" type="Texture" id=2]
|
||||
[ext_resource path="res://graphics/player/sg_idle.png" type="Texture" id=3]
|
||||
[ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=4]
|
||||
[ext_resource path="res://graphics/player/jump.png" type="Texture" id=5]
|
||||
[ext_resource path="res://graphics/player/pal_purplearmor.png" type="Texture" id=6]
|
||||
[ext_resource path="res://graphics/player/sg_climb.png" type="Texture" id=7]
|
||||
[ext_resource path="res://graphics/player/pal_sword_red.png" type="Texture" id=8]
|
||||
[ext_resource path="res://graphics/player/sg_stab.png" type="Texture" id=9]
|
||||
[ext_resource path="res://graphics/player/sword_slash.png" type="Texture" id=10]
|
||||
[ext_resource path="res://graphics/player/sword_stab.png" type="Texture" id=11]
|
||||
[ext_resource path="res://graphics/player/sg_slash.png" type="Texture" id=12]
|
||||
[ext_resource path="res://scripts/recolor.tres" type="Shader" id=13]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=14]
|
||||
shader = ExtResource( 4 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = true
|
||||
shader_param/palette = ExtResource( 6 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 0, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 20, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=16]
|
||||
atlas = ExtResource( 12 )
|
||||
region = Rect2( 0, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=17]
|
||||
atlas = ExtResource( 12 )
|
||||
region = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=18]
|
||||
atlas = ExtResource( 12 )
|
||||
region = Rect2( 64, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=19]
|
||||
atlas = ExtResource( 9 )
|
||||
region = Rect2( 0, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=20]
|
||||
atlas = ExtResource( 9 )
|
||||
region = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 0, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 20, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 40, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 60, 0, 20, 20 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=5]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 12 ), SubResource( 13 ) ],
|
||||
"loop": true,
|
||||
"name": "climb",
|
||||
"speed": 7.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "jump",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 16 ), SubResource( 17 ), SubResource( 18 ) ],
|
||||
"loop": false,
|
||||
"name": "slash",
|
||||
"speed": 7.0
|
||||
}, {
|
||||
"frames": [ SubResource( 19 ), SubResource( 20 ) ],
|
||||
"loop": false,
|
||||
"name": "stab",
|
||||
"speed": 15.0
|
||||
}, {
|
||||
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 10.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=21]
|
||||
shader = ExtResource( 13 )
|
||||
shader_param/palette = ExtResource( 8 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=22]
|
||||
atlas = ExtResource( 10 )
|
||||
region = Rect2( 0, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=23]
|
||||
atlas = ExtResource( 10 )
|
||||
region = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=24]
|
||||
atlas = ExtResource( 10 )
|
||||
region = Rect2( 64, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=25]
|
||||
atlas = ExtResource( 11 )
|
||||
region = Rect2( 0, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=26]
|
||||
atlas = ExtResource( 11 )
|
||||
region = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=15]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 22 ), SubResource( 23 ), SubResource( 24 ) ],
|
||||
"loop": true,
|
||||
"name": "slash",
|
||||
"speed": 7.0
|
||||
}, {
|
||||
"frames": [ SubResource( 25 ), SubResource( 26 ) ],
|
||||
"loop": false,
|
||||
"name": "stab",
|
||||
"speed": 15.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=27]
|
||||
shader = ExtResource( 4 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = true
|
||||
shader_param/palette = ExtResource( 6 )
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=28]
|
||||
shader = ExtResource( 13 )
|
||||
shader_param/palette = ExtResource( 8 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
extents = Vector2( 4, 7 )
|
||||
|
||||
[sub_resource type="Animation" id=29]
|
||||
resource_name = "climb"
|
||||
length = 0.3
|
||||
loop = true
|
||||
step = 0.15
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.15 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ Rect2( 0, 0, 20, 20 ), Rect2( 20, 0, 20, 20 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 7 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("SwordArea/SwordHitBox:disabled")
|
||||
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": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("SwordSprite:texture")
|
||||
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": 1,
|
||||
"values": [ null ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=30]
|
||||
resource_name = "idle"
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.06
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
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": [ Rect2( 0, 0, 20, 20 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 3 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("SwordArea/SwordHitBox:disabled")
|
||||
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": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("SwordSprite:texture")
|
||||
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": 1,
|
||||
"values": [ null ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=31]
|
||||
resource_name = "jump"
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.06
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
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": [ Rect2( 1, 0, 20, 20 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 5 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("SwordArea/SwordHitBox:disabled")
|
||||
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": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("SwordSprite:texture")
|
||||
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": 1,
|
||||
"values": [ null ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=32]
|
||||
resource_name = "stab"
|
||||
length = 0.3
|
||||
step = 0.06
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.06 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ Rect2( 0, 0, 32, 32 ), Rect2( 32, 0, 32, 32 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 9 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("SwordArea/SwordHitBox:disabled")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.06 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("SwordSprite:texture")
|
||||
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": 1,
|
||||
"values": [ ExtResource( 11 ) ]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/path = NodePath("SwordSprite:region_rect")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"times": PoolRealArray( 0, 0.06 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ Rect2( 0, 0, 32, 32 ), Rect2( 32, 0, 32, 32 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=33]
|
||||
resource_name = "walk"
|
||||
length = 0.4
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:region_rect")
|
||||
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": [ Rect2( 0, 0, 20, 20 ), Rect2( 20, 0, 20, 20 ), Rect2( 40, 0, 20, 20 ), Rect2( 60, 0, 20, 20 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 2 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("SwordArea/SwordHitBox:disabled")
|
||||
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": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("SwordSprite:texture")
|
||||
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": 1,
|
||||
"values": [ null ]
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=34]
|
||||
extents = Vector2( 6, 7 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
visible = false
|
||||
material = SubResource( 14 )
|
||||
frames = SubResource( 5 )
|
||||
animation = "stab"
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="Sword" type="AnimatedSprite" parent="."]
|
||||
visible = false
|
||||
material = SubResource( 21 )
|
||||
frames = SubResource( 15 )
|
||||
animation = "stab"
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 27 )
|
||||
texture = ExtResource( 3 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 20, 20 )
|
||||
|
||||
[node name="SwordSprite" type="Sprite" parent="."]
|
||||
material = SubResource( 28 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["player"]]
|
||||
position = Vector2( 0, 3 )
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource( 6 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["sword"]]
|
||||
position = Vector2( 0, 3 )
|
||||
shape = SubResource( 6 )
|
||||
|
||||
[node name="ClimbRay" type="RayCast2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 4, 10 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, -14 )
|
||||
collision_mask = 4
|
||||
collide_with_areas = true
|
||||
collide_with_bodies = false
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/climb = SubResource( 29 )
|
||||
anims/idle = SubResource( 30 )
|
||||
anims/jump = SubResource( 31 )
|
||||
anims/stab = SubResource( 32 )
|
||||
anims/walk = SubResource( 33 )
|
||||
|
||||
[node name="SwordArea" type="Area2D" parent="." groups=["sword"]]
|
||||
|
||||
[node name="SwordHitBox" type="CollisionShape2D" parent="SwordArea"]
|
||||
position = Vector2( 10, 3 )
|
||||
shape = SubResource( 34 )
|
||||
disabled = true
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
13
objects/rock/rock.gd
Normal file
13
objects/rock/rock.gd
Normal file
|
@ -0,0 +1,13 @@
|
|||
extends KinematicBody2D
|
||||
var velocity = Vector2.ZERO
|
||||
|
||||
func _physics_process(delta):
|
||||
if !is_on_floor():
|
||||
#Gravity
|
||||
velocity.y = 100
|
||||
velocity.x = 0
|
||||
move_and_slide(velocity,Vector2.UP)
|
||||
velocity.x = 0
|
||||
|
||||
func push(direction):
|
||||
velocity -= direction * 32
|
26
objects/rock/rock.tscn
Normal file
26
objects/rock/rock.tscn
Normal file
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/rock/rock.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=2]
|
||||
[ext_resource path="res://objects/rock/rock.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 5, 4.5 )
|
||||
|
||||
[node name="Rock" type="KinematicBody2D" groups=["pushable"]]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 0, -1 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 2 )
|
Loading…
Add table
Add a link
Reference in a new issue