Skip to content

input_system::triple_axis

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

Usage

Meant for tracking values controlled by 6 keys. Eg. forward/backward/left/right/up/down movement.

To Use construct triple_axis object in game::your_script scope. To get axis value call triple_axis::raw() or triple_axis.normalized().

triple_axis::normalized() will make sure vector made from 3 axis' states is normalized. triple_axis::raw() will treat 3 axis independently.

Example

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

#include"axis.h"
#include"time_system.h"
#include<glm/glm.hpp>

namespace game {
	class my_script {
	private:
		input_system::triple_axis a = input_system::axis(GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT, GLFW_KEY_W, GLFW_KEY_S); // constuct axis object
		glm::vec3 r = glm::vec3(0.0f);
		glm::vec3 n = glm::vec3(0.0f);
		
		// ...
	public:
		virtual void update();
		
		// ...
	};
}

// ...

void game::my_script::update(){
	r += a.raw() * (float)time::delta_time; // get axis raw value using triple_axis::raw();
	n += a.normalized() * (float)time::delta_time; // get axis normalized value using triple_axis::normalized();

	// ...
}

See also

Home

Git Workflow

Issues

Coding Rules

Skrypty-Tutorial

Useful resources

Game Structure

Code Structure

Clone this wiki locally