How to implement global data in the advance game template?

I am using your advance game template (thank you for including this) and there is a comment in main that says:

// TODO: Load global data here (assets that must be available in all screens, i.e. fonts)

I cannot figure out how to access variables that I create here from other screens. I am using c++ if that makes a difference.

Thank you!


  • Ok, I see, actually, there is one variable as example (kind of), currentScreen.

    You can just declare variables required for all the screens in screens/screens.h, that file is visible for all the screens.

    Variables declared in screens.h, should be defined (initialized) in main code (advance_game.c).

    I use that same templates for most of my games, here it is the last one:, just coded in the last two days, you can check global variables font and music.
  • Another great example. Just what I was looking for.

    (I'll be keeping an eye on the Dev branch now.)

  • wave_collector throws the following error:

    gcc: error: C:\raylib\raylib\raylib_icon: No such file or directory
  • edited January 2017
    Hey Markz, thanks for reporting that! It should be raylib\src\resources, I'll correct it together with some other issues... game crashes some times and need to investigate it...

    Just checked it and it's ok, that file is not referenced... just notice you should use 'raylib_makefile' Notepad++ script for compilation.
Sign In or Register to comment.