Skip to content

setting up a project

Lulezer edited this page Mar 30, 2025 · 3 revisions

⚙️ Prerequisites

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)

🛠️ Step-by-Step Setup

1. Download Echlib

  • 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.

2. Project Directory Setup

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 dont have to use Cmake but it is Very Usefull

CmakeLists.txt: `cmake_minimum_required(VERSION 3.10) project(MyGame)

set(CMAKE_CXX_STANDARD 17)

Set the location of the include folder (where echlib headers are)

include_directories(include)

Add source files

add_executable(MyGame src/main.cpp src/game.cpp)

Add Echlib source files (since it's not a precompiled library)

add_subdirectory(lib/echlib)

Link the source files directly

target_sources(MyGame PRIVATE lib/echlib/echlib.cpp lib/echlib/raudio.cpp )

`

With this configuration:

  1. The header files are included from include/echlib/.

  2. The Echlib source files are included directly from lib/echlib/.

  3. 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

Clone this wiki locally