Solar System OpenGL v1.0.0
Loading...
Searching...
No Matches
keyboard_handler.cpp File Reference

Implements keyboard input handling for controlling the application. More...

#include "keyboard_handler.h"

Go to the source code of this file.

Functions

void zoom (bool out)
 Adjusts the camera zoom level.
 
void keyPressed (unsigned char key, int x, int y)
 Handles keyboard input to control application features.
 

Variables

bool showOrbits = false
 Flag to toggle orbital visibility.
 
float cameraDistance = 50.0
 Distance of the camera from the target.
 
int selectedElement = -1
 Index of the currently selected celestial body.
 
bool paused = false
 Flag to toggle simulation pause state.
 

Detailed Description

Implements keyboard input handling for controlling the application.

This file provides the implementation of functions for handling keyboard input to control various aspects of the application, such as camera zoom, orbital visibility, and simulation state.

Function Documentation

◆ keyPressed()

void keyPressed ( unsigned char key,
int x,
int y )

Handles keyboard input to control application features.

Handles keyboard input for controlling the application.

Parameters
keyThe ASCII code of the pressed key.
xThe X-coordinate of the mouse cursor.
yThe Y-coordinate of the mouse cursor.

This function is called when a key is pressed. It processes the key input to perform actions such as zooming the camera, toggling orbital visibility, selecting celestial bodies, and pausing or resuming the simulation.

◆ zoom()

void zoom ( bool out)

Adjusts the camera zoom level.

Parameters
outIf true, zooms out; otherwise, zooms in.

This function adjusts the camera distance based on the zoom direction. The distance is clamped between 5.0 and 100.0 units.

Variable Documentation

◆ cameraDistance

float cameraDistance = 50.0

Distance of the camera from the target.

This variable represents the distance between the camera and the point it is observing, affecting the zoom level.

This external float variable represents the distance between the camera and the point it is observing, affecting the zoom level.

This external variable represents the distance between the camera and the point it is looking at, affecting the zoom level.

◆ paused

bool paused = false

Flag to toggle simulation pause state.

This variable indicates whether the simulation is currently paused or running.

This external boolean variable indicates whether the simulation is currently paused or running.

◆ selectedElement

int selectedElement = -1

Index of the currently selected celestial body.

This variable represents the index of the currently selected planet or celestial body, used for highlighting or focusing. A value of -1 indicates no selection.

This external integer variable represents the index of the currently selected planet or celestial body, used for highlighting or focusing.

◆ showOrbits

bool showOrbits = false

Flag to toggle orbital visibility.

This variable indicates whether the orbital paths of celestial bodies are visible or hidden.

This external boolean variable indicates whether the orbital paths of celestial bodies are visible or hidden.