-
Notifications
You must be signed in to change notification settings - Fork 0
scripts_system::script
Paweł Waligóra edited this page May 9, 2024
·
17 revisions
Full signature: class
scripts_system::script
namespace scripts_system {
class script {
public:
std::string name;
script() : name("") {};
script(const std::string& name_) : name(name_) {};
virtual void start() {};
virtual void update() {};
virtual ~script() {};
};
}
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::start()
- called once just before first update -
scripts_system::script::update()
- called every iteration of game loop
-
All methods are called by scripts_system::call_events()
, after object has been registered with: scripts_system::subscribe(&object)
- preferred.
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_START
SCRIPTS_UPDATE
my_script.h
#pragma once
#include "scripts_system.h"
namespace game {
class my_script : public scripts_system::script {
public:
virtual void start();
virtual void update();
// other public members
private:
// private members
};
}
my_script.cpp
#include "my_script.h"
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
}
// 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