VSGL2 - Very Simple Graphic Library 2  2.0
 All Classes Namespaces Files Functions Variables Macros Pages
Functions
vsgl2::io Namespace Reference

Functions

bool is_pressed (int key)
 Use to check if a button is pressed. More...
 
string read_text (string font, int dim, int x, int y, Color c, uint8_t max_length=0)
 Use to read text from the user, the return key stops the input. More...
 
int get_mouse_x ()
 Use to get the mouse x coordinate. More...
 
int get_mouse_y ()
 Use to get the mouse y coordinate. More...
 
int get_mouse_wheel_x ()
 Use to get the mouse wheel horizontal value,. More...
 
int get_mouse_wheel_y ()
 Use to get the mouse wheel vertical value,. More...
 
bool mouse_left_button_pressed ()
 Use to check if the mouse left button is pressed. More...
 
bool mouse_right_button_pressed ()
 Use to check if the mouse right button is pressed. More...
 

Function Documentation

int get_mouse_wheel_x ( )

Use to get the mouse wheel horizontal value,.

Returns
The amount scrolled horizontally, positive (1) to the right and negative (-1) to the left
int get_mouse_wheel_y ( )

Use to get the mouse wheel vertical value,.

Returns
The amount scrolled vertically, positive (1) away from the user and negative (-1) toward the user
int get_mouse_x ( )

Use to get the mouse x coordinate.

Returns
The value of mouse x coordinate
int get_mouse_y ( )

Use to get the mouse y coordinate.

Returns
The value of mouse y coordinate
bool is_pressed ( int  key)

Use to check if a button is pressed.

Parameters
keyThe enum value indicating the key pressed
Returns
True if key is pressed, false otherwise
Attention
All the SDL scancodes (https://wiki.libsdl.org/SDL_Scancode) are translated in a sort of VSGL equivalent notation For example, SDL_SCANCODE_LEFT will become VSGL_LEFT
Warning
All translated code are in vsgl2_keycode.h, this is a work in progress, so actually only certain codes are translated
Todo:
Translate all the SDL2 scancodes into VSGL codes
bool mouse_left_button_pressed ( )

Use to check if the mouse left button is pressed.

Returns
True if the left button is pressed, false otherwise
bool mouse_right_button_pressed ( )

Use to check if the mouse right button is pressed.

Returns
True if the right button is pressed, false otherwise
string read_text ( string  font,
int  dim,
int  x,
int  y,
Color  c,
uint8_t  max_length = 0 
)

Use to read text from the user, the return key stops the input.

Parameters
fontThe filename of the font.
dimFont dimension
xThe x coordinate of the upper left corner of the text inside the window coordinates
yThe y coordinate of the upper left corner of the text inside the window coordinates
cThe color of the text
max_lengthThe maximum length of the text that can be written. The default value is 0, which means that there is no limit to the text length, otherwise the user can write only max_length characters. The value range is from 0 to 255, greater numbers than that will be truncated.
Returns
The string typed from the user
Warning
This function is blocking, i.e. the program is stopped until the user presses the return key.