1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-22 05:23:14 +00:00
Pixelorama/src/Classes/TileSetCustom.gd

34 lines
785 B
GDScript3
Raw Normal View History

2024-11-16 03:41:32 +02:00
class_name TileSetCustom
extends RefCounted
signal updated
2024-11-16 03:41:32 +02:00
var name := ""
var tile_size: Vector2i
var tiles: Array[Image] = []
func _init(_tile_size: Vector2i, _name := "") -> void:
tile_size = _tile_size
name = _name
#var indices_x := ceili(float(_project_size.x) / tile_size.x)
#var indices_y := ceili(float(_project_size.y) / tile_size.y)
#tiles.resize(indices_x * indices_y + 1)
var empty_image := Image.create_empty(tile_size.x, tile_size.y, false, Image.FORMAT_RGBA8)
tiles.append(empty_image)
func add_tile(tile: Image) -> void:
tiles.append(tile)
updated.emit()
func remove_tile_at_index(index: int) -> void:
tiles.remove_at(index)
updated.emit()
func replace_tile_at(new_tile: Image, index: int) -> void:
tiles[index].copy_from(new_tile)
updated.emit()