https://github.com/numpad/c-engine
Experimental Game Engine in C99 which Supports Linux and WebAssembly.
https://github.com/numpad/c-engine
c99 emscripten game-development libwebsockets linux networking opengl opengl-es sdl2 sockets webassembly websockets
Last synced: about 2 months ago
JSON representation
Experimental Game Engine in C99 which Supports Linux and WebAssembly.
- Host: GitHub
- URL: https://github.com/numpad/c-engine
- Owner: numpad
- Created: 2023-06-22T19:03:20.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-08T14:13:10.000Z (about 1 year ago)
- Last Synced: 2025-03-08T15:22:53.303Z (about 1 year ago)
- Topics: c99, emscripten, game-development, libwebsockets, linux, networking, opengl, opengl-es, sdl2, sockets, webassembly, websockets
- Language: C
- Homepage:
- Size: 22 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C-Engine
A nice and simple low-level engine for simple game development in C99.
## Building
The engine is being built using C99, OpenGL ES2, [SDL2](https://www.libsdl.org/)
and a few other great libraries.
Supported Platforms are Linux and the Browser (WebAssembly) – Windows and native
Android will be implemented eventually and should in theory work without too many
changes.
```bash
# Linux:
$ make
# WebAssembly:
$ make CC=emcc
```
Afterwards, run the game using `$ ./cengine` or `$ emrun cengine.html`, depending on your platform.
To serve the game as a Progressive Webapp, build using `CC=emcc` and copy `src/web/pwa/service-worker.js` in the same directory as `cengine.html`. The directory `src/web/pwa/` needs to be accessible.
### Hot reloading
On linux, the engine supports hot reloading scenes & code used in them.
This requires changing the `Makefile`, `src/engine.c` and then running:
```
# Build loadable DLL
$ make scenes
# Send SIGUSR1 to running cengine process.
$ killall -USR1 cengine # (not tested)
```
### Server
```bash
# Build the server
$ make -f src/server/Makefile
# Run it on port 9123 (instead of 9124) as we use a reverse proxy.
$ ./server -p 9123
```
```nginx
server {
listen 9124 ssl;
server_name gameserver.example.com;
root /mnt/file_server;
location / {
sendfile on;
sendfile_max_chunk 64m;
tcp_nopush on;
proxy_pass http://localhost:9123;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
}
```