Skip to content

Commit

Permalink
Ported 3D framework to GD4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Mar 6, 2023
1 parent 9ff4658 commit b99d9f7
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 311 deletions.
113 changes: 58 additions & 55 deletions addons/PACgd/Cole/Cole.tscn
Original file line number Diff line number Diff line change
@@ -1,108 +1,111 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=3 uid="uid://dxsvfhhmhdlxf"]

[ext_resource path="res://addons/PACgd/Cole/Cole.gd" type="Script" id=1]
[ext_resource path="res://addons/PACgd/Cole/spritesheet.png" type="Texture" id=2]
[ext_resource path="res://addons/PACgd/Cole/Talk Bubble.gd" type="Script" id=3]
[ext_resource type="Script" path="res://addons/PACgd/Cole/Cole.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://d17q42dswug3b" path="res://addons/PACgd/Cole/spritesheet.png" id="2"]
[ext_resource type="Script" path="res://addons/PACgd/Cole/Talk Bubble.gd" id="3"]

[sub_resource type="Animation" id=1]
[sub_resource type="Animation" id="1"]
length = 0.1
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/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ 8 ]
"values": [8]
}

[sub_resource type="Animation" id=2]
[sub_resource type="Animation" id="2"]
resource_name = "lower_hand"
length = 0.375
step = 0.125
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/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.125, 0.25 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"times": PackedFloat32Array(0, 0.125, 0.25),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [ 10, 9, 8 ]
"values": [10, 9, 8]
}

[sub_resource type="Animation" id=3]
[sub_resource type="Animation" id="3"]
resource_name = "raise_hand"
length = 0.25
step = 0.125
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/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.125, 0.25 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"times": PackedFloat32Array(0, 0.125, 0.25),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [ 9, 10, 11 ]
"values": [9, 10, 11]
}

[sub_resource type="Animation" id=4]
loop = true
[sub_resource type="Animation" id="4"]
loop_mode = 1
step = 0.125
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/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1 ),
"times": PackedFloat32Array(0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1),
"update": 1,
"values": [ 0, 1, 2, 3, 4, 5, 6, 7 ]
"values": [0, 1, 2, 3, 4, 5, 6, 7]
}

[sub_resource type="BoxShape" id=5]
extents = Vector3( 1.08514, 4.33591, 0.0757634 )
[sub_resource type="AnimationLibrary" id="AnimationLibrary_01cuq"]
_data = {
"idle": SubResource("1"),
"lower_hand": SubResource("2"),
"raise_hand": SubResource("3"),
"walk": SubResource("4")
}

[node name="Cole" type="KinematicBody"]
[sub_resource type="BoxShape3D" id="5"]
size = Vector3(1.08514, 4.33591, 0.0757634)

[node name="Cole" type="CharacterBody3D"]
input_ray_pickable = false
script = ExtResource( 1 )
script = ExtResource("1")

[node name="Animations" type="AnimationPlayer" parent="."]
autoplay = "idle"
anims/idle = SubResource( 1 )
anims/lower_hand = SubResource( 2 )
anims/raise_hand = SubResource( 3 )
anims/walk = SubResource( 4 )
libraries = {
"": SubResource("AnimationLibrary_01cuq")
}

[node name="Sprite" type="Sprite3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.43683, 0 )
use_in_baked_light = true
texture = ExtResource( 2 )
[node name="Sprite2D" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.43683, 0)
alpha_cut = 2
texture = ExtResource("2")
hframes = 8
vframes = 2
frame = 8

[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.41086, 0 )
shape = SubResource( 5 )
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.41086, 0)
shape = SubResource("5")

[node name="TalkBubble" type="RichTextLabel" parent="."]
visible = false
clip_contents = false
grow_horizontal = 2
rect_clip_content = false
bbcode_enabled = true
tab_size = 0
scroll_active = false
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
tab_size = 0
script = ExtResource("3")
38 changes: 19 additions & 19 deletions addons/PACgd/Cole/Cole2D.tscn
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[gd_scene load_steps=9 format=2]

