├── .gitattributes
├── README.md
├── ball.cpp
├── ball.h
├── build.bat
├── main.cpp
├── preview.jpg
└── raylib-cpp.sublime-build
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Raylib-CPP-Starter-Template-SublimeText
2 |
3 | Raylib C++ Starter Template for Sublime Text 4 on Windows.
4 | This demo project contains a bouncing ball raylib example program.
5 | It works with raylib version 4.5. Tested on both Windows 10 and Windows 11.
6 |
7 | # How to use this template
8 | 1. Open the template folder in Sublime text.
9 | 2. Go to Tools -> Build System -> New Build System.
10 | 3. In the new build file, copy the contents of the raylib-cpp.sublime-build file included in this repository.
11 | 4. Save the new file as raylib-cpp.sublime-build
12 | 5. Go to Tools -> Build System and select raylib-cpp as the build system, if it is not already selected.
13 | 6. Press CTRL + B on the keyboard to build the project.
14 |
15 | Once you have created the raylib-cpp.sublime-build file, we can re-use it in all your raylib projects. This procedure must be done only once.
16 |
17 | # Video Tutorial
18 |
19 |
20 |
21 |
22 | 🎥 Video Tutorial on YouTube
23 |
24 |
25 |
26 |
27 | | 📺 My YouTube Channel
28 | | 🌍 My Website |
29 |
30 |
--------------------------------------------------------------------------------
/ball.cpp:
--------------------------------------------------------------------------------
1 | #include "ball.h"
2 | #include
3 |
4 | Ball::Ball()
5 | {
6 | x = 100;
7 | y = 100;
8 | speedX = 8;
9 | speedY = 8;
10 | radius = 15;
11 | }
12 |
13 | void Ball::Update()
14 | {
15 | x += speedX;
16 | y += speedY;
17 |
18 | if (x + radius >= GetScreenWidth() || x - radius <= 0)
19 | speedX *= -1;
20 |
21 | if (y + radius >= GetScreenHeight() || y - radius <= 0)
22 | speedY *= -1;
23 | }
24 |
25 | void Ball::Draw()
26 | {
27 | DrawCircle(x, y, radius, WHITE);
28 | }
--------------------------------------------------------------------------------
/ball.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class Ball
4 | {
5 | public:
6 | Ball();
7 | void Update();
8 | void Draw();
9 |
10 | private:
11 | int x;
12 | int y;
13 | int speedX;
14 | int speedY;
15 | int radius;
16 | };
--------------------------------------------------------------------------------
/build.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | cls
3 |
4 | :: ***********************************************************************
5 | rem Batch file for compiling Raylib and/or Raygui applications
6 | :: ***********************************************************************
7 |
8 | :Initialization
9 | SET "RAYLIB_DIR=C:\raylib"
10 | SET "CURRENT_DIR=%cd%"
11 |
12 | SET "INPUT_FILE=%1"
13 | SET "OUTPUT_FILE=%2"
14 | SET "INCLUDE_FILES= -I %cd%"
15 |
16 | SET "COMPILER= C:\raylib\w64devkit\bin\g++.exe"
17 | SET "CFLAGS=%RAYLIB_DIR%\raylib\src\raylib.rc.data -Wall -std=c++14 -D_DEFAULT_SOURCE -Wno-missing-braces"
18 | SET "LDFLAGS= -lraylib -lopengl32 -lgdi32 -lwinmm"
19 | SET "EXTRAFLAGS="
20 |
21 | IF /I "%3"=="Release" SET EXTRAFLAGS=%EXTRAFLAGS% -O3
22 |
23 |
24 | :Main
25 | echo(
26 | echo ^> Removing Previous Build
27 | echo ----------------------------
28 | IF EXIST "%1.exe" del /F "%1.exe"
29 |
30 | echo(
31 | echo ^> Compiling Program
32 | echo ----------------------------
33 | %COMPILER% -o "%OUTPUT_FILE%" *.cpp %INCLUDE_FILES% %CFLAGS% %LDFLAGS% %EXTRAFLAGS%
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "ball.h"
3 |
4 | int main() {
5 | Color darkGreen = Color{20, 160, 133, 255};
6 |
7 | int screenWidth = 800;
8 | int screenHeight = 600;
9 |
10 | Ball ball = Ball();
11 |
12 | InitWindow(screenWidth, screenHeight, "My first RAYLIB program!");
13 | SetTargetFPS(60);
14 |
15 | while (!WindowShouldClose()) {
16 | BeginDrawing();
17 | ClearBackground(darkGreen);
18 | ball.Update();
19 | ball.Draw();
20 | EndDrawing();
21 | }
22 |
23 | CloseWindow();
24 | }
25 |
--------------------------------------------------------------------------------
/preview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/educ8s/Raylib-CPP-Starter-Template-SublimeText/2ffea3dd520dd839c682caa4b2264b37692f4986/preview.jpg
--------------------------------------------------------------------------------
/raylib-cpp.sublime-build:
--------------------------------------------------------------------------------
1 | {
2 | "selector" : "source.cpp",
3 |
4 | "quiet": true,
5 |
6 | "shell" : true,
7 |
8 | "working_dir" : "$file_path",
9 |
10 | "variants": [
11 | {
12 | "name": "Compile",
13 | "cmd" : ["$file_path\\build.bat", "$file_name", "$file_base_name.exe"]
14 | },
15 |
16 | {
17 | "name": "Compile & Run",
18 | "cmd" : ["$file_path\\build.bat", "$file_name", "$file_base_name.exe", "&&", "$file_base_name.exe"], //, "&&", "$file_base_name.exe"
19 | },
20 |
21 | {
22 | "name": "Release",
23 | "cmd" : ["$file_path\\build.bat", "$file_name", "$file_base_name.exe", "Release"]
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------