initial setup

This commit is contained in:
2025-01-14 21:32:58 +01:00
parent 8da78e51e8
commit 3de570b141
4 changed files with 101 additions and 30 deletions

View File

@@ -1,3 +1,10 @@
# Goal
Building my Powder Toy in C with Raylib.
It will be a cellular automaton with gravity and different particles: the evolution of conway's game of life...
Users should be able to save their creations.
It should be in a well-written and well-optimized code, and should be multiplatform ready.
# Raylib-Quickstart # Raylib-Quickstart
A simple cross platform template for setting up a project with the bleeding edge raylib code. A simple cross platform template for setting up a project with the bleeding edge raylib code.
Works with C or C++. Works with C or C++.

30
src/cells.c Normal file
View File

@@ -0,0 +1,30 @@
/**
* @file src/cells.c
* @brief Cell logic implementation
*
* @copyright
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <https://unlicense.org/>
*/
#include <stdio.h>

33
src/cells.h Normal file
View File

@@ -0,0 +1,33 @@
/**
* @file src/cells.h
* @brief Cell logic header
*
* @copyright
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <https://unlicense.org/>
*/
#ifndef CELLS_H
#define CELLS_H
#endif // CELLS_H

View File

@@ -1,53 +1,54 @@
/* /**
Raylib example file. * @file src/main.c
This is an example main file for a simple raylib project. * @brief Sandbox game in Raylib
Use this as a starting point or replace it with your code. *
* @copyright
by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/ * Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <https://unlicense.org/>
*/ */
#include "raylib.h" #include "raylib.h"
#include "cells.h"
#include "resource_dir.h" // utility header for SearchAndSetResourceDir
int main () int main ()
{ {
// Tell the window to use vsync and work on high DPI displays
SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_HIGHDPI); SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_HIGHDPI);
InitWindow(1280, 800, "Sandbox");
// Create the window and OpenGL context
InitWindow(1280, 800, "Hello Raylib");
// Utility function from resource_dir.h to find the resources folder and set it as the current working directory so we can load from it
SearchAndSetResourceDir("resources");
// Load a texture from the resources directory
Texture wabbit = LoadTexture("wabbit_alpha.png");
// game loop // game loop
while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window while (!WindowShouldClose())
{ {
test();
// drawing // drawing
BeginDrawing(); BeginDrawing();
// Setup the back buffer for drawing (clear color and depth buffers) // Setup the back buffer for drawing (clear color and depth buffers)
ClearBackground(BLACK); ClearBackground(BLACK);
// draw some text using the default font
DrawText("Hello Raylib", 200,200,20,WHITE);
// draw our texture to the screen
DrawTexture(wabbit, 400, 200, WHITE);
// end the frame and get ready for the next one (display frame, poll input, etc...) // end the frame and get ready for the next one (display frame, poll input, etc...)
EndDrawing(); EndDrawing();
} }
// cleanup
// unload our texture so it can be cleaned up
UnloadTexture(wabbit);
// destroy the window and cleanup the OpenGL context // destroy the window and cleanup the OpenGL context
CloseWindow(); CloseWindow();
return 0; return 0;