From 3de570b14175eff4601ed970414ec9cfd7b79c40 Mon Sep 17 00:00:00 2001 From: xamidev Date: Tue, 14 Jan 2025 21:32:58 +0100 Subject: [PATCH] initial setup --- README.md | 7 ++++++ src/cells.c | 30 ++++++++++++++++++++++++++ src/cells.h | 33 +++++++++++++++++++++++++++++ src/main.c | 61 +++++++++++++++++++++++++++-------------------------- 4 files changed, 101 insertions(+), 30 deletions(-) create mode 100644 src/cells.c create mode 100644 src/cells.h diff --git a/README.md b/README.md index 201bd83..0192c62 100644 --- a/README.md +++ b/README.md @@ -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 A simple cross platform template for setting up a project with the bleeding edge raylib code. Works with C or C++. diff --git a/src/cells.c b/src/cells.c new file mode 100644 index 0000000..38c7e62 --- /dev/null +++ b/src/cells.c @@ -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 +*/ + +#include \ No newline at end of file diff --git a/src/cells.h b/src/cells.h new file mode 100644 index 0000000..ccea4d5 --- /dev/null +++ b/src/cells.h @@ -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 +*/ + +#ifndef CELLS_H +#define CELLS_H + +#endif // CELLS_H \ No newline at end of file diff --git a/src/main.c b/src/main.c index aa18f0f..ef646da 100644 --- a/src/main.c +++ b/src/main.c @@ -1,53 +1,54 @@ -/* -Raylib example file. -This is an example main file for a simple raylib project. -Use this as a starting point or replace it with your code. - -by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/ - +/** +* @file src/main.c +* @brief Sandbox game in Raylib +* +* @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 */ #include "raylib.h" - -#include "resource_dir.h" // utility header for SearchAndSetResourceDir +#include "cells.h" int main () { - // Tell the window to use vsync and work on high DPI displays SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_HIGHDPI); - - // 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"); + InitWindow(1280, 800, "Sandbox"); // game loop - while (!WindowShouldClose()) // run the loop untill the user presses ESCAPE or presses the Close button on the window + while (!WindowShouldClose()) { + test(); // drawing BeginDrawing(); // Setup the back buffer for drawing (clear color and depth buffers) 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...) EndDrawing(); } - // cleanup - // unload our texture so it can be cleaned up - UnloadTexture(wabbit); - // destroy the window and cleanup the OpenGL context CloseWindow(); return 0;