tabulacrum_test.gd
· 915 B · GDScript3
Raw
Playground
extends Node2D
var world = Tabulacrum.new()
@onready var window_title = get_window().title
func _ready() -> void:
for _i in range(1000):
world.conjure_entity() \
.it_is_a(["circle"]) \
.give_it(
{ position = Vector2(randi_range(100, 500), randi_range(100, 500))
, speed = randf_range(0, 5)
, time = randf() * 2 * PI
, size = randf_range(2,5)
}
) \
.seal()
func _draw() -> void:
for id in world.grab_tome("circle"):
var entity = world.summon_entity(id)
var orbit = Vector2 \
( cos(entity.time) * 10 + entity.position.x
, sin(entity.time) * 10 + entity.position.y
)
draw_circle(orbit, entity.size, Color.WHITE)
func _process(delta: float) -> void:
for id in world.grab_tome("time"):
var entity = world.summon_entity(id)
entity.time += delta * entity.speed
get_window().title = "%s - %s fps" % [window_title, Engine.get_frames_per_second()]
queue_redraw()
| 1 | extends Node2D |
| 2 | var world = Tabulacrum.new() |
| 3 | |
| 4 | @onready var window_title = get_window().title |
| 5 | func _ready() -> void: |
| 6 | for _i in range(1000): |
| 7 | world.conjure_entity() \ |
| 8 | .it_is_a(["circle"]) \ |
| 9 | .give_it( |
| 10 | { position = Vector2(randi_range(100, 500), randi_range(100, 500)) |
| 11 | , speed = randf_range(0, 5) |
| 12 | , time = randf() * 2 * PI |
| 13 | , size = randf_range(2,5) |
| 14 | } |
| 15 | ) \ |
| 16 | .seal() |
| 17 | |
| 18 | func _draw() -> void: |
| 19 | |
| 20 | for id in world.grab_tome("circle"): |
| 21 | var entity = world.summon_entity(id) |
| 22 | var orbit = Vector2 \ |
| 23 | ( cos(entity.time) * 10 + entity.position.x |
| 24 | , sin(entity.time) * 10 + entity.position.y |
| 25 | ) |
| 26 | draw_circle(orbit, entity.size, Color.WHITE) |
| 27 | |
| 28 | func _process(delta: float) -> void: |
| 29 | for id in world.grab_tome("time"): |
| 30 | var entity = world.summon_entity(id) |
| 31 | entity.time += delta * entity.speed |
| 32 | get_window().title = "%s - %s fps" % [window_title, Engine.get_frames_per_second()] |
| 33 | queue_redraw() |
| 34 |