GithubHelp home page GithubHelp logo

raylib-game-template's Introduction


DISCLAIMER:

Welcome to raylib game template!

This template provides a base structure to start developing a small raylib game in plain C. The repo is also pre-configured with a default LICENSE (zlib/libpng) and a README.md (this one) to be properly filled by users. Feel free to change the LICENSE as required.

All the sections defined by $(Data to Fill) are expected to be edited and filled properly. It's recommended to delete this disclaimer message after editing this README.md file.

This template has been created to be used with raylib (www.raylib.com) and it's licensed under an unmodified zlib/libpng license.

Copyright (c) 2014-2024 Ramon Santamaria (@raysan5)


Getting Started with this template

You can use this templates in some ways. Using Visual Studio, using CMake or make your own build setup. This repository come with Visual Studio and CMake already setuped.

Chose one of the follow setup, that fit in you development enviroment.

Visual Studio

  • After extracting the zip, the parent folder raylib-game-template should exist in the same directory as raylib itself. So your file structure should look like this:
  • If using Visual Studio, open projects/VS2022/raylib-game-template.sln
  • Select on raylib_game in the solution explorer, then in the toolbar at the top, click Project > Set as Startup Project
  • Now you're all set up! Click Local Windows Debugger with the green play arrow and the project will run.

CMake

  • Extract the zip of this project
  • Type the follow command:
cmake -S . -B build

if you want with debug symbols put the flag -DCMAKE_BUILD_TYPE=Debug

  • After CMake config you project build:
cmake --build build
  • Inside the build folder are another folder (named the same as the project name on CMakeLists.txt) with the executable and resources folder.

$(Game Title)

$(Game Title)

Description

$(Your Game Description)

Features

  • $(Game Feature 01)
  • $(Game Feature 02)
  • $(Game Feature 03)

Controls

Keyboard:

  • $(Game Control 01)
  • $(Game Control 02)
  • $(Game Control 03)

Screenshots

TODO: Show your game to the world, animated GIFs recommended!.

Developers

  • $(Developer 01) - $(Role/Tasks Developed)
  • $(Developer 02) - $(Role/Tasks Developed)
  • $(Developer 03) - $(Role/Tasks Developed)

Links

  • YouTube Gameplay: $(YouTube Link)
  • itch.io Release: $(itch.io Game Page)
  • Steam Release: $(Steam Game Page)

License

This game sources are licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.

$(Additional Licenses)

Copyright (c) $(Year) $(User Name) ($(User Twitter/GitHub Name))

raylib-game-template's People

Contributors

jdoleary avatar jeffm2501 avatar jupiterrider avatar lesleyrs avatar lpg2709 avatar m374lx avatar majanto avatar mrdaybird avatar orcmid avatar planetis-m avatar raysan5 avatar s-yablonskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raylib-game-template's Issues

Why do you have 2 CMakeLists.txt?

Hi, why do you have 2 CMakeLists.txt? Doesn't this cause a conflict when creating the project?

I would like the template to be more neutral, so that it can be used in any IDE or text editor, such as Kdevelop, Gnome builder, kate, Eclipse, VIM, geditor, and not just in visual studio.

saludos.

make fails when converting to C++

All I did was change the compiler from gcc to g++ and change the flag -std=c99 to -std=c++17

alex@pop-os:~/Dropbox/dev/silver-palm-tree/src$ make make raylib_game make[1]: Entering directory '/home/alex/Dropbox/dev/silver-palm-tree/src' g++ -c raylib_game.c -o raylib_game.o -Wall -std=c++17 -D_DEFAULT_SOURCE -Wno-missing-braces -s -O1 -D_DEFAULT_SOURCE -I/usr/local/include -I. -I/home/alex/Dropbox/dev/silver-palm-tree/src -I/home/alex/Dropbox/dev/silver-palm-tree/src/external -DPLATFORM_DESKTOP raylib_game.c:25:28: error: invalid conversion from ‘int’ to ‘GameScreen’ [-fpermissive] 25 | GameScreen currentScreen = 0; | ^ | | | int raylib_game.c: In function ‘void ChangeToScreen(int)’: raylib_game.c:142:21: error: invalid conversion from ‘int’ to ‘GameScreen’ [-fpermissive] 142 | currentScreen = screen; | ^~~~~~ | | | int raylib_game.c: In function ‘void UpdateTransition()’: raylib_game.c:189:29: error: invalid conversion from ‘int’ to ‘GameScreen’ [-fpermissive] 189 | currentScreen = transToScreen; | ^~~~~~~~~~~~~ | | | int raylib_game.c: At global scope: raylib_game.c:120:13: warning: ‘void ChangeToScreen(int)’ defined but not used [-Wunused-function] 120 | static void ChangeToScreen(int screen) | ^~~~~~~~~~~~~~ make[1]: *** [Makefile:407: raylib_game.o] Error 1 make[1]: Leaving directory '/home/alex/Dropbox/dev/silver-palm-tree/src' make: *** [Makefile:398: all] Error 2

