Compare commits

...

3 Commits

Author SHA1 Message Date
f31a6ee0c2
center camera on load 2024-02-26 13:09:17 -05:00
fe0d76e370
add scrolling bg + fix tile data 2024-02-26 13:08:29 -05:00
beabc319e5
Rename Player to Unit 2024-02-26 13:06:12 -05:00
14 changed files with 227 additions and 56 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
export_presets.cfg
/AuthKey_VSYTQ75GZQ.p8
*.dds

View File

@ -34,7 +34,8 @@ enum TileID {
TileUnknown = 30,
TileCoopBoss = 31,
TileDamage = 32,
TileDamagex2 = 33
TileDamagex2 = 33,
TileMud = 34
}
static func get_tile_texture(id: int):
@ -61,10 +62,11 @@ static func get_tile_texture(id: int):
24: return "mass_warpmoveL2.dat"
25: return "mass_snow0.dat"
26: return "mass_snow0.dat"
27: return "mass_heal0.dat"
27: return "mass_heal.dat"
28: return "mass_healL2.dat"
29: return "mass_common0.dat"
30: return "mass_common0.dat"
31: return "mass_boss.dat"
32: return "mass_damage.dat"
32: return "mass_damage0.dat"
33: return "mass_damageL2.dat"
34: return "mass_mud.dat"

View File

@ -13,8 +13,9 @@ func _init():
# Called when the node enters the scene tree for the first time.
func _ready():
$BGSprite.texture = PakAssetLoader.load_file("user://data/fields.pak/practice_l.dat")
homes = tiles.filter(is_home)
$Player.position = homes[0].position
$Unit.position = homes[0].position
next_home = homes[1].position
homes = [homes[0], homes[1], homes[3], homes[2]]
pass
@ -25,8 +26,9 @@ func is_home(tile):
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if $Player.position != next_home:
$Player.position = $Player.position.move_toward(next_home, 4)
var move_speed = delta * 60.0
if $Unit.position != next_home:
$Unit.position = $Unit.position.move_toward(next_home, move_speed * 8)
else:
x += 1
next_home = homes[x % 4].position
@ -43,11 +45,9 @@ func create_from_buffer(bytes: PackedByteArray):
for i in range(0, num_tiles):
var tile = load("res://Field/tile.tscn").instantiate()
tile.id = bytes.decode_u32(i * 8)
var exit_bits = bytes.decode_u8((i * 8) + 4)
# var exit_bits = bytes.decode_u8((i * 8) + 4)
add_child.call_deferred(tile)
tile.position = Vector2(((i % width) * 158) + 64, (j * 158) + 64)
tiles.append(tile)
if i % height == height - 1:
j += 1
#print(bytes)
pass

View File

