Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ Standard: c++11
---
Language: JavaScript
IndentWidth: 2
ColumnLimit: 100
ColumnLimit: 100
1 change: 1 addition & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ exclude_files=vendor
exclude_files=docs
filter=-runtime/explicit
filter=-legal/copyright
filter=-whitespace/newline
29 changes: 15 additions & 14 deletions examples/audio/audio_music_stream.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************************
*
* raylib [audio] example - Music playing (streaming)
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
*
* raylib [audio] example - Music playing (streaming)
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

Expand All @@ -19,7 +19,7 @@ int main() {

raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");

raylib::AudioDevice audio; // Initialize audio device
raylib::AudioDevice audio; // Initialize audio device

raylib::Music music("resources/target.ogg");

Expand All @@ -28,14 +28,14 @@ int main() {
float timePlayed = 0.0f;
bool pause = false;

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
music.Update(); // Update music buffer with new stream data
music.Update(); // Update music buffer with new stream data

// Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE)) {
Expand All @@ -49,7 +49,8 @@ int main() {

if (pause) {
music.Pause();
} else {
}
else {
music.Resume();
}
}
Expand Down
32 changes: 16 additions & 16 deletions examples/audio/audio_sound_loading.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************************
*
* raylib [audio] example - Sound loading and playing
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
*
* raylib [audio] example - Sound loading and playing
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

Expand All @@ -19,20 +19,20 @@ int main() {

raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");

raylib::AudioDevice audiodevice; // Initialize audio device
raylib::AudioDevice audiodevice; // Initialize audio device

raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file
raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file
raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file
raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound
if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound
if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound
if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound
//----------------------------------------------------------------------------------

// Draw
Expand Down
40 changes: 20 additions & 20 deletions examples/core/core_basic_window.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/*******************************************************************************************
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

Expand All @@ -33,7 +33,7 @@ int main() {
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
// Update your variables here
Expand Down
44 changes: 21 additions & 23 deletions examples/core/core_basic_window_web.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*******************************************************************************************
*
* raylib-cpp [core] example - Basic window (adapted for HTML5 platform)
*
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
* As you will notice, code structure is slightly diferent to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
*
* raylib-cpp [core] example - Basic window (adapted for HTML5 platform)
*
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
* As you will notice, code structure is slightly diferent to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#include <emscripten/emscripten.h>
#endif

//----------------------------------------------------------------------------------
Expand All @@ -28,25 +28,24 @@ int screenHeight = 450;
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame
void UpdateDrawFrame(void); // Update and Draw one frame

//----------------------------------------------------------------------------------
// Main Enry Point
//----------------------------------------------------------------------------------
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [core] example - basic window");

#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) // Detect window close button or ESC key
while (!window.ShouldClose()) // Detect window close button or ESC key
{
UpdateDrawFrame();
}
Expand All @@ -58,8 +57,7 @@ int main()
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void)
{
void UpdateDrawFrame(void) {
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
Expand All @@ -69,9 +67,9 @@ void UpdateDrawFrame(void)
//----------------------------------------------------------------------------------
BeginDrawing();

ClearBackground(RAYWHITE);
ClearBackground(RAYWHITE);

raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY);
raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY);

EndDrawing();
//----------------------------------------------------------------------------------
Expand Down
33 changes: 17 additions & 16 deletions examples/core/core_drop_files.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*******************************************************************************************
*
* raylib [core] example - Windows drop files
*
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
*
* This example has been created using raylib-cpp (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2020 Rob Loach (@RobLoach)
*
********************************************************************************************/
*
* raylib [core] example - Windows drop files
*
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
*
* This example has been created using raylib-cpp (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2020 Rob Loach (@RobLoach)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

Expand All @@ -23,11 +23,11 @@ int main() {

std::vector<std::string> droppedFiles;

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
if (IsFileDropped()) {
Expand All @@ -44,15 +44,16 @@ int main() {
// Check if there are files to process.
if (droppedFiles.empty()) {
raylib::DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
} else {
}
else {
raylib::DrawText("Dropped files:", 100, 40, 20, DARKGRAY);

// Iterate through all the dropped files.
for (int i = 0; i < (int)droppedFiles.size(); i++) {
if (i % 2 == 0)
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
else
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));

// Display the path to the dropped file.
raylib::DrawText(droppedFiles[i].c_str(), 120, 100 + 40 * i, 10, GRAY);
Expand Down
31 changes: 17 additions & 14 deletions examples/core/core_input_mouse.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************************
*
* raylib [core] example - Mouse input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
*
* raylib [core] example - Mouse input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

#include "raylib-cpp.hpp"

Expand All @@ -23,18 +23,21 @@ int main() {
raylib::Color ballColor = raylib::Color::DarkBlue();
raylib::Color textColor = raylib::Color::DarkGray();

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();

if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
ballColor = MAROON;
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON))
ballColor = LIME;
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON))
ballColor = DARKBLUE;
//----------------------------------------------------------------------------------

// Draw
Expand Down
Loading
Loading