-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from X-R-G-B/doc/RB-64-Raylib-encapsulation
DOCUMENTATION: Add raylib wrapper documentation
- Loading branch information
Showing
25 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# C++ Client Documentation | ||
|
||
## Table of Contents | ||
- [Introduction](#introduction) | ||
- [Raylib Library](#raylib-library) | ||
|
||
## Introduction | ||
The C++ client is a simple game client that uses the Raylib library to handle graphics and audio. The client is designed to be simple and easy to use, but it is also very flexible and can be used to create more complex games. | ||
|
||
## Raylib Library | ||
We use the Raylib library to handle our graphics and audio. Raylib is a simple and easy-to-use library that provides a wide range of features. The Raylib library is written in C, but we have wrapped it in C++ classes to make it easier to use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Using Audio in our game client | ||
|
||
In your C++ client application, you can manage audio using the Raylib library. This guide explains how to work with sounds and music using our Raylib wrapper classes. Before looking at the other pages, we advise you to look at the rest of this page. Initialize the audio correctly is essential to use it in our client. | ||
|
||
## Audio Device Management | ||
|
||
### Functions | ||
|
||
```cpp | ||
void Raylib::initAudioDevice(); | ||
void Raylib::closeAudioDevice(); | ||
bool Raylib::isAudioDeviceReady(); | ||
void Raylib::setMasterVolume(float volume); | ||
``` | ||
## Example usage | ||
You need to initialize the audio device before using any audio functions. You can do this by calling the initAudioDevice() function. You can then use the other functions to manage the audio device. If you want to player music, every frame you need to call the UpdateMusicStream() function. | ||
```cpp | ||
int main() { | ||
Raylib::Music music("path/to/musicfile.ogg"); | ||
Raylib::initAudioDevice(); | ||
// game loop | ||
while (!Raylib::WindowShouldClose()) { | ||
// stuff | ||
//for every music | ||
Raylib::UpdateMusicStream(music); | ||
} | ||
Raylib::closeAudioDevice(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Volume, pitch, and pan | ||
|
||
- The pitch base level is 1.0f (normal pitch). | ||
- The volume base level is 1.0f (maximum volume). | ||
- The pan base level is 0.5f (center). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Audio File Formats | ||
|
||
Raylib supports the following audio file formats: | ||
|
||
- WAV | ||
- OGG | ||
- MP3 | ||
- XM | ||
- QOA | ||
- MOD | ||
- FLAC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## Music Class | ||
|
||
### Constructors | ||
|
||
```cpp | ||
Raylib::Music(const std::string& fileName, float volume = 0.5f); | ||
``` | ||
Create a music object from the specified audio file. | ||
### Methods | ||
```cpp | ||
void Raylib::Music::unload(); | ||
bool Raylib::Music::isReady() const; | ||
void Raylib::Music::play() const; | ||
bool Raylib::Music::isPlaying() const; | ||
void Raylib::Music::update() const; | ||
void Raylib::Music::stop() const; | ||
void Raylib::Music::pause() const; | ||
void Raylib::Music::resume() const; | ||
void Raylib::Music::setVolume(float volume) const; | ||
void Raylib::Music::setPitch(float pitch) const; | ||
void Raylib::Music::setPan(float pan) const; | ||
float Raylib::Music::getTimeLength() const; | ||
float Raylib::Music::getTimePlayed() const; | ||
bool Raylib::Music::NeedToPlay() const; | ||
void Raylib::Music::setNeedToPlay(bool needToPlay); | ||
std::string Raylib::Music::getPath() const; | ||
``` | ||
|
||
### Example usage | ||
|
||
```cpp | ||
Raylib::Music myMusic("path/to/musicfile.ogg"); | ||
myMusic.play(); | ||
myMusic.setVolume(0.6f); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## Sound Class | ||
|
||
### Constructors | ||
|
||
```cpp | ||
Raylib::Sound(const std::string& fileName, float volume = 0.5f); | ||
``` | ||
Create a sound object from the specified audio file. | ||
### Methods | ||
```cpp | ||
void Raylib::Sound::unload(); | ||
void Raylib::Sound::play() const; | ||
void Raylib::Sound::stop() const; | ||
void Raylib::Sound::pause() const; | ||
void Raylib::Sound::resume() const; | ||
bool Raylib::Sound::isPlaying() const; | ||
void Raylib::Sound::setVolume(float volume) const; | ||
void Raylib::Sound::setPitch(float pitch) const; | ||
void Raylib::Sound::setPan(float pan) const; | ||
bool Raylib::Sound::NeedToPlay() const; | ||
void Raylib::Sound::setNeedToPlay(bool needToPlay); | ||
std::string Raylib::Sound::getPath() const; | ||
``` | ||
|
||
### Example usage | ||
|
||
```cpp | ||
Raylib::Sound mySound("path/to/soundfile.wav"); | ||
mySound.play(); | ||
mySound.setVolume(0.8f); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Input-related functions: keyboard | ||
|
||
- `bool Raylib::isKeyPressed(Raylib::KeyboardKey key);` | ||
Check if a key has been pressed once. | ||
|
||
- `bool Raylib::isKeyDown(Raylib::KeyboardKey key);` | ||
Check if a key is being pressed. | ||
|
||
- `bool Raylib::isKeyReleased(Raylib::KeyboardKey key);` | ||
Check if a key has been released once. | ||
|
||
- `bool Raylib::isKeyUp(Raylib::KeyboardKey key);` | ||
Check if a key is NOT being pressed. | ||
|
||
- `void Raylib::setExitKey(Raylib::KeyboardKey key);` | ||
Set a key to exit the application. | ||
|
||
- `int Raylib::getKeyPressed();` | ||
Get the key pressed (keycode). | ||
|
||
- `int Raylib::getCharPressed();` | ||
Get the last character pressed (unicode). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## Input-related functions: mouse | ||
|
||
- `bool Raylib::isMouseButtonPressed(Raylib::MouseButton button);` | ||
Check if a mouse button has been pressed once. | ||
|
||
- `bool Raylib::isMouseButtonDown(Raylib::MouseButton button);` | ||
Check if a mouse button is being pressed. | ||
|
||
- `bool Raylib::isMouseButtonReleased(Raylib::MouseButton button);` | ||
Check if a mouse button has been released once. | ||
|
||
- `bool Raylib::isMouseButtonUp(Raylib::MouseButton button);` | ||
Check if a mouse button is NOT being pressed. | ||
|
||
- `int Raylib::getMouseX();` | ||
Get the X position of the mouse cursor. | ||
|
||
- `int Raylib::getMouseY();` | ||
Get the Y position of the mouse cursor. | ||
|
||
- `Vector2 Raylib::getMousePosition();` | ||
Get the current position of the mouse cursor. | ||
|
||
- `Vector2 Raylib::getMouseDelta();` | ||
Get the mouse delta movement. | ||
|
||
- `void Raylib::setMousePosition(int x, int y);` | ||
Set the position of the mouse cursor. | ||
|
||
- `void Raylib::setMouseOffset(int offsetX, int offsetY);` | ||
Set an offset for the mouse position. | ||
|
||
- `void Raylib::setMouseScale(float scaleX, float scaleY);` | ||
Set the scaling factor for the mouse position. | ||
|
||
- `float Raylib::getMouseWheelMove();` | ||
Get the mouse wheel movement. | ||
|
||
- `Vector2 Raylib::getMouseWheelMoveV();` | ||
Get the mouse wheel movement as a vector. | ||
|
||
- `void Raylib::setMouseCursor(int cursor);` | ||
Set the mouse cursor style. | ||
|
||
## Example | ||
|
||
```cpp | ||
if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_RIGHT)) | ||
{ | ||
// Move right | ||
} | ||
else if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_LEFT)) | ||
{ | ||
// Move left | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## Color Structure | ||
|
||
Represents a color. | ||
|
||
- `Raylib::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);` | ||
Constructor to create a color with specified `r` (red), `g` (green), `b` (blue), and `a` (alpha) values. | ||
|
||
### Color Constants | ||
|
||
- `Raylib::DarkGray` | ||
- `Raylib::Yellow` | ||
- `Raylib::Gold` | ||
- `Raylib::Orange` | ||
- `Raylib::Pink` | ||
- `Raylib::Red` | ||
- `Raylib::Maroon` | ||
- `Raylib::Green` | ||
- `Raylib::Lime` | ||
- `Raylib::DarkGreen` | ||
- `Raylib::SkyBlue` | ||
- `Raylib::Blue` | ||
- `Raylib::DarkBlue` | ||
- `Raylib::Purple` | ||
- `Raylib::Violet` | ||
- `Raylib::DarkPurple` | ||
- `Raylib::Beige` | ||
- `Raylib::Brown` | ||
- `Raylib::DarkBrown` | ||
- `Raylib::White` | ||
- `Raylib::Black` | ||
- `Raylib::Blank` | ||
- `Raylib::Magenta` | ||
- `Raylib::RayWhite` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Rectangle Structure | ||
|
||
Represents a rectangle. | ||
|
||
- `Raylib::Rectangle(float x, float y, float width, float height);` | ||
Constructor to create a rectangle with specified `x`, `y`, `width`, and `height` values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Vector2 Structure | ||
|
||
Represents a 2D vector. | ||
|
||
- `Raylib::Vector2(float x, float y);` | ||
Constructor to create a 2D vector with specified `x` and `y` values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Vector3 Structure | ||
|
||
Represents a 3D vector. | ||
|
||
- `Raylib::Vector3(float x, float y, float z);` | ||
Constructor to create a 3D vector with specified `x`, `y`, and `z` values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Vector4 Structure | ||
|
||
Represents a 4D vector. | ||
|
||
- `Raylib::Vector4(float x, float y, float z, float w);` | ||
Constructor to create a 4D vector with specified `x`, `y`, `z`, and `w` values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Colors/pixels related functions | ||
|
||
- `Raylib::Color Raylib::fade(Raylib::Color color, float alpha);` | ||
Fade a color by a specified alpha value. | ||
|
||
- `int Raylib::colorToInt(Raylib::Color color);` | ||
Convert a Color to a 32-bit integer. | ||
|
||
- `Vector4 Raylib::colorNormalize(Raylib::Color color);` | ||
Normalize a Color struct to a Vector4. | ||
|
||
- `Raylib::Color Raylib::colorFromNormalized(Raylib::Vector4 normalized);` | ||
Create a Color from a normalized Vector4. | ||
|
||
- `Raylib::Color Raylib::getColor(unsigned int hexValue);` | ||
Create a Color from a hex value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Enum ConfigFlags | ||
|
||
You can use the following flags to configure the window: | ||
|
||
- `Raylib::ConfigFlags::ConfigFlags::FLAG_FULLSCREEN_MODE`: Set fullscreen mode. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_RESIZABLE`: Allow the window to be resized. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_UNDECORATED`: Disable window decoration (frame and buttons). | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_TRANSPARENT`: Allow the window to be transparent. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_HIDDEN`: Hide the window. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_MINIMIZED`: Minimize the window. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_MAXIMIZED`: Maximize the window. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_UNFOCUSED`: Disable window focus. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_TOPMOST`: Set the window to be always on top. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_HIGHDPI`: Enable high-DPI mode. | ||
- `Raylib::ConfigFlags::FLAG_WINDOW_ALWAYS_RUN`: Allow the window to run in the background. | ||
- `Raylib::ConfigFlags::FLAG_MSAA_4X_HINT`: Enable 4x MSAA. | ||
- `Raylib::ConfigFlags::FLAG_VSYNC_HINT`: Enable V-Sync. | ||
|
||
## Example | ||
|
||
```cpp | ||
Raylib::setWindowState(Raylib::ConfigFlags::WINDOW_RESIZABLE); | ||
Raylib::setWindowState(Raylib::ConfigFlags::WINDOW_RESIZABLE | Raylib::ConfigFlags::FLAG_VSYNC_HINT); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Cursor-related functions | ||
|
||
- `void Raylib::showCursor();` | ||
Show the cursor. | ||
|
||
- `void Raylib::hideCursor();` | ||
Hide the cursor. | ||
|
||
- `bool Raylib::isCursorHidden();` | ||
Check if the cursor is currently hidden. | ||
|
||
- `void Raylib::enableCursor();` | ||
Enable cursor (unlock it). | ||
|
||
- `void Raylib::disableCursor();` | ||
Disable cursor (lock it). | ||
|
||
- `bool Raylib::isCursorOnScreen();` | ||
Check if the cursor is within the game window. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Drawing-related functions | ||
|
||
- `void Raylib::clearBackground(Raylib::Color color);` | ||
Clear the background with a specified color. | ||
|
||
- `void Raylib::beginDrawing();` | ||
Begin drawing. | ||
|
||
- `void Raylib::endDrawing();` | ||
End drawing and swap buffers. |
Oops, something went wrong.