@ -1,9 +1,23 @@
[gd_scene load_steps=3 format=3 uid="uid://qipfodwbk1gf"]
[gd_scene load_steps=5 format=3 uid="uid://qipfodwbk1gf"]
[ext_resource type="Script" path="res://Field/field.gd" id="1_6uvjw"]
[ext_resource type="PackedScene" uid="uid://dtm0201qhcn4d" path="res://Player/player.tscn" id="2_oi7aa"]
[ext_resource type="PackedScene" uid="uid://dtm0201qhcn4d" path="res://Unit/unit.tscn" id="2_jhvjp"]
[ext_resource type="Shader" path="res://PanningCamera/background.gdshader" id="3_l3ah4"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_jb3sl"]
shader = ExtResource("3_l3ah4")
[node name="Field" type="Node2D"]
script = ExtResource("1_6uvjw")
metadata/_edit_group_ = true
[node name="Player" parent="." instance=ExtResource("2_oi7aa")]
[node name="BGSprite" type="Sprite2D" parent="."]
texture_repeat = 2
material = SubResource("ShaderMaterial_jb3sl")
position = Vector2(900, 900)
scale = Vector2(2, 2)
offset = Vector2(2.08165e-12, 2.08165e-12)
region_enabled = true
region_rect = Rect2(2.08165e-12, -704, 6000, 6000)
[node name="Unit" parent="." instance=ExtResource("2_jhvjp")]

View File

@ -22,5 +22,5 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(_delta):
pass

View File

@ -1,5 +1,4 @@
extends Camera2D
class_name PanningCamera2D
@export var MIN_ZOOM: float = 0.5
@export var MAX_ZOOM: float = 3.0

View File

@ -0,0 +1,14 @@
shader_type canvas_item;
const float y_speed = 0.5 / 3.0;
const float x_speed = 0.1 / 3.0;
void fragment() {
vec2 new_uv = vec2(UV.x + TIME * x_speed, UV.y + TIME * y_speed);
COLOR = texture(TEXTURE, new_uv);
}
//void light() {
// Called for every pixel for every light affecting the CanvasItem.
// Uncomment to replace the default light processing function with this one.
//}

View File

@ -1,24 +0,0 @@
extends Node2D
var yvel = 1
var yoff = 0
# Called when the node enters the scene tree for the first time.
func _ready():
$Sprite2D.texture = PakAssetLoader.load_file("user://data/units.pak/tomomo_00_00.dat")
$Sprite2D.position = get_global_transform().origin
$Sprite2D.position.y -= 128
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
var pos = get_global_transform().origin
pos.y += -128 + yoff
yvel -= 1
if yvel < -9:
yvel = 9
pos.y += yvel
yoff += yvel
$Sprite2D.position = pos

View File

@ -1,13 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://dtm0201qhcn4d"]
[ext_resource type="Script" path="res://Player/player.gd" id="1_6ggpr"]
[node name="Player" type="Node2D"]
z_index = 1
script = ExtResource("1_6ggpr")
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
top_level = true
z_index = 2
position = Vector2(2.08165e-12, -128)

21
Unit/unit.gd Normal file
View File

@ -0,0 +1,21 @@
extends Node2D
var yvel = 1
var yoff = 0
# Called when the node enters the scene tree for the first time.
func _ready():
$UnitSprite.texture = PakAssetLoader.load_file("user://data/units.pak/tomomo_00_00.dat")
$UnitSprite.position = get_parent().to_global(position)
$UnitSprite/AnimationPlayer.play("move")
$UnitSprite/AnimationPlayer.speed_scale = 1
$RingSprite.texture = PakAssetLoader.load_file("user://data/system.pak/playerring1.dat")
$RingSprite/AnimationPlayer.play("spin")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
$UnitSprite.position = get_parent().to_global(position)
pass

134
Unit/unit.tscn Normal file
View File

@ -0,0 +1,134 @@
[gd_scene load_steps=9 format=3 uid="uid://dtm0201qhcn4d"]
[ext_resource type="Script" path="res://Unit/unit.gd" id="1_6ggpr"]
[sub_resource type="Animation" id="Animation_ijbbj"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_wu12n"]
resource_name = "spin"
length = 7.00001
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = false
tracks/0/keys = {
"times": PackedFloat32Array(0, 7),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 6.28319]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fvvof"]
_data = {
"RESET": SubResource("Animation_ijbbj"),
"spin": SubResource("Animation_wu12n")
}
[sub_resource type="Animation" id="Animation_nsm8w"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:offset")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(2.08165e-12, -128)]
}
[sub_resource type="Animation" id="Animation_yme65"]
resource_name = "idle"
length = 1.2
loop_mode = 2
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1.2),
"transitions": PackedFloat32Array(-2, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(1.05, 0.97)]
}
[sub_resource type="Animation" id="Animation_mqx3b"]
resource_name = "move"
length = 0.116668
loop_mode = 2
step = 0.0166667
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:offset")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.116667),
"transitions": PackedFloat32Array(0.435275, 1),
"update": 0,
"values": [Vector2(2.08165e-12, -128), Vector2(2.08165e-12, -158)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8dthf"]
_data = {
"RESET": SubResource("Animation_nsm8w"),
"idle": SubResource("Animation_yme65"),
"move": SubResource("Animation_mqx3b")
}
[node name="Unit" type="Node2D"]
z_index = 1
script = ExtResource("1_6ggpr")
metadata/_edit_group_ = true
[node name="RingSprite" type="Sprite2D" parent="."]
flip_v = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="RingSprite"]
libraries = {
"": SubResource("AnimationLibrary_fvvof")
}
[node name="UnitSprite" type="Sprite2D" parent="."]
top_level = true
z_index = 2
offset = Vector2(2.08165e-12, -128)
flip_h = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="UnitSprite"]
libraries = {
"": SubResource("AnimationLibrary_8dthf")
}

12
main.gd Normal file
View File

@ -0,0 +1,12 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready():
var center = $Field.to_global($Field.tiles[$Field.tiles.size() / 2].position)
$Camera2D.position = center
$Camera2D.reset_pos = center
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass

View File

@ -1,14 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://djirenq1psstj"]
[gd_scene load_steps=4 format=3 uid="uid://djirenq1psstj"]
[ext_resource type="Script" path="res://main.gd" id="1_2dcib"]
[ext_resource type="Script" path="res://PanningCamera/PanningCamera2D.gd" id="1_vtapg"]
[ext_resource type="PackedScene" uid="uid://qipfodwbk1gf" path="res://Field/field.tscn" id="1_y0qkv"]
[node name="Main" type="Node2D"]
script = ExtResource("1_2dcib")
metadata/_edit_group_ = true
[node name="Camera2D" type="Camera2D" parent="."]
limit_left = -5000
limit_top = -2000
limit_right = 5000
limit_bottom = 4000
editor_draw_limits = true
script = ExtResource("1_vtapg")
MIN_ZOOM = null
MAX_ZOOM = null
ZOOM_RATE = 5.0
[node name="Field" parent="." instance=ExtResource("1_y0qkv")]

View File

@ -15,13 +15,18 @@ run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"
[debug]
gdscript/warnings/integer_division=0
[display]
window/size/viewport_width=1920
window/size/viewport_height=1080
window/vsync/vsync_mode=0
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method="mobile"
renderer/rendering_method.mobile="gl_compatibility"
textures/vram_compression/import_etc2_astc=true