44 lines
1.3 KiB
ActionScript 3
44 lines
1.3 KiB
ActionScript 3
// Autoload configuration script.
|
|
// Runs before any scene/game script to configure input and preload resources.
|
|
|
|
void Autoload() {
|
|
|
|
|
|
ClearAllActions();
|
|
|
|
// Movement
|
|
RegisterAction("move_up");
|
|
RegisterAction("move_down");
|
|
RegisterAction("move_left");
|
|
RegisterAction("move_right");
|
|
BindKeyboard("move_up", Key::W);
|
|
BindKeyboard("move_up", Key::UP);
|
|
BindKeyboard("move_down", Key::S);
|
|
BindKeyboard("move_down", Key::DOWN);
|
|
BindKeyboard("move_left", Key::A);
|
|
BindKeyboard("move_left", Key::LEFT);
|
|
BindKeyboard("move_right", Key::D);
|
|
BindKeyboard("move_right", Key::RIGHT);
|
|
|
|
// Actions
|
|
RegisterAction("jump");
|
|
RegisterAction("interact");
|
|
RegisterAction("attack");
|
|
BindKeyboard("jump", Key::SPACE);
|
|
BindKeyboard("interact", Key::E);
|
|
BindKeyboard("attack", Key::LEFT_CONTROL);
|
|
BindMouseButton("attack", MouseButton::LEFT);
|
|
|
|
// Gamepad (optional)
|
|
BindGamepadButton("jump", 0, GamepadButton::RIGHT_FACE_DOWN);
|
|
BindGamepadButton("interact", 0, GamepadButton::RIGHT_FACE_RIGHT);
|
|
BindGamepadAxis("move_left", 0, GamepadAxis::LEFT_X, 0.3f, true);
|
|
BindGamepadAxis("move_right", 0, GamepadAxis::LEFT_X, 0.3f, false);
|
|
|
|
// Pick the initial scene to load.
|
|
Scene::Load("scenes/demo.toml");
|
|
|
|
Globals::Set("demo_var",100);
|
|
}
|
|
|