amethyst/apps/example_game/lib/example/game.ex
Kodi Craft f037f0de02
All checks were successful
Build & Test / nix-build (push) Successful in 2m42s
Build & Test / nix-build (pull_request) Successful in 2m45s
No longer rely on loose error checking and other minor fixes
2024-09-19 15:11:59 +02:00

40 lines
965 B
Elixir

defmodule Example.Game do
require Logger
@behaviour Amethyst.API.Game
@impl true
def instantiate(supervisor) do
Logger.info("The supervisor for this game is at #{inspect(supervisor)}")
{:ok, %{}}
end
@impl true
def login(from, cfg, refs) do
Logger.info("Player logged in from #{inspect(from)}: #{inspect(cfg)}")
Logger.info("The refs for this game are #{inspect(refs)}")
#send(from, {:send_packet, %{
# packet_type: :synchronize_player_position,
# x: 0.0, y: 0.0, z: 0.0, yaw: 0.0, pitch: 0.0, flags: 0x00,
# teleport_id: 0
#}})
:accept
end
@impl true
def player_position(from, {x, y, z}, _refs) do
Logger.info("Player at #{inspect(from)} moved to #{x}, #{y}, #{z}")
:ok
end
@impl true
def accept_teleport(from, id, _state_refs) do
Logger.info("Player at #{inspect(from)} accepted teleport #{inspect(id)}")
:ok
end
@impl true
def joinable?(_refs) do
true
end
end