Skip to content

input_system::axis

Paweł Waligóra edited this page May 22, 2024 · 11 revisions

Usage

Meant for tracking values controlled by 2 keys. Eg. forward/backward movement.

To Use construct axis object in game::your_script scope. To get axis value call axis::state().

Example

following example shows how to use input_system::axis in a script.

#include"axis.h"
#include"time_system.h"

namespace game {
	class my_script {
	private:
		input_system::axis a = input_system::axis(GLFW_KEY_UP, GLFW_KEY_DOWN); // constuct axis object
		float x = 0.0f;
		
		// ...
	public:
		virtual void update();
		
		// ...
	};
}

// ...

void game::my_script::update(){
	x += a.state() * (float)time::delta_time; // get axis value using axis::state()

	// ...
}

See also

Home

Git Workflow

Issues

Coding Rules

Skrypty-Tutorial

Useful resources

Game Structure

Code Structure

Clone this wiki locally