Files
escape/Scripts/Painting.gd
T

35 lines
1.0 KiB
GDScript

@tool
extends Node3D
const SIZE = 5
enum Direction {UP, RIGHT, DOWN, LEFT}
var sequence = []
func _ready():
randomize()
var arrow = Image.load_from_file("res://Images/arrow.png")
arrow.convert(Image.FORMAT_RG8)
var painting = Image.create(128*SIZE, 128*SIZE, false, Image.FORMAT_RG8)
var painting_em = Image.create(128*SIZE, 128*SIZE, false, Image.FORMAT_RG8)
painting_em.fill(Color.BLACK)
painting.fill(Color.YELLOW_GREEN)
for x in range(SIZE):
for y in range(SIZE):
var dir = randi() % 4
for i in range(dir):
arrow.rotate_90(0)
painting.blit_rect(arrow, arrow.get_used_rect() ,Vector2i(x*128, y*128))
if randi() % SIZE == 0:
painting_em.blit_rect(arrow, arrow.get_used_rect() ,Vector2i(x*128, y*128))
sequence.append(dir)
for i in range(4-dir):
arrow.rotate_90(0)
var texture = ImageTexture.create_from_image(painting)
$Canvas.get_surface_override_material(0).albedo_texture = texture
var texture_em = ImageTexture.create_from_image(painting_em)
$Canvas.get_surface_override_material(0).emission_texture = texture_em