Added simple style selection. Also player's skeleton is now using a simpler setup.

This commit is contained in:
Relintai 2020-07-13 20:52:10 +02:00
parent ac75b6a45e
commit 4e78f34268
18 changed files with 327 additions and 50 deletions

View File

@ -0,0 +1,73 @@
extends CharacterSkeleton2D
# Copyright Péter Magyar relintai@gmail.com
# MIT License, functionality from this class needs to be protable to the entity spell system
# Copyright (c) 2019 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#export (NodePath) var sprite_path : NodePath = ""
var sprite : Sprite
var _facing : int = 0
var effects : Array
var _atlas : CharacterAtlas2D
enum CharacterFacing {
FACING_FRONT = 0,
FACING_BACK = 1,
FACING_RIGHT = 2,
FACING_LEFT = 3,
}
#func _ready() -> void:
# sprite = get_node(sprite_path) as Sprite
func _enter_tree():
sprite = get_node("/root/Main").get_body().instance()
add_child(sprite)
func update_facing(input_direction : Vector2) -> void:
if input_direction.x > 0.01 and _facing != CharacterFacing.FACING_RIGHT:
_facing = CharacterFacing.FACING_RIGHT
sprite.transform.x.x = -1
elif input_direction.x < -0.01 and _facing != CharacterFacing.FACING_LEFT:
_facing = CharacterFacing.FACING_LEFT
sprite.transform.x.x = 1
func add_effect(bone_id : int, effect : PackedScene) -> void:
pass
func remove_effect(bone_id : int, effect : PackedScene) -> void:
pass
func get_animation_player() -> AnimationPlayer:
return null
func get_animation_tree() -> AnimationTree:
return null
func set_character_atlas(atlas : CharacterAtlas) -> void:
_atlas = atlas as CharacterAtlas2D

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://characters/SimpleCharacter.gd" type="Script" id=1]
[node name="Character" type="CharacterSkeleton2D"]
script = ExtResource( 1 )

View File

@ -1,49 +1,8 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://characters/Character.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/item_visuals/CharacterAtlasEntry2D.gd" type="Script" id=2]
[ext_resource path="res://scripts/item_visuals/CharacterAtlas2D.gd" type="Script" id=3]
[ext_resource path="res://characters/char_t1_outline_split.png" type="Texture" id=5]
[ext_resource path="res://characters/SimpleCharacter.tscn" type="PackedScene" id=1]
[ext_resource path="res://player/Body.gd" type="Script" id=6]
[sub_resource type="CharacterAtlasEntry" id=1]
script = ExtResource( 2 )
front_rect = Rect2( 101, 15, 9, 12 )
back_rect = Rect2( 74, 18, 9, 12 )
right_rect = Rect2( 8, 13, 9, 12 )
left_rect = Rect2( 8, 13, 9, 12 )
[sub_resource type="CharacterAtlasEntry" id=2]
script = ExtResource( 2 )
front_rect = Rect2( 102, 2, 7, 8 )
back_rect = Rect2( 75, 5, 7, 8 )
right_rect = Rect2( 9, 0, 7, 8 )
left_rect = Rect2( 9, 0, 7, 8 )
[sub_resource type="CharacterAtlas" id=3]
script = ExtResource( 3 )
comments = "HUMANOID_BONE_HIP = 0,
HUMANOID_BONE_TORSO = 1,
HUMANOID_BONE_LEG_R = 2,
HUMANOID_BONE_FOOT_R = 3,
HUMANOID_BONE_TOE_R = 4,
HUMANOID_BONE_LEG_L = 5,
HUMANOID_BONE_FOOT_L = 6,
HUMANOID_BONE_TOE_L = 7,
HUMANOID_BONE_ARM_R = 8,
#HUMANOID_BONE_SHOULDER_GUARD_R = 0,
HUMANOID_BONE_HAND_R = 9,
HUMANOID_BONE_FINGERS_R = 10,
HUMANOID_BONE_ARM_L = 11,
#HUMANOID_BONE_SHOULDER_GUARD_L = 0,
HUMANOID_BONE_HAND_L = 12,
HUMANOID_BONE_FINGERS_L = 13,
HUMANOID_BONE_HEAD = 14,
HUMANOID_BONE_HEAD_TOP = 15,
HUMANOID_BONES_MAX = 16,"
texture = ExtResource( 5 )
slots = [ null, SubResource( 1 ), null, null, null, null, null, null, null, null, null, null, null, null, SubResource( 2 ), null ]
[sub_resource type="CircleShape2D" id=4]
radius = 8.0
@ -51,9 +10,6 @@ radius = 8.0
script = ExtResource( 6 )
[node name="Character" parent="." instance=ExtResource( 1 )]
front_node_path = NodePath("../../Body/Character/CharacterFrontModel")
side_node_path = NodePath("../../Body/Character/CharacterSideModel")
character_atlas = SubResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 4 )

View File

@ -186,7 +186,7 @@ func process_input(delta: float) -> void:
#handle_graphic_facing(abs(dir.dot(Vector2(0, 1))) > 0.9)
character_skeleton.update_facing(input_dir)
character_skeleton.get_animation_tree().set("parameters/walking/blend_amount", input_dir.length())
# character_skeleton.get_animation_tree().set("parameters/walking/blend_amount", input_dir.length())
func process_movement(delta : float) -> void:
@ -473,7 +473,8 @@ func on_c_controlled_changed(val):
if val:
camera = Camera2D.new()
camera.zoom = Vector2(0.6, 0.6)
# camera.zoom = Vector2(0.6, 0.6)
camera.zoom = get_node("/root/Main").get_world_scale()
add_child(camera)
camera.current = true

