Skip to content

Commit

Permalink
changed movement of player and moved player and enemies to separate s…
Browse files Browse the repository at this point in the history
…cenes
  • Loading branch information
konsvasi committed Feb 21, 2018
1 parent a20e1b5 commit d70a7a1
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 158 deletions.
74 changes: 74 additions & 0 deletions Scenes/Enemy.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[gd_scene load_steps=16 format=2]

[ext_resource path="res://Scripts/skeleton.gd" type="Script" id=1]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_1.png" type="Texture" id=2]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_1.png" type="Texture" id=3]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_2.png" type="Texture" id=4]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_3.png" type="Texture" id=5]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_1.png" type="Texture" id=6]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_2.png" type="Texture" id=7]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_3.png" type="Texture" id=8]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_2.png" type="Texture" id=9]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_3.png" type="Texture" id=10]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_1.png" type="Texture" id=11]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_2.png" type="Texture" id=12]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_3.png" type="Texture" id=13]

[sub_resource type="SpriteFrames" id=1]

animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "idle",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ), ExtResource( 4 ), ExtResource( 3 ), ExtResource( 5 ) ],
"loop": true,
"name": "walk_right",
"speed": 5.0
}, {
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 6 ), ExtResource( 8 ) ],
"loop": true,
"name": "walk_left",
"speed": 5.0
}, {
"frames": [ ExtResource( 2 ), ExtResource( 9 ), ExtResource( 2 ), ExtResource( 10 ) ],
"loop": true,
"name": "walk_down",
"speed": 5.0
}, {
"frames": [ ExtResource( 11 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 13 ) ],
"loop": true,
"name": "walk_up",
"speed": 5.0
} ]

[sub_resource type="CapsuleShape2D" id=2]

custom_solver_bias = 0.0
radius = 10.0
height = 6.54572

[node name="skeleton" type="KinematicBody2D"]

position = Vector2( 448, 384 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 1 )
__meta__ = {
"_edit_group_": true
}

[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]

frames = SubResource( 1 )
animation = "idle"
playing = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]

shape = SubResource( 2 )


76 changes: 76 additions & 0 deletions Scenes/Player.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[gd_scene load_steps=16 format=2]

[ext_resource path="res://Scripts/Player.gd" type="Script" id=1]
[ext_resource path="res://Tilesets/walk_down_1.png" type="Texture" id=2]
[ext_resource path="res://Tilesets/walk_right_1.png" type="Texture" id=3]
[ext_resource path="res://Tilesets/walk_right_2.png" type="Texture" id=4]
[ext_resource path="res://Tilesets/walk_right_3.png" type="Texture" id=5]
[ext_resource path="res://Tilesets/walk_left_1.png" type="Texture" id=6]
[ext_resource path="res://Tilesets/walk_left_2.png" type="Texture" id=7]
[ext_resource path="res://Tilesets/walk_left_3.png" type="Texture" id=8]
[ext_resource path="res://Tilesets/walk_down_2.png" type="Texture" id=9]
[ext_resource path="res://Tilesets/walk_down_3.png" type="Texture" id=10]
[ext_resource path="res://Tilesets/walk_up_1.png" type="Texture" id=11]
[ext_resource path="res://Tilesets/walk_up_2.png" type="Texture" id=12]
[ext_resource path="res://Tilesets/walk_up_3.png" type="Texture" id=13]

[sub_resource type="SpriteFrames" id=1]

animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "idle",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ) ],
"loop": true,
"name": "walk_right",
"speed": 10.0
}, {
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 6 ), ExtResource( 8 ) ],
"loop": true,
"name": "walk_left",
"speed": 10.0
}, {
"frames": [ ExtResource( 2 ), ExtResource( 9 ), ExtResource( 2 ), ExtResource( 10 ) ],
"loop": true,
"name": "walk_down",
"speed": 10.0
}, {
"frames": [ ExtResource( 11 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ) ],
"loop": true,
"name": "walk_up",
"speed": 10.0
} ]
_sections_unfolded = [ "Resource" ]

[sub_resource type="CapsuleShape2D" id=2]

custom_solver_bias = 0.0
radius = 10.0
height = 4.01181

[node name="Player" type="KinematicBody2D"]

editor/display_folded = true
position = Vector2( 544, 160 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 1 )
_sections_unfolded = [ "Transform" ]
__meta__ = {
"_edit_group_": true
}

[node name="Sprite" type="AnimatedSprite" parent="." index="0"]

frames = SubResource( 1 )
animation = "idle"

