From fcfc2f9df77c4e7d10eea6a9dee10f0d13288f9c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 30 Jul 2020 11:31:31 +0300 Subject: Add shadows to characters --- scenes/CharacterShadow.tscn | 11 ++++ scenes/DwarfNPC.tscn | 9 ++- scenes/PlayerCharacter.tscn | 7 ++- scenes/Scene1.tscn | 140 ++++++++++++++++++++++---------------------- 4 files changed, 93 insertions(+), 74 deletions(-) create mode 100644 scenes/CharacterShadow.tscn (limited to 'scenes') diff --git a/scenes/CharacterShadow.tscn b/scenes/CharacterShadow.tscn new file mode 100644 index 0000000..9413d6d --- /dev/null +++ b/scenes/CharacterShadow.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/Shadow.gd" type="Script" id=1] + +[node name="CharacterShadow" type="Node2D"] +position = Vector2( 0.5, -0.5 ) +scale = Vector2( 1, 0.5 ) +z_index = -1 +script = ExtResource( 1 ) +radius = 4.0 +color = Color( 0.145098, 0.145098, 0.145098, 1 ) diff --git a/scenes/DwarfNPC.tscn b/scenes/DwarfNPC.tscn index a2d206d..3395724 100644 --- a/scenes/DwarfNPC.tscn +++ b/scenes/DwarfNPC.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://textures/dwarf_idle_01.tres" type="Texture" id=1] [ext_resource path="res://scripts/DwarfNPC.gd" type="Script" id=2] +[ext_resource path="res://scenes/CharacterShadow.tscn" type="PackedScene" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 4, 2 ) @@ -16,4 +17,8 @@ shape = SubResource( 1 ) [node name="Sprite" type="Sprite" parent="."] position = Vector2( 0, -1 ) texture = ExtResource( 1 ) -offset = Vector2( 3, -5 ) +offset = Vector2( 3, -6 ) + +[node name="CharacterShadow" parent="Sprite" instance=ExtResource( 3 )] +position = Vector2( 0.5, 0.5 ) +color = Color( 0, 0, 0, 0.196078 ) diff --git a/scenes/PlayerCharacter.tscn b/scenes/PlayerCharacter.tscn index b905cd5..85b3914 100644 --- a/scenes/PlayerCharacter.tscn +++ b/scenes/PlayerCharacter.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://textures/monk_idle.tres" type="Texture" id=1] [ext_resource path="res://scripts/PlayerCharacter.gd" type="Script" id=2] +[ext_resource path="res://scenes/CharacterShadow.tscn" type="PackedScene" id=3] [sub_resource type="AnimatedTexture" id=1] frame_0/texture = ExtResource( 1 ) @@ -10,7 +11,6 @@ frame_0/texture = ExtResource( 1 ) extents = Vector2( 4, 2 ) [node name="PlayerCharacter" type="KinematicBody2D"] -position = Vector2( 0, -0.5 ) collision/safe_margin = 0.001 script = ExtResource( 2 ) speed = 24 @@ -20,6 +20,9 @@ walk_wobble_coeff = 10.0 texture = SubResource( 1 ) offset = Vector2( 6, -6.5 ) +[node name="CharacterShadow" parent="Sprite" instance=ExtResource( 3 )] +color = Color( 0, 0, 0, 0.196078 ) + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2( 0, -1.5 ) shape = SubResource( 2 ) diff --git a/scenes/Scene1.tscn b/scenes/Scene1.tscn index ce08c03..2741c4a 100644 --- a/scenes/Scene1.tscn +++ b/scenes/Scene1.tscn @@ -6,139 +6,139 @@ [ext_resource path="res://scripts/Scene1.gd" type="Script" id=4] [ext_resource path="res://externals/point_light.png" type="Texture" id=5] -[sub_resource type="OccluderPolygon2D" id=27] +[sub_resource type="OccluderPolygon2D" id=1] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=34] +[sub_resource type="OccluderPolygon2D" id=2] polygon = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=35] +[sub_resource type="OccluderPolygon2D" id=3] polygon = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=26] +[sub_resource type="OccluderPolygon2D" id=4] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=36] +[sub_resource type="OccluderPolygon2D" id=5] polygon = PoolVector2Array( 0, 0, 4, 0, 4, 8, 0, 8 ) -[sub_resource type="OccluderPolygon2D" id=37] +[sub_resource type="OccluderPolygon2D" id=6] polygon = PoolVector2Array( 0, 0, 4, 0, 4, 8, 0, 8 ) -[sub_resource type="OccluderPolygon2D" id=28] +[sub_resource type="OccluderPolygon2D" id=7] polygon = PoolVector2Array( 8, 8, 4, 8, 4, 4, 8, 4 ) -[sub_resource type="OccluderPolygon2D" id=29] +[sub_resource type="OccluderPolygon2D" id=8] polygon = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=30] +[sub_resource type="OccluderPolygon2D" id=9] polygon = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=31] +[sub_resource type="OccluderPolygon2D" id=10] polygon = PoolVector2Array( 0, 8, 4, 8, 4, 4, 0, 4 ) -[sub_resource type="OccluderPolygon2D" id=32] +[sub_resource type="OccluderPolygon2D" id=11] polygon = PoolVector2Array( 0, 8, 4, 8, 4, 0, 0, 0 ) -[sub_resource type="OccluderPolygon2D" id=33] +[sub_resource type="OccluderPolygon2D" id=12] polygon = PoolVector2Array( 0, 0, 4, 0, 4, 8, 0, 8 ) -[sub_resource type="OccluderPolygon2D" id=38] +[sub_resource type="OccluderPolygon2D" id=13] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=39] +[sub_resource type="OccluderPolygon2D" id=14] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=40] +[sub_resource type="OccluderPolygon2D" id=15] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=41] +[sub_resource type="OccluderPolygon2D" id=16] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=42] +[sub_resource type="OccluderPolygon2D" id=17] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=43] +[sub_resource type="OccluderPolygon2D" id=18] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=44] +[sub_resource type="OccluderPolygon2D" id=19] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=45] +[sub_resource type="OccluderPolygon2D" id=20] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=46] +[sub_resource type="OccluderPolygon2D" id=21] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="OccluderPolygon2D" id=47] +[sub_resource type="OccluderPolygon2D" id=22] polygon = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=1] +[sub_resource type="ConvexPolygonShape2D" id=23] points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=2] +[sub_resource type="ConvexPolygonShape2D" id=24] points = PoolVector2Array( 0, 4, 8, 4, 8, 8, 0, 8 ) -[sub_resource type="ConvexPolygonShape2D" id=3] +[sub_resource type="ConvexPolygonShape2D" id=25] points = PoolVector2Array( 8, 8, 4, 8, 4, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=4] +[sub_resource type="ConvexPolygonShape2D" id=26] points = PoolVector2Array( 0, 4, 4, 4, 4, 8, 0, 8 ) -[sub_resource type="ConvexPolygonShape2D" id=5] +[sub_resource type="ConvexPolygonShape2D" id=27] points = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=6] +[sub_resource type="ConvexPolygonShape2D" id=28] points = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=7] +[sub_resource type="ConvexPolygonShape2D" id=29] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=8] +[sub_resource type="ConvexPolygonShape2D" id=30] points = PoolVector2Array( 8, 8, 4, 8, 4, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=9] +[sub_resource type="ConvexPolygonShape2D" id=31] points = PoolVector2Array( 8, 8, 4, 8, 4, 0, 8, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=10] +[sub_resource type="ConvexPolygonShape2D" id=32] points = PoolVector2Array( 0, 0, 4, 0, 4, 8, 0, 8 ) -[sub_resource type="ConvexPolygonShape2D" id=11] +[sub_resource type="ConvexPolygonShape2D" id=33] points = PoolVector2Array( 4, 8, 0, 8, 0, 0, 4, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=12] +[sub_resource type="ConvexPolygonShape2D" id=34] points = PoolVector2Array( 4, 8, 0, 8, 0, 4, 4, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=13] +[sub_resource type="ConvexPolygonShape2D" id=35] points = PoolVector2Array( 4, 8, 0, 8, 0, 0, 4, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=14] +[sub_resource type="ConvexPolygonShape2D" id=36] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=15] +[sub_resource type="ConvexPolygonShape2D" id=37] points = PoolVector2Array( 4, 0, 4, 4, 8, 4, 8, 8, 0, 8, 0, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=16] +[sub_resource type="ConvexPolygonShape2D" id=38] points = PoolVector2Array( 4, 4, 4, 0, 8, 0, 8, 8, 0, 8, 0, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=17] +[sub_resource type="ConvexPolygonShape2D" id=39] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=18] +[sub_resource type="ConvexPolygonShape2D" id=40] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=19] +[sub_resource type="ConvexPolygonShape2D" id=41] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=20] +[sub_resource type="ConvexPolygonShape2D" id=42] points = PoolVector2Array( 8, 8, 0, 8, 0, 4, 8, 4 ) -[sub_resource type="ConvexPolygonShape2D" id=21] +[sub_resource type="ConvexPolygonShape2D" id=43] points = PoolVector2Array( 4, 0, 4, 4, 8, 4, 8, 8, 0, 8, 0, 0 ) -[sub_resource type="ConvexPolygonShape2D" id=22] +[sub_resource type="ConvexPolygonShape2D" id=44] points = PoolVector2Array( 4, 4, 4, 0, 8, 0, 8, 8, 0, 8, 0, 4 ) -[sub_resource type="TileSet" id=23] +[sub_resource type="TileSet" id=45] 0/name = "world_tileset.tres 0" 0/texture = ExtResource( 2 ) 0/tex_offset = Vector2( 0, 0 ) @@ -148,7 +148,7 @@ points = PoolVector2Array( 4, 4, 4, 0, 8, 0, 8, 8, 0, 8, 0, 4 ) 0/autotile/icon_coordinate = Vector2( 0, 0 ) 0/autotile/tile_size = Vector2( 8, 8 ) 0/autotile/spacing = 0 -0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 27 ), Vector2( 0, 1 ), SubResource( 34 ), Vector2( 0, 2 ), SubResource( 35 ), Vector2( 1, 0 ), SubResource( 26 ), Vector2( 1, 1 ), SubResource( 36 ), Vector2( 1, 2 ), SubResource( 37 ), Vector2( 2, 0 ), SubResource( 28 ), Vector2( 2, 1 ), SubResource( 29 ), Vector2( 2, 2 ), SubResource( 30 ), Vector2( 3, 0 ), SubResource( 31 ), Vector2( 3, 1 ), SubResource( 32 ), Vector2( 3, 2 ), SubResource( 33 ), Vector2( 4, 0 ), SubResource( 38 ), Vector2( 4, 1 ), SubResource( 39 ), Vector2( 4, 2 ), SubResource( 40 ), Vector2( 5, 0 ), SubResource( 41 ), Vector2( 5, 1 ), SubResource( 42 ), Vector2( 5, 2 ), SubResource( 43 ), Vector2( 6, 1 ), SubResource( 44 ), Vector2( 6, 2 ), SubResource( 45 ), Vector2( 7, 1 ), SubResource( 46 ), Vector2( 7, 2 ), SubResource( 47 ) ] +0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 1 ), Vector2( 0, 1 ), SubResource( 2 ), Vector2( 0, 2 ), SubResource( 3 ), Vector2( 1, 0 ), SubResource( 4 ), Vector2( 1, 1 ), SubResource( 5 ), Vector2( 1, 2 ), SubResource( 6 ), Vector2( 2, 0 ), SubResource( 7 ), Vector2( 2, 1 ), SubResource( 8 ), Vector2( 2, 2 ), SubResource( 9 ), Vector2( 3, 0 ), SubResource( 10 ), Vector2( 3, 1 ), SubResource( 11 ), Vector2( 3, 2 ), SubResource( 12 ), Vector2( 4, 0 ), SubResource( 13 ), Vector2( 4, 1 ), SubResource( 14 ), Vector2( 4, 2 ), SubResource( 15 ), Vector2( 5, 0 ), SubResource( 16 ), Vector2( 5, 1 ), SubResource( 17 ), Vector2( 5, 2 ), SubResource( 18 ), Vector2( 6, 1 ), SubResource( 19 ), Vector2( 6, 2 ), SubResource( 20 ), Vector2( 7, 1 ), SubResource( 21 ), Vector2( 7, 2 ), SubResource( 22 ) ] 0/autotile/navpoly_map = [ ] 0/autotile/priority_map = [ ] 0/autotile/z_index_map = [ ] @@ -156,140 +156,140 @@ points = PoolVector2Array( 4, 4, 4, 0, 8, 0, 8, 8, 0, 8, 0, 4 ) 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( 1 ) +0/shape = SubResource( 23 ) 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( 1 ), +"shape": SubResource( 23 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 1, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 2 ), +"shape": SubResource( 24 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 2, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 3 ), +"shape": SubResource( 25 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 3, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 4 ), +"shape": SubResource( 26 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 2, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 5 ), +"shape": SubResource( 27 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 0, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 6 ), +"shape": SubResource( 28 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 7 ), +"shape": SubResource( 29 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 0, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 8 ), +"shape": SubResource( 30 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 2, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 9 ), +"shape": SubResource( 31 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 3, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 10 ), +"shape": SubResource( 32 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 1, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 11 ), +"shape": SubResource( 33 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 1, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 12 ), +"shape": SubResource( 34 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 3, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 13 ), +"shape": SubResource( 35 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 14 ), +"shape": SubResource( 36 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 15 ), +"shape": SubResource( 37 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 16 ), +"shape": SubResource( 38 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 6, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 17 ), +"shape": SubResource( 39 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 7, 1 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 18 ), +"shape": SubResource( 40 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 6, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 19 ), +"shape": SubResource( 41 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 7, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 20 ), +"shape": SubResource( 42 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 21 ), +"shape": SubResource( 43 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 2 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 22 ), +"shape": SubResource( 44 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) } ] 0/z_index = 0 @@ -300,7 +300,7 @@ script = ExtResource( 4 ) [node name="YSort" type="YSort" parent="."] [node name="TileMap" type="TileMap" parent="YSort"] -tile_set = SubResource( 23 ) +tile_set = SubResource( 45 ) cell_size = Vector2( 8, 8 ) cell_tile_origin = 2 cell_y_sort = true -- cgit v1.3