From 005152a8c34f20c099a4cf0460ff74fbde83d46f Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Fri, 28 Jul 2023 00:17:03 +0930 Subject: [PATCH] Move battle sprites to new test scene --- Node2D.gd | 23 ----------------------- Node2D.tscn | 15 +++------------ test/battle_sprites.gd | 25 +++++++++++++++++++++++++ test/battle_sprites.tscn | 19 +++++++++++++++++++ 4 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 test/battle_sprites.gd create mode 100644 test/battle_sprites.tscn diff --git a/Node2D.gd b/Node2D.gd index c120ca2..f6cd73f 100644 --- a/Node2D.gd +++ b/Node2D.gd @@ -1,27 +1,4 @@ extends Node2D -var PC = load('PC.tscn') -var PCs = [] - func _ready(): Engine.set_target_fps(60) - var strips = len(SpriteLoader.strip_textures) # * 4 / 5 - #var strip_divide = strips * 2 / 5 - var strip_divide = strips * 1 / 5 - for i in strips: - PCs.append(PC.instance()) - #PCs[-1].set_position(Vector2((i%strip_divide)*16, (i/strip_divide)*24*11)) - PCs[-1].set_position(Vector2((i%strip_divide)*24, (i/strip_divide)*32)) - PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[i]) - PCs[-1].texture = SpriteLoader.strip_textures[i] - - add_child(PCs[-1]) -# PCs.append(PC.instance()) -# PCs[-1].set_position(Vector2(0, 2*24*11)) -# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45]) -# PCs[-1].texture = SpriteLoader.weapon_textures['Fist'] -# add_child(PCs[-1]) - -func _on_OptionButton_item_selected(ID): - for pc in PCs: - pc.animation = ID diff --git a/Node2D.tscn b/Node2D.tscn index 3afd3ec..96e1ff8 100644 --- a/Node2D.tscn +++ b/Node2D.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://palette_mat.tres" type="Material" id=1] [ext_resource path="res://Node2D.gd" type="Script" id=2] [ext_resource path="res://test/audio_system.tscn" type="PackedScene" id=3] [ext_resource path="res://test/worldmap_system.tscn" type="PackedScene" id=4] +[ext_resource path="res://test/battle_sprites.tscn" type="PackedScene" id=5] [node name="Control" type="Control"] anchor_right = 1.0 @@ -15,19 +16,9 @@ position = Vector2( 16, 16 ) scale = Vector2( 2, 2 ) script = ExtResource( 2 ) -[node name="OptionButton" type="OptionButton" parent="Node2D"] -anchor_bottom = 0.67 -margin_top = 180.0 -margin_right = 100.0 -margin_bottom = 170.0 -rect_scale = Vector2( 0.5, 0.5 ) -text = "Stand" -items = [ "Stand", null, false, 0, null, "Guard", null, false, 1, null, "Walk", null, false, 2, null, "Down", null, false, 3, null, "R_Swing", null, false, 4, null, "L_Swing", null, false, 5, null, "Cheer", null, false, 6, null, "Recoil", null, false, 7, null, "Chant", null, false, 8, null ] -selected = 0 - [node name="audio_system" parent="." instance=ExtResource( 3 )] position = Vector2( 0, 400 ) [node name="worldmap_system" parent="." instance=ExtResource( 4 )] -[connection signal="item_selected" from="Node2D/OptionButton" to="Node2D" method="_on_OptionButton_item_selected"] +[node name="battle_sprites" parent="." instance=ExtResource( 5 )] diff --git a/test/battle_sprites.gd b/test/battle_sprites.gd new file mode 100644 index 0000000..a65a662 --- /dev/null +++ b/test/battle_sprites.gd @@ -0,0 +1,25 @@ +extends Node2D + +var PC = load('res://PC.tscn') +var PCs = [] +func _ready() -> void: + var strips = len(SpriteLoader.strip_textures) # * 4 / 5 + #var strip_divide = strips * 2 / 5 + var strip_divide = strips * 1 / 5 + for i in strips: + PCs.append(PC.instance()) + #PCs[-1].set_position(Vector2((i%strip_divide)*16, (i/strip_divide)*24*11)) + PCs[-1].set_position(Vector2((i%strip_divide)*24, (i/strip_divide)*32)) + PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[i]) + PCs[-1].texture = SpriteLoader.strip_textures[i] + + add_child(PCs[-1]) + # PCs.append(PC.instance()) + # PCs[-1].set_position(Vector2(0, 2*24*11)) + # PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45]) + # PCs[-1].texture = SpriteLoader.weapon_textures['Fist'] + # add_child(PCs[-1]) + +func _on_OptionButton_item_selected(ID): + for pc in PCs: + pc.animation = ID diff --git a/test/battle_sprites.tscn b/test/battle_sprites.tscn new file mode 100644 index 0000000..723869a --- /dev/null +++ b/test/battle_sprites.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://test/battle_sprites.gd" type="Script" id=1] + +[node name="battle_sprites" type="Node2D"] +scale = Vector2( 2, 2 ) +script = ExtResource( 1 ) + +[node name="OptionButton" type="OptionButton" parent="."] +anchor_bottom = 0.67 +margin_top = 160.0 +margin_right = 100.0 +margin_bottom = 180.0 +rect_scale = Vector2( 0.5, 0.5 ) +text = "Stand" +items = [ "Stand", null, false, 0, null, "Guard", null, false, 1, null, "Walk", null, false, 2, null, "Down", null, false, 3, null, "R_Swing", null, false, 4, null, "L_Swing", null, false, 5, null, "Cheer", null, false, 6, null, "Recoil", null, false, 7, null, "Chant", null, false, 8, null ] +selected = 0 + +[connection signal="item_selected" from="OptionButton" to="." method="_on_OptionButton_item_selected"]