Is it wise to add working directory change for compiling/debugging

I think it is a good idea to expand the readme with information about changing the working directory into $(ProjectDir)......\src
Just so that the .exe that is being debugged can find the resrouces properly. I ended up figuring this out myself.. took me an hour.

Getting linker error with cmake

Getting the following linker error when building with cmake:
(pruned for readability)

...
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwGetTime
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwSwapBuffers
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwSetErrorCallback
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwInit
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwDefaultWindowHints
wasm-ld: error: _deps/raylib-build/raylib/libraylib.a(rcore.c.o): undefined symbol: glfwWindowHint
...

Adding the following after line 44 fixed the issue:

    target_link_options(${PROJECT_NAME} PUBLIC "-sUSE_GLFW=3")

CONVENTIONS omits typedef conventions

The typedef cases seem to be for title case. It is not shown, although an already-defined type is used in an example.

I am unclear about the situation with all caps types that also happens in raylib.

The trick around using struct declarator names as defined types is also worthy of note. A mindmeld of the C Language type form :).

E.g.,

typedef struct Texture { ... } Texture

static CoreData CORE = { 0 )

`PLATFORM=PLATFORM_WEB make` don't work on MacOS

After brew install emscripten, brew install raylib, cloning this repo and running PLATFORM=PLATFORM_WEB make from the src/ dir gives this output:

% PLATFORM=PLATFORM_WEB make
/Applications/Xcode.app/Contents/Developer/usr/bin/make raylib_game
emcc -c raylib_game.c -o raylib_game.o -std=c99 -Wall -Wno-missing-braces -Wunused-result -D_DEFAULT_SOURCE -Os -I. -I../../raylib/src -I../../raylib/src/external -I../../raylib/src/extras -DPLATFORM_WEB
make[1]: emcc: No such file or directory
make[1]: *** [raylib_game.o] Error 1
make: *** [all] Error 2

which emcc finds it at /usr/local/bin, which is on the $PATH

Convention for line-width?

I notice that there is no constraint on line width and even in markdown, lines can be very wide, although GitHub Markdown treats simple line breaks as just white space.

I like to have my code and other text formats confined to a line width that I can print and also view easily in any editor. I even set VS Code to break on a right margin and I clean them up usually. The only exception I can think of is URLs and Markdown links. I am known to put a ruler line at the top of a text file just for this purpose.

Put differently, if I continued to do that (my width magic number is 72) would it still be compatible with the raylib convention? I.e., in a pull request?

How to add resources

I'm not a C developer, but I wanted to try to create some games with raylib. This will really be a stupid question, but how can I add resources to the solution? I'm using VS2022 and the provided solution file. I added the files from the Dr. Turtle and Mr. Gamera resources to the src/resources folder, but they are not found when running the game with this warning:

WARNING: FILEIO: [resources/sky.png] Failed to open file
WARNING: FILEIO: [resources/mountains.png] Failed to open file
WARNING: FILEIO: [resources/sea.png] Failed to open file
etc.

Do I have to add all files into a custom build step? What am I missing?

Note: If I just copy the resources folder to the output folder it works. I notice the CMAKE file have a COPY src/resources command, is it missing in the VS2022 solution? Or does it use another mechanism?

`make clean` not working on windows

sh: del: not found

I did some reading on the discord and you can use make clean SHELL=CMD in order to get it to work because w64devkit uses busybox shell.

Does that not mean that windows should use the linux commands by default, or is w64devkit not the intended way to use raylib on windows? I guess the installer only installs mingw itself, where do you get the single download from besides raylib?

Edit: I just noticed it works fine in raylib itself, can this be added to the makefile here as well? clean_shell_cmd: SHELL=cmd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.