Примеры

1. Пример c ивентами

file.py
from alem_f import World,Robot,Move,Rotation

world = World(Vec3(10,10,10))
submit(world)
def on_spawn(source):
    print("SPAWNED - ",source)

def on_update_position(source,new_position,old_position):
    print("updated - ",source , " , old pos - ", old_position)

def on_update_entity(source,**kwargs):
    print("ENTITY UPDATE - ",source," , updated_params - ",kwargs)

world.events.get_event("on_spawn").add_handler(on_spawn)
world.events.get_event("on_update_position").add_handler(on_update_position)
world.events.get_event("on_update_entity").add_handler(on_update_entity)

r1 = Robot(world)
r1.spawn()
for i in range(5):
    r1.forward()

for i in range(5):
    r1.back()

r1.turn(Rotation.Right)
r1.turn(Rotation.Right)
r1.turn(Rotation.Right)
for i in range(5):
    r1.forward()

2. Пример c блоками

file.py
from alem_f import World,Robot,Rotation
from alem.entities.blocks import DirtBlock
size = Vec3(9,9,6)
world = World(size)
submit(world)
robot = Robot(world)
robot.spawn()
half_size = Vec3(size.x // 2,size.y // 2,size.z //2)
neighbours = [
  [0,1],
  [1,1],
  [1,0],
  [1,-1],
  [-1,-1],
  [-1,0],
  [-1,1]
]
for z in range(0,half_size.z):
  for pos in neighbours:
    current_size = Vec3(0,0,0)
    new_size = current_size + Vec3(pos[0],pos[1],z)
    block = DirtBlock(world,new_size)
    block.spawn()