[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]

shape = SubResource( 2 )


19 changes: 19 additions & 0 deletions Scenes/World.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends Node2D

export (PackedScene) var enemies

func _ready():
randomize()


func _on_enemyTimer_timeout():
$EnemyPath/spawnLocation.set_offset(randi())
var enemy = enemies.instance()
add_child(enemy)
enemy.get_node("AnimatedSprite").play("walk_down")

var direction = $EnemyPath/spawnLocation.rotation + PI/2
enemy.position = $EnemyPath/spawnLocation.position
direction += rand_range(-PI/4, PI/4)
#enemy.set_linear_velocity(Vector2(rand_range(20, 85), 0).rotated(direction))
enemy.move_and_slide(Vector2())
190 changes: 43 additions & 147 deletions Scenes/World.tscn
Original file line number Diff line number Diff line change
@@ -1,112 +1,28 @@
[gd_scene load_steps=33 format=2]

[ext_resource path="res://Tilesets/worldTileSet.tres" type="TileSet" id=1]
[ext_resource path="res://Scripts/Player.gd" type="Script" id=2]
[ext_resource path="res://Tilesets/walk_up_1.png" type="Texture" id=3]
[ext_resource path="res://Tilesets/walk_up_2.png" type="Texture" id=4]
[ext_resource path="res://Tilesets/walk_up_3.png" type="Texture" id=5]
[ext_resource path="res://Tilesets/walk_down_1.png" type="Texture" id=6]
[ext_resource path="res://Tilesets/walk_down_2.png" type="Texture" id=7]
[ext_resource path="res://Tilesets/walk_down_3.png" type="Texture" id=8]
[ext_resource path="res://Tilesets/walk_left_1.png" type="Texture" id=9]
[ext_resource path="res://Tilesets/walk_left_2.png" type="Texture" id=10]
[ext_resource path="res://Tilesets/walk_left_3.png" type="Texture" id=11]
[ext_resource path="res://Tilesets/walk_right_1.png" type="Texture" id=12]
[ext_resource path="res://Tilesets/walk_right_2.png" type="Texture" id=13]
[ext_resource path="res://Tilesets/walk_right_3.png" type="Texture" id=14]
[ext_resource path="res://Scripts/skeleton.gd" type="Script" id=15]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_1.png" type="Texture" id=16]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_2.png" type="Texture" id=17]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_up_3.png" type="Texture" id=18]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_1.png" type="Texture" id=19]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_2.png" type="Texture" id=20]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_down_3.png" type="Texture" id=21]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_1.png" type="Texture" id=22]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_2.png" type="Texture" id=23]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_left_3.png" type="Texture" id=24]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_1.png" type="Texture" id=25]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_2.png" type="Texture" id=26]
[ext_resource path="res://Tilesets/monster_animations/monster_walk_right_3.png" type="Texture" id=27]
[ext_resource path="res://Scenes/Portal.tscn" type="PackedScene" id=28]

[sub_resource type="SpriteFrames" id=1]

animations = [ {
"frames": [ ExtResource( 3 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ) ],
"loop": true,
"name": "walk_up",
"speed": 10.0
}, {
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 6 ), ExtResource( 8 ) ],
"loop": true,
"name": "walk_down",
"speed": 10.0
}, {
"frames": [ ExtResource( 9 ), ExtResource( 10 ), ExtResource( 9 ), ExtResource( 11 ) ],
"loop": true,
"name": "walk_left",
"speed": 10.0
}, {
"frames": [ ExtResource( 12 ), ExtResource( 12 ), ExtResource( 13 ), ExtResource( 14 ) ],
"loop": true,
"name": "walk_right",
"speed": 10.0
}, {
"frames": [ ExtResource( 6 ) ],
"loop": true,
"name": "idle",
"speed": 5.0
} ]
_sections_unfolded = [ "Resource" ]

[sub_resource type="CapsuleShape2D" id=2]

custom_solver_bias = 0.0
radius = 10.0
height = 4.01181

[sub_resource type="SpriteFrames" id=3]