View File

@ -79,6 +79,11 @@ func _ready() -> void:
_active_animation_tree = _side_animation_tree
_is_front_side = false
#func _enter_tree():
# var body = get_node("/root/Main").get_body().instance()
# add_child(body)
func update_facing(input_direction : Vector2) -> void:
var front : bool = abs(input_direction.dot(Vector2(0, 1))) > 0.9

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://scenes/MainScene.gd" type="Script" id=1]
[ext_resource path="res://scenes/World.tscn" type="PackedScene" id=2]
@ -6,6 +6,14 @@
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=4]
[ext_resource path="res://ui/debug/DebugInfo.tscn" type="PackedScene" id=5]
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=6]
[ext_resource path="res://tilesets/16x16_orthogonal/16x16_orthogonal_world.tscn" type="PackedScene" id=7]
[ext_resource path="res://tilesets/rogue_dungeon/rogue_dungeon_world.tscn" type="PackedScene" id=8]
[ext_resource path="res://tilesets/denzi_public_domain/denzi_public_domain_world.tscn" type="PackedScene" id=9]
[ext_resource path="res://tilesets/dc_32x32/dc_32x32_world.tscn" type="PackedScene" id=10]
[ext_resource path="res://tilesets/rogue_lite/world_rogue_lite.tscn" type="PackedScene" id=11]
[ext_resource path="res://tilesets/denzi_32x32_orthogonal/denzi_32x32_orthogonal_world.tscn" type="PackedScene" id=12]
[ext_resource path="res://tilesets/rogue_db32/rogue_db32_world.tscn" type="PackedScene" id=13]
[ext_resource path="res://tilesets/16x16_orthogonal/player.tscn" type="PackedScene" id=14]
[node name="Main" type="Node"]
script = ExtResource( 1 )
@ -13,6 +21,9 @@ menu_scene = ExtResource( 3 )
world_scene = ExtResource( 2 )
debug_camera_scene = ExtResource( 6 )
loading_screen_path = NodePath("LoadingScreen/PanelContainer")
worlds = [ ExtResource( 7 ), ExtResource( 10 ), ExtResource( 12 ), ExtResource( 9 ), ExtResource( 13 ), ExtResource( 8 ), ExtResource( 11 ) ]
world_scales = [ Vector2( 0.5, 0.5 ), Vector2( 0.8, 0.8 ), Vector2( 0.8, 0.8 ), Vector2( 0.8, 0.8 ), Vector2( 0.8, 0.8 ), Vector2( 0.8, 0.8 ), Vector2( 0.8, 0.8 ) ]
bodies = [ ExtResource( 14 ), null, null, null, null, null, null ]
[node name="LoadingScreen" type="CanvasLayer" parent="."]
layer = 100

View File

@ -26,6 +26,10 @@ export(PackedScene) var menu_scene : PackedScene
export(PackedScene) var world_scene : PackedScene
export(PackedScene) var debug_camera_scene : PackedScene
export(NodePath) var loading_screen_path : NodePath
export(int) var curent_style : int = 0
export(Array, PackedScene) var worlds : Array
export(Array, Vector2) var world_scales : Array
export(Array, PackedScene) var bodies : Array
enum StartSceneTypes {
NONE, MENU, WORLD
@ -115,7 +119,8 @@ func switch_scene(scene : int) -> void:
current_scene = gs
elif scene == StartSceneTypes.WORLD:
var gs : Node = world_scene.instance()
# var gs : Node = world_scene.instance()
var gs : Node = get_world().instance()
add_child(gs)
gs.owner = self
@ -165,3 +170,12 @@ class ModulePathSorter:
if a.resource_path < b.resource_path:
return true
return false
func get_world():
return worlds[curent_style]
func get_world_scale():
return world_scales[curent_style]
func get_body():
return bodies[curent_style]

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://tilesets/16x16_orthogonal/16x16_retrostyle_character_paperdoll_Denzi090103-1.PNG" type="Texture" id=1]
[node name="Node2D" type="Sprite"]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 83, 1, 9, 16 )

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
[gd_resource type="TileSet" load_steps=2 format=2]
[ext_resource path="res://tilesets/denzi_32x32_orthogonal/32x32_terrain_Denzi110115-4.png" type="Texture" id=1]
[resource]
0/name = "Floor"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 64, 96, 32, 32 )
0/tile_mode = 0
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "Wall"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 64, 32, 32, 32 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "Wall2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 64, 128, 33, 32 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0

View File

@ -0,0 +1,23 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://tilesets/denzi_32x32_orthogonal/32x32_terrain_Denzi110115-4.png" type="Texture" id=1]
[node name="Node2D" type="Node2D"]
[node name="Floor" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
region_enabled = true
region_rect = Rect2( 64, 96, 32, 32 )
[node name="Wall" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
region_enabled = true
region_rect = Rect2( 64, 32, 32, 32 )
[node name="Wall2" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
region_enabled = true
region_rect = Rect2( 64, 128, 33, 32 )

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long