-
Notifications
You must be signed in to change notification settings - Fork 1
setting up a project
Before setting up your project, ensure you have the following installed:
- C++ compiler (GCC, Clang, or MSVC)
- CMake (for managing the build process) Optional But Usefull
- Echlib library (see the installation guide)
- Go to the Echlib GitHub Releases page.
- Download the latest zip file for Echlib.
- Extract the contents of the zip file into a
lib/echlib
directory inside your project folder.
Create the following folder structure inside your project directory:
` /MyProject /include (Header files, including Echlib headers) /echlib - echlib.h - raudio.h - etc. /src (Source files, where your game logic lives) - main.cpp - game.cpp - game.h /assets (Textures, audio files, etc.) /build (Generated object files, executables, etc.) CMakeLists.txt (CMake build configuration)
`
You don't have to use CMake, but it is very useful.
cmake_minimum_required(VERSION 3.10)
project(MyGame)
set(CMAKE_CXX_STANDARD 17)
include_directories(include)
add_executable(MyGame src/main.cpp src/game.cpp)
add_subdirectory(lib/echlib)
target_sources(MyGame PRIVATE
lib/echlib/echlib.cpp
lib/echlib/raudio.cpp
)
With this configuration:
-
The header files are included from include/echlib/.
-
The Echlib source files are included directly from lib/echlib/.
-
Echlib will be compiled as part of your project.
Short Example:
#include <echlib.h> // include echlib
int main()
{
int WindowWidth = 640; // Define a width for the window
int windowHeight = 360; // Define a height for the window
ech::MakeWindow(WindowWidth, windowHeight, "Window example with echlib"); // Create the window
ech::SetTargetFps(60); // You dont have to put this for the window to work but you should so that the game always run at 60fps.
while (!ech::WindowShouldClose())
{
ech::StartDrawing(); // Start Drawing the window
ech::ClearBackground(ech::WHITE); // Clear the Background With a color
ech::EndDrawing(); // End Drawing The window
}
ech::CloseWindow(); // Close Window
return 0;
}
We will go more in depth in the code later but for now paste this example to see if you linked echlib correctly
Yo