add scrolling bg + fix tile data

This commit is contained in:
Candygoblen123 2024-02-26 13:07:49 -05:00
parent beabc319e5
commit fe0d76e370
No known key found for this signature in database
GPG Key ID: 577DA64EBEF10385
5 changed files with 39 additions and 10 deletions

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"
33: return "mass_damageL2.dat"
32: return "mass_damage0.dat"
33: return "mass_damageL2.dat"
34: return "mass_mud.dat"

View File

@ -13,6 +13,7 @@ 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)
$Unit.position = homes[0].position
next_home = homes[1].position
@ -44,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="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

@ -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.
//}