Project Setup
This commit is contained in:
parent
8a9d8b1ece
commit
9504620227
13 changed files with 125329 additions and 69 deletions
73
.gitignore
vendored
73
.gitignore
vendored
|
@ -1,68 +1,5 @@
|
|||
# ---> C
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# ---> CMake
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeUserPresets.json
|
||||
|
||||
.bake_cache
|
||||
.DS_Store
|
||||
.vscode
|
||||
gcov
|
||||
bin
|
||||
|
|
194
README.md
194
README.md
|
@ -1,2 +1,194 @@
|
|||
# colysis
|
||||
### I do not own these libraries
|
||||
_This is a template that I have made using both Raylib and Flecs libraries using the bake compiler._
|
||||
|
||||
_Please note that neither Raylib (https://github.com/raysan5/raylib) nor Flecs (https://github.com/SanderMertens/flecs/tree/master) belong to me. I have only created this template for ease-of-use for any developers who desire to start using Flecs and Raylib._
|
||||
|
||||
# ------ SETTING UP THE PROJECT ------
|
||||
If this is your first time setting up a project, I will walk you through all of the steps for getting started.
|
||||
|
||||
## MacOS or Linux
|
||||
**1. First, install Brew.**
|
||||
|
||||
If you're using MacOS or Linux you will first need to install **Brew**. Open a new terminal and run this command:
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
**2. Install Git CLI**
|
||||
|
||||
Once that's finished, install the **GitHub CLI** (Command Line Imterface). This is what we will use to install the **bake** compiler.
|
||||
```bash
|
||||
brew install git
|
||||
```
|
||||
> Run `git --version` to make sure it installed correctly. The result should be something like `git version 2.49.1`.
|
||||
|
||||
**3. Install Bake**
|
||||
|
||||
Go to this link ([Bake Compiler](https://github.com/SanderMertens/bake)) and click "Code" and download the zip file.
|
||||
|
||||
Once downloaded, open the folder. Open a new terminal and drag and drop `setup.sh` into the terminal window. Press return (or enter) in the terminal, enter your password if asked, and close the terminal when done.
|
||||
|
||||
> Again, ensure it installed correctly with `bake --version`
|
||||
|
||||
**4. Raylib and Flecs Libraries**
|
||||
|
||||
Download this zip file [Unix Raylib Library](https://github.com/user-attachments/files/17962571/libraylib.a.zip) and unzip it once it's downloaded.
|
||||
|
||||
Open your device root folder (for example: "Macintosh HD" in finder) then go to Users/*you*/bake/lib (or equivalent on Linux) and put this raylib library in it.
|
||||
|
||||
Download the raylib source files by running,
|
||||
```bash
|
||||
cd
|
||||
git clone https://github.com/raysan5/raylib.git
|
||||
```
|
||||
|
||||
Download this [flecs package](https://github.com/user-attachments/files/17963061/flecs.zip), unzip it, and run:
|
||||
```
|
||||
cd /path/to/flecs
|
||||
bake
|
||||
```
|
||||
> Note: if this package is moved, you have to run `bake` again.
|
||||
|
||||
**5. Build the Template**
|
||||
|
||||
Now let's build the template.
|
||||
|
||||
Simply open a terminal and go to a location where you would like to put the template. I will put mine into "~/bake/src/bake/templates".
|
||||
|
||||
Once there, run these commands:
|
||||
```bash
|
||||
git clone https://github.com/aog05/Raylib-and-Flecs-Template
|
||||
bake Raylib-and-Flecs-Template
|
||||
```
|
||||
|
||||
**6. Create the Project**
|
||||
|
||||
Go to a folder where you like this project to be. I put mine in a folder called, _"Raylib Projects"_ and run this command.
|
||||
```bash
|
||||
bake new your_project_name -t RaFT
|
||||
```
|
||||
|
||||
Run the program with: `bake run`.
|
||||
|
||||
If you ever want to make a new project, all you have to do is repeat step this step.
|
||||
|
||||
## Windows
|
||||
Windows is a slightly tougher version to build for, so if there are any problems, you can report them here or on Discord.
|
||||
|
||||
**1. Install Git CLI**
|
||||
|
||||
If you haven't already download the GitHub CLI (Command Line Interface) run the command below.
|
||||
```powershell
|
||||
winget install --id Git.Git -e --source winget
|
||||
```
|
||||
> Note: this command only works on Windows 11. Go [here](https://git-scm.com/downloads/win) for previous versions.
|
||||
|
||||
**2. Install Visual Studio Build Tools**
|
||||
|
||||
First, follow this link ([Download Bulid Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)) and go down to "Tools for Visual Studio" and click download on "Build Tools for Visual Studio" at the bottom of the selection.
|
||||
|
||||
Once it finishes downloading, open the Visual Studio Installer and click "Modify". After that, select "Desktop Development with C++" and click "Modify" in the bottom right. You can close the installer once it finishes installing.
|
||||
|
||||
**3. Install Bake**
|
||||
|
||||
Go to this link ([Bake Compiler](https://github.com/SanderMertens/bake)) and click "Code" and download the zip file.
|
||||
|
||||
Once downloaded, right-click the zip folder and click "Extract All...". open the folder. Open a new terminal, type `cd`, drag and drop the folder inside (should be called "bake-master") into the terminal window, and hit enter.
|
||||
```powershell
|
||||
# The command should look like this
|
||||
cd C:\Users\your_username\Downloads\bake-master\bake-master
|
||||
```
|
||||
|
||||
Run `./setup.bat` after that.
|
||||
|
||||
> Again, ensure it installed correctly with `bake --version`
|
||||
|
||||
**4. Raylib and Flecs libraries**
|
||||
|
||||
Download this zip file ([Raylib for x32](https://github.com/user-attachments/files/18310969/raylibdll.zip) or [Raylib for x64](https://github.com/user-attachments/files/18310976/raylibdll.zip)) and unzip it once it's downloaded.
|
||||
|
||||
Open "File Explorer" and go to C:\Users\*you*\bake\lib and put this raylib library in it.
|
||||
|
||||
Download the raylib source files by running,
|
||||
```powershell
|
||||
cd
|
||||
git clone https://github.com/raysan5/raylib.git
|
||||
```
|
||||
|
||||
Download this [flecs package](https://github.com/user-attachments/files/17963061/flecs.zip), unzip it, and run:
|
||||
```
|
||||
cd \path\to\flecs
|
||||
bake
|
||||
```
|
||||
> Note: if this package is moved, you have to run `bake` again.
|
||||
|
||||
**5. Build the Template**
|
||||
|
||||
Now let's build the template.
|
||||
|
||||
Simply open a terminal and go to a location where you would like to put the template. I will put mine into "~/bake/src/bake/templates".
|
||||
|
||||
Once there, run these commands:
|
||||
```powershell
|
||||
git clone https://github.com/aog05/Raylib-and-Flecs-Template
|
||||
bake Raylib-and-Flecs-Template
|
||||
```
|
||||
|
||||
**6. Create the Project**
|
||||
|
||||
Go to a folder where you like this project to be. I put mine in a folder called, _"Raylib Projects"_ and run this command.
|
||||
```powershell
|
||||
bake new your_project_name -t RaFT
|
||||
```
|
||||
|
||||
Run the program with: `bake run`.
|
||||
|
||||
If you ever want to make a new project, all you have to do is repeat this step.
|
||||
|
||||
## Build for Web
|
||||
|
||||
In your existing project, run these commands for your specific platform.
|
||||
|
||||
**For all platforms and languages**
|
||||
```powershell
|
||||
bake --target em
|
||||
```
|
||||
|
||||
**Web MacOS and Linux**
|
||||
|
||||
Copy and paste this at the root of your project.
|
||||
```bash
|
||||
emcc -o bin/game.html .bake_cache/Em-debug/obj/main.o .bake_cache/Em-debug/obj/flecs.o -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result --embed-file assets -Os -I ~/raylib/src -I ~/raylib/src/external -I include -I deps -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --shell-file ~/raylib/src/minshell.html ~/raylib/src/web/libraylib.a -DPLATFORM_WEB -s 'EXPORTED_FUNCTIONS=["_free","_malloc","_main"]' -s EXPORTED_RUNTIME_METHODS=ccall
|
||||
```
|
||||
|
||||
**Web Windows**
|
||||
|
||||
Copy and paste this at the root of your project.
|
||||
```powershell
|
||||
emcc -o bin/game.html .bake_cache/Em-debug/obj/main.o .bake_cache/Em-debug/obj/flecs.o -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result --embed-file assets -Os -I C:/raylib/src -I C:/raylib/src/external -I include -I deps -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --shell-file C:/raylib/src/minshell.html C:/raylib/src/web/libraylib.a -DPLATFORM_WEB -s 'EXPORTED_FUNCTIONS=["_free","_malloc","_main"]' -s EXPORTED_RUNTIME_METHODS=ccall
|
||||
```
|
||||
|
||||
**Test on the Web**
|
||||
|
||||
This will produce an HTML file where you can run your game.
|
||||
|
||||
```bash
|
||||
// If you have npm, use
|
||||
npx http-server /path/to/game.html
|
||||
|
||||
// If you have python, use
|
||||
// It may also be "py", "python3", or "py -3" depending on your OS
|
||||
python -m http.server
|
||||
```
|
||||
|
||||
By the way, if this is for itch.io, you have to take the HTML, JS, and WASM and compress them to a zip file. You can upload the zip file for web games on itch!
|
||||
|
||||
# ------ REFERENCES ------
|
||||
Reference Articles:
|
||||
|
||||
Flecs Quickstart: https://www.flecs.dev/flecs/md_docs_2Quickstart.html
|
||||
|
||||
Raylib Examples: https://www.raylib.com/examples.html
|
||||
|
||||
Raylib CheatSheet: https://www.raylib.com/cheatsheet/cheatsheet.html
|
||||
|
||||
Bake Compiler: https://github.com/SanderMertens/bake
|
||||
|
|
BIN
assets/Raylib_logo.png
Normal file
BIN
assets/Raylib_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
43
deps/dependee.json
vendored
Normal file
43
deps/dependee.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"dependee": {
|
||||
"lang.c": {
|
||||
"${cfg sanitize}": {
|
||||
"defines": [
|
||||
"FLECS_SANITIZE"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lang.cpp": {
|
||||
"${cfg sanitize}": {
|
||||
"defines": [
|
||||
"FLECS_SANITIZE"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"lang.c": {
|
||||
"${os linux}": {
|
||||
"lib": [
|
||||
"rt",
|
||||
"pthread",
|
||||
"m"
|
||||
],
|
||||
"${cfg debug}": {
|
||||
"export-symbols": true
|
||||
},
|
||||
"${cfg sanitize}": {
|
||||
"export-symbols": true
|
||||
}
|
||||
},
|
||||
"${os windows}": {
|
||||
"lib": [
|
||||
"ws2_32"
|
||||
]
|
||||
},
|
||||
"${cfg sanitize}": {
|
||||
"defines": [
|
||||
"FLECS_SANITIZE"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
81507
deps/flecs.c
vendored
Normal file
81507
deps/flecs.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
33512
deps/flecs.h
vendored
Normal file
33512
deps/flecs.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
19
include/colysis.h
Normal file
19
include/colysis.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef COLYSIS_H
|
||||
#define COLYSIS_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "colysis/bake_config.h"
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "rlgl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
24
include/colysis/bake_config.h
Normal file
24
include/colysis/bake_config.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
)
|
||||
(.)
|
||||
.|.
|
||||
| |
|
||||
_.--| |--._
|
||||
.-'; ;`-'& ; `&.
|
||||
\ & ; & &_/
|
||||
|"""---...---"""|
|
||||
\ | | | | | | | /
|
||||
`---.|.|.|.---'
|
||||
|
||||
* This file is generated by bake.lang.c for your convenience. Headers of
|
||||
* dependencies will automatically show up in this file. Include bake_config.h
|
||||
* in your main project file. Do not edit! */
|
||||
|
||||
#ifndef COLYSIS_BAKE_CONFIG_H
|
||||
#define COLYSIS_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include "../../deps/flecs.h"
|
||||
|
||||
#endif
|
||||
|
1708
include/raylib.h
Normal file
1708
include/raylib.h
Normal file
File diff suppressed because it is too large
Load diff
2949
include/raymath.h
Normal file
2949
include/raymath.h
Normal file
File diff suppressed because it is too large
Load diff
5262
include/rlgl.h
Normal file
5262
include/rlgl.h
Normal file
File diff suppressed because it is too large
Load diff
80
project.json
Normal file
80
project.json
Normal file
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"id": "colysis",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"author": "Sander Mertens and Raysan5",
|
||||
"description": "A template including both Raylib and Flecs!",
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"standalone": true
|
||||
},
|
||||
"lang.c": {
|
||||
"${os linux}": {
|
||||
"lib": [
|
||||
"rt",
|
||||
"pthread",
|
||||
"m",
|
||||
"GL",
|
||||
"X11",
|
||||
"Xi",
|
||||
"Xcursor",
|
||||
"dl",
|
||||
"raylib"
|
||||
]
|
||||
},
|
||||
"${os windows}": {
|
||||
"lib": [
|
||||
"raylibdll.lib",
|
||||
"ws2_32",
|
||||
"gdi32",
|
||||
"opengl32",
|
||||
"winmm",
|
||||
"kernel32"
|
||||
],
|
||||
"defines": [
|
||||
"_WINDOWS",
|
||||
"_USRDLL",
|
||||
"CGLM_EXPORTS",
|
||||
"CGLM_DLL"
|
||||
]
|
||||
},
|
||||
"${cfg sanitize}": {
|
||||
"defines": [
|
||||
"FLECS_SANITIZE"
|
||||
]
|
||||
},
|
||||
"${os darwin}": {
|
||||
"lib": [
|
||||
"raylib"
|
||||
],
|
||||
"ldflags": [
|
||||
"-framework Cocoa",
|
||||
"-framework CoreVideo",
|
||||
"-framework IOKit",
|
||||
"-framework GLUT",
|
||||
"-framework OpenGL"
|
||||
]
|
||||
},
|
||||
"${target em}": {
|
||||
"libpath": [
|
||||
"~\/raylib\/src"
|
||||
],
|
||||
"embed": [
|
||||
"assets"
|
||||
],
|
||||
"ldflags": [
|
||||
"-I ~\/raylib\/src",
|
||||
"-I ~\/raylib\/src\/external",
|
||||
"-s USE_GLFW=3",
|
||||
"-s ASYNCIFY",
|
||||
"-s TOTAL_MEMORY=67108864",
|
||||
"-s FORCE_FILESYSTEM=1",
|
||||
"-s EXPORTED_FUNCTIONS=['_free','_malloc','_main']",
|
||||
"-s EXPORTED_RUNTIME_METHODS=ccall",
|
||||
"--shell-file ~\/raylib\/src\/minshell.html ~\/raylib\/src\/web\/libraylib.a",
|
||||
"-D PLATFORM_WEB"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
27
src/main.c
Normal file
27
src/main.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <colysis.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
InitWindow(900, 500, "Colysis");
|
||||
|
||||
ecs_world_t *world = ecs_init();
|
||||
ecs_entity_t ray = ecs_entity(world, { .name = "raysan5" });
|
||||
|
||||
puts(ecs_get_name(world, ray));
|
||||
Texture2D logo = LoadTexture("assets/Raylib_logo.png");
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
BeginDrawing();
|
||||
DrawTexture(logo, GetScreenWidth() / 2 - logo.width / 2, GetScreenHeight() / 2 - logo.height / 2, WHITE);
|
||||
DrawText(ecs_get_name(world, ray), GetScreenWidth() / 2 - 25 * 3.5f, GetScreenHeight() - 50, 50, BLACK);
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
UnloadTexture(logo);
|
||||
CloseWindow();
|
||||
return ecs_fini(world);
|
||||
}
|
Loading…
Reference in a new issue