2023-07-27 20:25:26 +09:30
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
var pal_shader_mat := preload('res://palette_mat.tres')
|
|
|
|
var worldmap_shader_mat := preload('res://worldmap_palette_mat.tres')
|
|
|
|
|
|
|
|
var map_images := []
|
|
|
|
var map_textures := []
|
|
|
|
var map_texrects := []
|
|
|
|
|
|
|
|
func _create_palette_and_atlas_texrects() -> void:
|
|
|
|
for tileset in 3:
|
|
|
|
# Debug the Atlases
|
|
|
|
var texrect = TextureRect.new()
|
|
|
|
texrect.rect_position.x = tileset * 256 * 2
|
|
|
|
texrect.rect_scale *= 16
|
|
|
|
texrect.texture = SpriteLoader.worldmap_palette_textures[tileset]
|
|
|
|
map_texrects.append(texrect)
|
|
|
|
add_child(texrect)
|
|
|
|
texrect = TextureRect.new()
|
|
|
|
texrect.rect_position.x = tileset * 256 * 2
|
|
|
|
texrect.rect_position.y = 256
|
|
|
|
texrect.rect_scale *= 4
|
|
|
|
texrect.texture = SpriteLoader.worldmap_tile_atlas_textures[tileset]
|
|
|
|
texrect.material = pal_shader_mat.duplicate()
|
|
|
|
texrect.material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[tileset])
|
|
|
|
map_texrects.append(texrect)
|
|
|
|
add_child(texrect)
|
|
|
|
texrect = TextureRect.new()
|
|
|
|
texrect.rect_position.x = tileset * 256 * 2
|
|
|
|
texrect.rect_position.y = 768
|
|
|
|
texrect.rect_scale *= 4
|
|
|
|
texrect.texture = SpriteLoader.worldmap_tile_atlas_textures[tileset]
|
|
|
|
map_texrects.append(texrect)
|
|
|
|
add_child(texrect)
|
|
|
|
|
|
|
|
func _create_worldmap_texrects() -> void:
|
|
|
|
var map_tilesets = [0, 1, 0, 2, 2]
|
|
|
|
for i in 1:
|
|
|
|
var tileset = map_tilesets[i]
|
|
|
|
var image = MapLoader.worldmaps[i].make_tile_map()
|
|
|
|
map_images.append(image)
|
|
|
|
var tex := SpriteLoader.texture_from_image(image)
|
|
|
|
map_textures.append(tex)
|
|
|
|
var texrect = TextureRect.new()
|
|
|
|
texrect.rect_scale *= 8 #8 # Needs to have at least 1 pixel per tile pixel
|
|
|
|
texrect.texture = tex
|
|
|
|
texrect.material = worldmap_shader_mat.duplicate()
|
|
|
|
texrect.material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[tileset])
|
|
|
|
texrect.material.set_shader_param('tile_atlas', SpriteLoader.worldmap_tile_atlas_textures[tileset])
|
|
|
|
map_texrects.append(texrect)
|
|
|
|
add_child(texrect)
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
|
|
|
# Only create this after MapLoader and SpriteLoader have loaded!
|
|
|
|
_create_worldmap_texrects()
|
2023-07-28 00:06:46 +09:30
|
|
|
# _create_palette_and_atlas_texrects()
|
2023-07-27 20:25:26 +09:30
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
#func _process(delta: float) -> void:
|
|
|
|
# pass
|