Permalink
Browse files

Install resources files

Install resources files in PREFIX/share/raymario/resources.
Document comands user has to run in README.md
  • Loading branch information...
jubalh committed Feb 8, 2018
1 parent eac5a0d commit 188beb56d9aa0a0912f22f3b0aeb7287f2a381ce
Showing with 43 additions and 20 deletions.
  1. +2 −1 README.md
  2. +17 −1 meson.build
  3. +4 −1 src/level.c
  4. +20 −17 src/main.c
@@ -17,7 +17,8 @@ It was originally created by [Víctor Fisac](https://github.com/victorfisac).
meson builddir
cd builddir
ninja
./raymario
sudo ninja install
raymario
```
## Screenshot
@@ -3,12 +3,23 @@ project('raymario', 'c', version: '1.0',
cc = meson.get_compiler('c')
# find dependencies
glfw_dep = dependency('glfw3')
gl_dep = dependency('gl')
openal_dep = dependency('openal')
m_dep = cc.find_library('m', required : false)
raylib_dep = cc.find_library('raylib', required : false)
prefix = get_option('prefix')
conf = configuration_data()
conf.set('PREFIX', prefix,
description : 'Installation prefix.')
conf.set('RESOURCE_DIR', '"' + prefix + '/share/raymario/resources"',
description : 'Resource directory contains fonts, images, sounds, maps. Resource files will be installed in $PREFIX/share/raymario/resources')
config_h = configure_file(output : 'config.h', configuration : conf)
source_c = [
'src/main.c',
'src/level.c',
@@ -17,10 +28,15 @@ source_c = [
'src/screens/gameplay_screen.c',
'src/screens/win_screen.c',
'src/screens/end_screen.c',
'src/libraries/physac.c'
'src/libraries/physac.c',
config_h
]
# build executable
raymario = executable('raymario',
source_c,
dependencies : [ raylib_dep, glfw_dep, gl_dep, openal_dep, m_dep ],
install : true)
# install resources directory to prefix/share/raymario
install_subdir('resources', install_dir : 'share/raymario')
@@ -4,6 +4,9 @@
#include "libraries/defines.c"
#include "libraries/physac.h"
// Config header build by meson. Contains the resources path.
#include "config.h"
// Levels are saved as image files (png)
// RGB - Color - Representation
// 255,255,0 - Yellow - Floor
@@ -49,7 +52,7 @@ void LoadLevel(int level)
}
// Map data initialization based on current level
Color *pixels = GetImageData(LoadImage(FormatText("resources/maps/level_map_%02i.png", level)));
Color *pixels = GetImageData(LoadImage(FormatText(RESOURCE_DIR "/maps/level_map_%02i.png", level)));
// Level initialization
usedFloor = 0;
@@ -34,6 +34,9 @@
#include "screens/win_screen.h"
#include "screens/gameplay_screen.h"
// Config header build by meson. Contains the resources path.
#include "config.h"
// Function declarations
void LoadResources();
void UnloadResources();
@@ -103,33 +106,33 @@ int main()
void LoadResources()
{
// SpriteFonts loading
font = LoadSpriteFont("resources/fonts/komika.png");
font = LoadSpriteFont(RESOURCE_DIR "/fonts/komika.png");
// Sprites loading
background = LoadTexture("resources/images/background.png");
marioAtlas = LoadTexture("resources/images/mario_atlas.png");
environmentAtlas = LoadTexture("resources/images/environment_atlas.png");
castleTex = LoadTexture("resources/images/castle.png");
background = LoadTexture(RESOURCE_DIR "/images/background.png");
marioAtlas = LoadTexture(RESOURCE_DIR "/images/mario_atlas.png");
environmentAtlas = LoadTexture(RESOURCE_DIR "/images/environment_atlas.png");
castleTex = LoadTexture(RESOURCE_DIR "/images/castle.png");
// Sounds Loading
sounds[S_SELECT] = LoadSound("resources/sounds/select.wav");
sounds[S_JUMP] = LoadSound("resources/sounds/player_jump.wav");
sounds[S_KICK] = LoadSound("resources/sounds/player_kick.wav");
sounds[S_FIRE] = LoadSound("resources/sounds/player_fire.wav");
sounds[S_DIE] = LoadSound("resources/sounds/player_die.wav");
sounds[S_COIN] = LoadSound("resources/sounds/coin.wav");
sounds[S_TIMELEFT] = LoadSound("resources/sounds/left_time.wav");
sounds[S_GAMEOVER] = LoadSound("resources/sounds/gameover.wav");
sounds[S_COMPLETE_LEVEL] = LoadSound("resources/sounds/win.wav");
sounds[S_WON] = LoadSound("resources/sounds/wingame.wav");
marioSong = LoadMusicStream("resources/music/mario_music.ogg");
sounds[S_SELECT] = LoadSound(RESOURCE_DIR "/sounds/select.wav");
sounds[S_JUMP] = LoadSound(RESOURCE_DIR "/sounds/player_jump.wav");
sounds[S_KICK] = LoadSound(RESOURCE_DIR "/sounds/player_kick.wav");
sounds[S_FIRE] = LoadSound(RESOURCE_DIR "/sounds/player_fire.wav");
sounds[S_DIE] = LoadSound(RESOURCE_DIR "/sounds/player_die.wav");
sounds[S_COIN] = LoadSound(RESOURCE_DIR "/sounds/coin.wav");
sounds[S_TIMELEFT] = LoadSound(RESOURCE_DIR "/sounds/left_time.wav");
sounds[S_GAMEOVER] = LoadSound(RESOURCE_DIR "/sounds/gameover.wav");
sounds[S_COMPLETE_LEVEL] = LoadSound(RESOURCE_DIR "/sounds/win.wav");
sounds[S_WON] = LoadSound(RESOURCE_DIR "/sounds/wingame.wav");
marioSong = LoadMusicStream(RESOURCE_DIR "/music/mario_music.ogg");
// Maps initialization
FILE *imageFile;
for (int i = 0; i < MAX_LEVELS; i++)
{
imageFile = fopen(FormatText("resources/maps/level_map_0%i.png", i + 1), "rb");
imageFile = fopen(FormatText(RESOURCE_DIR "/maps/level_map_0%i.png", i + 1), "rb");
if (imageFile == NULL) break;

0 comments on commit 188beb5

Please sign in to comment.