[ext_resource path="res://addons/PACgd/Cole/spritesheet.png" type="Texture" id=1]
[ext_resource path="res://addons/PACgd/Cole/spritesheet.png" type="Texture2D" id=1]
[ext_resource path="res://addons/PACgd/Cole/Cole2D.gd" type="Script" id=2]
[ext_resource path="res://addons/PACgd/Cole/Talk Bubble.gd" type="Script" id=3]

[sub_resource type="Animation" id=1]
length = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/path = NodePath("Sprite2D: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 ),
"times": PackedFloat32Array( 0 ),
"transitions": PackedFloat32Array( 1 ),
"update": 1,
"values": [ 8 ]
}
Expand All @@ -24,14 +24,14 @@ resource_name = "lower_hand"
length = 0.375
step = 0.125
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/path = NodePath("Sprite2D: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.125, 0.25 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"times": PackedFloat32Array( 0, 0.125, 0.25 ),
"transitions": PackedFloat32Array( 1, 1, 1 ),
"update": 1,
"values": [ 10, 9, 8 ]
}
Expand All @@ -41,14 +41,14 @@ resource_name = "raise_hand"
length = 0.25
step = 0.125
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/path = NodePath("Sprite2D: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.125, 0.25 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"times": PackedFloat32Array( 0, 0.125, 0.25 ),
"transitions": PackedFloat32Array( 1, 1, 1 ),
"update": 1,
"values": [ 9, 10, 11 ]
}
Expand All @@ -57,22 +57,22 @@ tracks/0/keys = {
loop = true
step = 0.125
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/path = NodePath("Sprite2D: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.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1 ),
"times": PackedFloat32Array( 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 ),
"transitions": PackedFloat32Array( 1, 1, 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 4, 5, 6, 7 ]
}

[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 33.5, 132 )
size = Vector2( 33.5, 132 )

[node name="Cole2D" type="KinematicBody2D"]
[node name="Cole2D" type="CharacterBody2D"]
script = ExtResource( 2 )

[node name="Animations" type="AnimationPlayer" parent="."]
Expand All @@ -86,7 +86,7 @@ anims/walk = SubResource( 4 )
position = Vector2( 3.5, -133 )
shape = SubResource( 5 )

[node name="Sprite" type="Sprite" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2( 0.3, 0.3 )
texture = ExtResource( 1 )
offset = Vector2( 0, -450 )
Expand All @@ -95,9 +95,9 @@ vframes = 2
frame = 8

[node name="TalkBubble" type="RichTextLabel" parent="."]
margin_top = -284.0
margin_bottom = -284.0
rect_clip_content = false
offset_top = -284.0
offset_bottom = -284.0
clip_contents = false
tab_size = 0
scroll_active = false
script = ExtResource( 3 )
Expand Down
15 changes: 8 additions & 7 deletions addons/PACgd/Cole/Talk Bubble.gd
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
extends RichTextLabel

onready var cole = $".."
@onready var cole = $".."

func set_text(text: String):
self.rect_size.x = self.get_font("font").get_string_size(text).x
self.rect_size.y = self.get_font("font").get_string_size(text).y

if cole is KinematicBody2D:
self.rect_position.x = -self.rect_size.x / 2
self.size.x = self.get_theme_font("normal_font").get_string_size(text).x
self.size.y = self.get_theme_font("normal_font").get_string_size(text).y

if cole is CharacterBody2D:
self.position.x = -self.size.x / 2
else:
self.rect_position = cole.camera.unproject_position(
self.position = cole.camera.unproject_position(
cole.transform.origin + cole.talk_bubble_offset
) - Vector2(self.rect_size.x / 2, 0)
) - Vector2(self.size.x / 2, 0)

self.text = text
Loading

0 comments on commit b99d9f7

Please sign in to comment.