animations = [ {
"frames": [ ExtResource( 16 ), ExtResource( 17 ), ExtResource( 16 ), ExtResource( 18 ) ],
"loop": true,
"name": "walk_up",
"speed": 5.0
}, {
"frames": [ ExtResource( 19 ), ExtResource( 20 ), ExtResource( 19 ), ExtResource( 21 ) ],
"loop": true,
"name": "walk_down",
"speed": 5.0
}, {
"frames": [ ExtResource( 22 ), ExtResource( 23 ), ExtResource( 22 ), ExtResource( 24 ) ],
"loop": true,
"name": "walk_left",
"speed": 5.0
}, {
"frames": [ ExtResource( 25 ), ExtResource( 26 ), ExtResource( 25 ), ExtResource( 27 ) ],
"loop": true,
"name": "walk_right",
"speed": 5.0
}, {
"frames": [ ExtResource( 19 ) ],
"loop": true,
"name": "idle",
"speed": 5.0
} ]

[sub_resource type="CapsuleShape2D" id=4]

custom_solver_bias = 0.0
radius = 10.0
height = 6.54572
[gd_scene load_steps=7 format=2]

[ext_resource path="res://Scenes/World.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Enemy.tscn" type="PackedScene" id=2]
[ext_resource path="res://Tilesets/worldTileSet.tres" type="TileSet" id=3]
[ext_resource path="res://Scenes/Player.tscn" type="PackedScene" id=4]
[ext_resource path="res://Scenes/Portal.tscn" type="PackedScene" id=5]

[sub_resource type="Curve2D" id=1]

bake_interval = 5.0
_data = {
"points": PoolVector2Array( 0, 0, 0, 0, 162.002, 449.326, 0, 0, 0, 0, 638.004, 449.326, 0, 0, 0, 0, 639.011, 571.326 )
}

[node name="World" type="Node2D" index="0"]

script = ExtResource( 1 )
enemies = ExtResource( 2 )

[node name="TileMap_BACK" type="TileMap" parent="." index="0"]

position = Vector2( -96, 0 )
mode = 0
tile_set = ExtResource( 1 )
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 16
cell_custom_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
Expand All @@ -131,7 +47,7 @@ __meta__ = {

position = Vector2( -96, 0 )
mode = 0
tile_set = ExtResource( 1 )
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 16
cell_custom_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
Expand All @@ -152,63 +68,43 @@ __meta__ = {
"_edit_lock_": true
}

[node name="Player" type="KinematicBody2D" parent="." index="2"]

editor/display_folded = true
position = Vector2( 544, 160 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 2 )
_sections_unfolded = [ "Transform" ]
__meta__ = {
"_edit_group_": true
}

[node name="Sprite" type="AnimatedSprite" parent="Player" index="0"]

frames = SubResource( 1 )
animation = "idle"
[node name="Player" parent="." index="2" instance=ExtResource( 4 )]

[node name="CollisionShape2D" type="CollisionShape2D" parent="Player" index="1"]
[node name="skeleton" parent="." index="3" instance=ExtResource( 2 )]

shape = SubResource( 2 )

[node name="skeleton" type="KinematicBody2D" parent="." index="3"]
[node name="stairsToBasement" parent="." index="4" instance=ExtResource( 5 )]

editor/display_folded = true
position = Vector2( 448, 384 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 15 )
__meta__ = {
"_edit_group_": true
}

[node name="AnimatedSprite" type="AnimatedSprite" parent="skeleton" index="0"]
position = Vector2( 366.26, 175.42 )

frames = SubResource( 3 )
animation = "idle"
playing = true
[node name="Area2D" parent="stairsToBasement" index="0"]

[node name="CollisionShape2D" type="CollisionShape2D" parent="skeleton" index="1"]
nextScene = "res://Scenes/Basement.tscn"

shape = SubResource( 4 )
[node name="EnemyPath" type="Path2D" parent="." index="5"]

[node name="Position2D" type="Position2D" parent="." index="4"]
curve = SubResource( 1 )

position = Vector2( 355.941, 504.996 )
[node name="spawnLocation" type="PathFollow2D" parent="EnemyPath" index="0"]

[node name="stairsToBasement" parent="." index="5" instance=ExtResource( 28 )]
position = Vector2( 162.002, 449.326 )
rotation = -1.55468e-05
offset = 0.0
h_offset = 0.0
v_offset = 0.0
rotate = true
cubic_interp = true
loop = true
lookahead = 4.0

position = Vector2( 366.26, 175.42 )
[node name="enemyTimer" type="Timer" parent="." index="6"]

[node name="Area2D" parent="stairsToBasement" index="0"]
process_mode = 1
wait_time = 1.0
one_shot = false
autostart = true

nextScene = "res://Scenes/Basement.tscn"
[connection signal="timeout" from="enemyTimer" to="." method="_on_enemyTimer_timeout"]


[editable path="stairsToBasement"]
Loading

0 comments on commit d70a7a1

Please sign in to comment.