mirror of
https://github.com/tonytins/dressupzack
synced 2025-05-05 13:34:48 -04:00
Cleaned up code base
- Moved character variables and News API address to global GameData class
This commit is contained in:
parent
ec79a57f96
commit
e90a500858
18 changed files with 153 additions and 168 deletions
|
@ -1,6 +1,3 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/character.gd" type="Script" id=1]
|
||||
[gd_resource type="Resource" format=2]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
[ext_resource path="res://sprites/clothes/blank_top.png" type="Texture" id=26]
|
||||
[ext_resource path="res://sprites/character/character_base_head.svg" type="Texture" id=27]
|
||||
[ext_resource path="res://sprites/character/mouth/mouth11.png" type="Texture" id=28]
|
||||
[ext_resource path="res://scripts/character_base.gd" type="Script" id=29]
|
||||
[ext_resource path="res://scripts/character.gd" type="Script" id=29]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
|
@ -54,7 +54,7 @@ animations = [ {
|
|||
"speed": 2.0
|
||||
} ]
|
||||
|
||||
[node name="CharacterBase" type="Node2D"]
|
||||
[node name="Character" type="Node2D"]
|
||||
position = Vector2( -19, -92 )
|
||||
script = ExtResource( 29 )
|
||||
|
||||
|
@ -92,7 +92,7 @@ texture = ExtResource( 27 )
|
|||
[node name="Eyes" type="AnimatedSprite" parent="Body/Head"]
|
||||
position = Vector2( 17.6857, 4.22147 )
|
||||
frames = SubResource( 2 )
|
||||
frame = 2
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="Mouth" type="AnimatedSprite" parent="Body/Head"]
|
|
@ -5,7 +5,6 @@
|
|||
[ext_resource path="res://scripts/news_window.gd" type="Script" id=3]
|
||||
|
||||
[node name="NewsWin" type="WindowDialog"]
|
||||
visible = true
|
||||
anchor_left = 0.15375
|
||||
anchor_top = 0.144
|
||||
anchor_right = 0.84625
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
[ext_resource path="res://scenes/clothing/base/clothing_base.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scripts/clothing/tops_base.gd" type="Script" id=2]
|
||||
|
||||
|
||||
|
||||
[node name="topsBase" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[connection signal="pressed" from="." to="." method="_on_tops_pressed"]
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
[ext_resource path="res://scenes/clothing/base/accessory_base.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://sprites/clothes/camera.png" type="Texture" id=2]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[node name="camera" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
|
|
|
@ -1,45 +1,43 @@
|
|||
[gd_scene load_steps=18 format=2]
|
||||
[gd_scene load_steps=17 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/CharacterBase.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/Character.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://sprites/world/background.svg" type="Texture" id=2]
|
||||
[ext_resource path="res://sprites/symbols/trash.svg" type="Texture" id=3]
|
||||
[ext_resource path="res://scenes/wardrobe.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://sprites/clothes/icrazy_frame.svg" type="Texture" id=5]
|
||||
[ext_resource path="res://sprites/clothes/lights.png" type="Texture" id=6]
|
||||
[ext_resource path="res://sprites/symbols/file-upload.svg" type="Texture" id=7]
|
||||
[ext_resource path="res://scripts/ui.gd" type="Script" id=8]
|
||||
[ext_resource path="res://scripts/interface.gd" type="Script" id=8]
|
||||
[ext_resource path="res://sprites/symbols/file-download.svg" type="Texture" id=9]
|
||||
[ext_resource path="res://sprites/symbols/file-upload-disabled.svg" type="Texture" id=10]
|
||||
[ext_resource path="res://sprites/symbols/file-download-disabled.svg" type="Texture" id=11]
|
||||
[ext_resource path="res://sprites/symbols/spinner.svg" type="Texture" id=12]
|
||||
[ext_resource path="res://scripts/spinner.gd" type="Script" id=13]
|
||||
[ext_resource path="res://scripts/game.gd" type="Script" id=14]
|
||||
[ext_resource path="res://sprites/symbols/newspaper.svg" type="Texture" id=15]
|
||||
[ext_resource path="res://scenes/NewsWin.tscn" type="PackedScene" id=16]
|
||||
[ext_resource path="res://sprites/symbols/newspaper-disabled.svg" type="Texture" id=17]
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 14 )
|
||||
[node name="Game" type="Node2D"]
|
||||
|
||||
[node name="Bg" type="Sprite" parent="."]
|
||||
[node name="Background" type="Sprite" parent="."]
|
||||
position = Vector2( 504.046, 202.426 )
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="picFrame" type="Sprite" parent="."]
|
||||
[node name="PictureFrame" type="Sprite" parent="."]
|
||||
position = Vector2( 127.602, 111.895 )
|
||||
texture = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="light" type="Light2D" parent="picFrame"]
|
||||
[node name="Light" type="Light2D" parent="PictureFrame"]
|
||||
position = Vector2( 35.118, -14.56 )
|
||||
texture = ExtResource( 6 )
|
||||
|
||||
[node name="characterBase" parent="." instance=ExtResource( 1 )]
|
||||
[node name="Character" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 141.307, 225.012 )
|
||||
|
||||
[node name="Controls" type="CanvasLayer" parent="."]
|
||||
|
@ -130,7 +128,7 @@ margin_bottom = 32.0
|
|||
hint_tooltip = "Clear"
|
||||
texture_normal = ExtResource( 3 )
|
||||
|
||||
[node name="versionLbl" type="Label" parent="Controls/Container"]
|
||||
[node name="VersionLbl" type="Label" parent="Controls/Container"]
|
||||
anchor_left = 0.88125
|
||||
anchor_top = 0.944
|
||||
anchor_right = 0.9825
|
||||
|
@ -147,6 +145,6 @@ visible = false
|
|||
|
||||
[connection signal="timeout" from="Controls/Container/Spinner/Timer" to="Controls/Container/Spinner" method="_on_Timer_timeout"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/NewsBtn" to="Controls/Container" method="_on_NewsBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ExportBtn" to="characterBase" method="_on_SaveBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ImportBtn" to="characterBase" method="_on_LoadBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ClearBtn" to="characterBase" method="_on_clearBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ExportBtn" to="Character" method="_on_SaveBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ImportBtn" to="Character" method="_on_LoadBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ClearBtn" to="Character" method="_on_clearBtn_pressed"]
|
||||
|
|
|
@ -108,10 +108,10 @@ margin_bottom = 258.0
|
|||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 38.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
margin_left = 5.0
|
||||
margin_top = 40.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -10.0
|
||||
|
||||
[node name="ShirtsScroll" type="ScrollContainer" parent="Shirts"]
|
||||
anchor_right = 1.0
|
||||
|
@ -120,8 +120,8 @@ margin_left = 10.0
|
|||
margin_top = 10.0
|
||||
|
||||
[node name="ShirtsGrid" type="GridContainer" parent="Shirts/ShirtsScroll"]
|
||||
margin_right = 782.0
|
||||
margin_bottom = 448.0
|
||||
margin_right = 780.0
|
||||
margin_bottom = 440.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 4
|
||||
|
@ -181,10 +181,10 @@ texture_normal = ExtResource( 2 )
|
|||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 38.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
margin_left = 5.0
|
||||
margin_top = 40.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -10.0
|
||||
|
||||
[node name="AccsScroll" type="ScrollContainer" parent="Accessoires"]
|
||||
anchor_right = 1.0
|
||||
|
@ -194,8 +194,8 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="AccsGrid" type="GridContainer" parent="Accessoires/AccsScroll"]
|
||||
margin_right = 792.0
|
||||
margin_bottom = 458.0
|
||||
margin_right = 790.0
|
||||
margin_bottom = 450.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
|
|
|
@ -1,8 +1,108 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Resource
|
||||
extends Node2D
|
||||
|
||||
var top = null
|
||||
var bottom = null
|
||||
var underwear = null
|
||||
var accessory = null
|
||||
const _TDU_VERSION = "0.2"
|
||||
const _SAVE_FILE = "user://character.tdu"
|
||||
|
||||
onready var blank_accessory = preload("res://sprites/clothes/blank_top.png")
|
||||
onready var base_top = preload("res://sprites/character/character_base_top.svg")
|
||||
onready var base_bottom = preload("res://sprites/character/character_base_legs.svg")
|
||||
|
||||
onready var export_win = $Controls/Container/ExportWin
|
||||
onready var import_win = $Controls/Container/ImportWin
|
||||
|
||||
onready var accessory = $Body/Accessory
|
||||
#onready var underwear = $Undies
|
||||
onready var bottom = $Body/Legs
|
||||
onready var top = $Body/Top
|
||||
# onready var eyes = $Body/Head/Eyes
|
||||
# onready var mouth = $Body/Head/Mouth
|
||||
|
||||
func _process(delta):
|
||||
|
||||
if GameData.accessory != null:
|
||||
accessory.texture = GameData.accessory
|
||||
|
||||
# if GameData.underwear != null:
|
||||
# underwear.texture = GameData.underwear
|
||||
|
||||
if GameData.bottom != null:
|
||||
bottom.texture = GameData.bottom
|
||||
|
||||
if GameData.top != null:
|
||||
top.texture = GameData.top
|
||||
|
||||
func save_game():
|
||||
var data_file = {
|
||||
"version": _TDU_VERSION,
|
||||
"game_ver": GameData.version,
|
||||
"accessory": "res://sprites/clothes/blank_top.png",
|
||||
"top": "res://sprites/clothes/blank_top.png",
|
||||
"bottom": "res://sprites/character/character_base_legs.svg",
|
||||
}
|
||||
|
||||
data_file["accessory"] = accessory.texture.resource_path
|
||||
data_file["top"] = top.texture.resource_path
|
||||
data_file["bottom"] = bottom.texture.resource_path
|
||||
|
||||
var file = File.new()
|
||||
if file.open(_SAVE_FILE, File.WRITE) != 0:
|
||||
print("Error opening file")
|
||||
return
|
||||
var json_file = to_json(data_file)
|
||||
|
||||
GameEvents.emit_signal("indicate")
|
||||
|
||||
file.store_line(json_file)
|
||||
file.close()
|
||||
|
||||
func load_game():
|
||||
var file = File.new()
|
||||
|
||||
if not file.file_exists(_SAVE_FILE):
|
||||
print("File not found!")
|
||||
return
|
||||
|
||||
if file.open(_SAVE_FILE, File.READ) != 0:
|
||||
print("Error opening file")
|
||||
return
|
||||
|
||||
var data = parse_json(file.get_as_text())
|
||||
|
||||
var top_texture = ImageTexture.new()
|
||||
var accessory_texture = ImageTexture.new()
|
||||
var bottom_texture = ImageTexture.new()
|
||||
var top_image = Image.new()
|
||||
var accessory_image = Image.new()
|
||||
var bottom_image = Image.new()
|
||||
|
||||
GameEvents.emit_signal("indicate")
|
||||
|
||||
top_image.load(data["top"])
|
||||
top_texture.create_from_image(top_image)
|
||||
top.texture = top_texture
|
||||
|
||||
bottom_image.load(data["bottom"])
|
||||
top_texture.create_from_image(top_image)
|
||||
bottom.texture = top_texture
|
||||
|
||||
accessory_image.load(data["accessory"])
|
||||
accessory_texture.create_from_image(top_image)
|
||||
accessory.texture = accessory_texture
|
||||
|
||||
file.close()
|
||||
|
||||
func _on_clearBtn_pressed():
|
||||
$Click.play()
|
||||
GameData.accessory = blank_accessory
|
||||
GameData.bottom = base_bottom
|
||||
GameData.top = base_top
|
||||
|
||||
func _on_SaveBtn_pressed():
|
||||
$Click.play()
|
||||
save_game()
|
||||
|
||||
func _on_LoadBtn_pressed():
|
||||
$Click.play()
|
||||
load_game()
|
||||
|
|
|
@ -3,3 +3,15 @@
|
|||
extends Node
|
||||
|
||||
var version = "0.0.0"
|
||||
|
||||
const NEWS_API = "https://static.tonybark.com/news/dressup.json"
|
||||
|
||||
var top = null
|
||||
var bottom = null
|
||||
var underwear = null
|
||||
var accessory = null
|
||||
|
||||
enum characters {
|
||||
ZACK,
|
||||
ANTHONY
|
||||
}
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Node2D
|
||||
|
||||
const _TDU_VERSION = "0.2"
|
||||
const _SAVE_FILE = "user://character.tdu"
|
||||
|
||||
onready var character = preload("res://resources/character.tres")
|
||||
onready var blank_accessory = preload("res://sprites/clothes/blank_top.png")
|
||||
onready var base_top = preload("res://sprites/character/character_base_top.svg")
|
||||
onready var base_bottom = preload("res://sprites/character/character_base_legs.svg")
|
||||
|
||||
onready var export_win = $Controls/Container/ExportWin
|
||||
onready var import_win = $Controls/Container/ImportWin
|
||||
|
||||
onready var accessory = $Body/Accessory
|
||||
#onready var underwear = $Undies
|
||||
onready var bottom = $Body/Legs
|
||||
onready var top = $Body/Top
|
||||
# onready var eyes = $Body/Head/Eyes
|
||||
# onready var mouth = $Body/Head/Mouth
|
||||
|
||||
func _process(delta):
|
||||
|
||||
if character.accessory != null:
|
||||
accessory.texture = character.accessory
|
||||
|
||||
# if character.underwear != null:
|
||||
# underwear.texture = character.underwear
|
||||
|
||||
if character.bottom != null:
|
||||
bottom.texture = character.bottom
|
||||
|
||||
if character.top != null:
|
||||
top.texture = character.top
|
||||
|
||||
func save_game():
|
||||
var data_file = {
|
||||
"version": _TDU_VERSION,
|
||||
"game_ver": GameData.version,
|
||||
"accessory": "res://sprites/clothes/blank_top.png",
|
||||
"top": "res://sprites/clothes/blank_top.png",
|
||||
"bottom": "res://sprites/character/character_base_legs.svg",
|
||||
}
|
||||
|
||||
data_file["accessory"] = accessory.texture.resource_path
|
||||
data_file["top"] = top.texture.resource_path
|
||||
data_file["bottom"] = bottom.texture.resource_path
|
||||
|
||||
var file = File.new()
|
||||
if file.open(_SAVE_FILE, File.WRITE) != 0:
|
||||
print("Error opening file")
|
||||
return
|
||||
var json_file = to_json(data_file)
|
||||
|
||||
GameEvents.emit_signal("indicate")
|
||||
|
||||
file.store_line(json_file)
|
||||
file.close()
|
||||
|
||||
func load_game():
|
||||
var file = File.new()
|
||||
|
||||
if not file.file_exists(_SAVE_FILE):
|
||||
print("File not found!")
|
||||
return
|
||||
|
||||
if file.open(_SAVE_FILE, File.READ) != 0:
|
||||
print("Error opening file")
|
||||
return
|
||||
|
||||
var data = parse_json(file.get_as_text())
|
||||
|
||||
var top_texture = ImageTexture.new()
|
||||
var accessory_texture = ImageTexture.new()
|
||||
var bottom_texture = ImageTexture.new()
|
||||
var top_image = Image.new()
|
||||
var accessory_image = Image.new()
|
||||
var bottom_image = Image.new()
|
||||
|
||||
GameEvents.emit_signal("indicate")
|
||||
|
||||
top_image.load(data["top"])
|
||||
top_texture.create_from_image(top_image)
|
||||
top.texture = top_texture
|
||||
|
||||
bottom_image.load(data["bottom"])
|
||||
top_texture.create_from_image(top_image)
|
||||
bottom.texture = top_texture
|
||||
|
||||
accessory_image.load(data["accessory"])
|
||||
accessory_texture.create_from_image(top_image)
|
||||
accessory.texture = accessory_texture
|
||||
|
||||
file.close()
|
||||
|
||||
func _on_clearBtn_pressed():
|
||||
$Click.play()
|
||||
character.accessory = blank_accessory
|
||||
character.bottom = base_bottom
|
||||
character.top = base_top
|
||||
|
||||
func _on_SaveBtn_pressed():
|
||||
$Click.play()
|
||||
save_game()
|
||||
|
||||
func _on_LoadBtn_pressed():
|
||||
$Click.play()
|
||||
load_game()
|
|
@ -3,5 +3,5 @@
|
|||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_accessory_pressed():
|
||||
character.accessory = texture_normal
|
||||
GameData.accessory = texture_normal
|
||||
$select.play()
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_bottoms_pressed():
|
||||
character.bottom = texture_normal
|
||||
GameData.bottom = texture_normal
|
||||
$select.play()
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_tops_pressed():
|
||||
character.top = texture_normal
|
||||
GameData.top = texture_normal
|
||||
$select.play()
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_undies_pressed():
|
||||
character.underwear = texture_normal
|
||||
GameData.underwear = texture_normal
|
||||
$select.play()
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Node2D
|
|
@ -2,8 +2,6 @@
|
|||
# See the LICENSE file in the project root for more information.
|
||||
extends Control
|
||||
|
||||
const _NEWS_API = "https://static.tonybark.com/news/dressup.json"
|
||||
|
||||
export var version: String = "1.0.0"
|
||||
|
||||
onready var character = preload("res://resources/character.tres")
|
||||
|
@ -18,11 +16,11 @@ onready var news_btn = $CenterBtns/ButtonCtr/NewsBtn
|
|||
onready var http_request = $NewsWin/NewsBtns/HTTPRequest
|
||||
|
||||
func _ready():
|
||||
var verLabel = $versionLbl
|
||||
var verLabel = $VersionLbl
|
||||
verLabel.text = "v" + version
|
||||
GameData.version = version
|
||||
|
||||
var err = http_request.request(_NEWS_API)
|
||||
var err = http_request.request(GameData.NEWS_API)
|
||||
|
||||
if err != OK:
|
||||
news_btn.disabled = true
|
|
@ -1,7 +1,5 @@
|
|||
extends WindowDialog
|
||||
|
||||
const _NEWS_API = "https://static.tonybark.com/news/dressup.json"
|
||||
|
||||
onready var news_list = $News
|
||||
onready var http_request = $NewsBtns/HTTPRequest
|
||||
|
||||
|
@ -16,4 +14,4 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
|
||||
func _on_SyncBtn_pressed():
|
||||
news_list.clear()
|
||||
http_request.request(_NEWS_API)
|
||||
http_request.request(GameData.NEWS_API)
|
||||
|
|
BIN
sprites/character.blend
Normal file
BIN
sprites/character.blend
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue