-
Notifications
You must be signed in to change notification settings - Fork 0
scripts_system::script
Paweł Waligóra edited this page Apr 16, 2024
·
17 revisions
Full signature: class
scripts_system::script
namespace scripts_system {
class script {
public:
bool active = true;
virtual void init() {};
virtual void start() {};
virtual void update() {};
virtual void free() {};
};
}
Class is meant to be abstract. Should be overridden. Place your custom classes that inherit from scripts_system::script
in namespace game
- methods
-
scripts_system::script::init()
- called during opengl init, use for memory allocation. -
scripts_system::script::start()
- called once just before game loop, use for setup -
scripts_system::script::update()
- called ever iteration of game loop -
scripts_system::script::free()
- called on opengl free, use for freeing memory allocated ongame::script::init()
-
All methods are called by scripts_system::call_events()
, after object has been registered with: scripts_system::subscribe(&object)
. Methods can be registered individually with: scripts_system::subscribe(std::bind(&game::your_script::method, &object), SCRIPTS_TYPE)
, where SCRIPTS_TYPE
can be one of the following:
SCRIPTS_INIT
SCRIPTS_START
SCRIPTS_UPDATE
SCRIPTS_FREE
my_script.h
#pragma once
#include "scripts_system.h"
namespace game {
class my_script : public scripts_system::script {
public:
virtual void init();
virtual void start();
virtual void update();
virtual void free();
// other public members
private:
// private members
};
}
my_script.cpp
#include "my_script.h"
void game::my_script::init() {
// this code will execute once on program init
}
void game::my_script::start() {
// this code will execute once just before game loop
}
void game::my_script::update() {
// this code will execute once every program step
}
void game::my_script::free() {
// this code will execute once on program free
}
// other members definitions
- engine
- scripts_system
- scene_loader
- time_system
-
input_system
- input_system::key_held
- input_system::key_events
- input_system::subscribe() (deprecated)
- input_system::axis_state()
- input_system::key_bind
- input_system::axis
- input_system::double_axis
- input_system::triple_axis
- input_system::axis2
- input_system::double_axis2
- input_system::triple_axis2
- input_system::axis-choice
- renderer
- physics
- ui_system
- game