Intro: compiling your game with VgaGames
========================================
For compiling your game with VgaGames use "vgag2-config".
"vgag2-config --cflags" outputs all needed "-I" compiler-flags.
"vgag2-config --libs" outputs all needed libraries with "-L" and "-l".
"vgag2-config --version" outputs the installed VgaGames2-version as a numerical value.
You may concatenate --cflags and --libs: vgag2-config --cflags --libs
Distributing your game
With VgaGames2 you have two possibilities to give your new game to your
friend Fred:
a) you assume, he already has an installed VgaGames2 version
b) or you include in your game a local version of VgaGames2
For both possibilities Fred has to compile the game, before he can play it.
Example-game
For the following descriptions we use "mygame" as an example:
mygame/Makefile # Makefile for compiling game
mygame/main.c # main function
mygame/game.c # game loop, called from main function
mygame/bitmaps/ # contains all bitmaps
mygame/sounds/ # contains all sounds
mygame/sprites/ # contains all sprites
mygame/share/ # contains optional colormaps and fonts
# and is used for saving properties (.vgag2.rc)
To compile, you have to type:
cc -O2 `vgag2-config --cflags` main.c game.c `vgag2-config --libs` -o mygame
a) Your friend Fred has already an installed VgaGames2 version
You give to him only your game, he unpacks it and types "make".
Your Makefile:
==>
CFLAGS = -O2
# check for installed version of VgaGames, then make your game
mygame: check_version main.c game.c
$(CC) $(CFLAGS) `vgag2-config --cflags` -o mygame main.c game.c `vgag2-config --libs`
# clean (clean also saved properties)
clean:
rm -f *.o mygame share/.vgag2.rc
# check for installed version of VgaGames
check_version:
@test `vgag2-config --version` -ge 202 || { \
echo "You need VgaGames version 2.02 or higher"; \
exit 1; \
}
|
CFLAGS = -O2 # two new variables, we assume version of VgaGames is 2.02 VGAG_SOURCEPATH = share/vgagames-2.02/src VGAG_PATH = share/vgagames/bin # make game: at first install VgaGames, then make your game, using VGAG_PATH mygame: vgagames-install main.c game.c $(CC) $(CFLAGS) `$(VGAG_PATH)/vgag2-config --cflags` -o mygame main.c game.c `$(VGAG_PATH)/vgag2-config --libs` # install VgaGames (using parameter "-local") vgagames-install: (cd $(VGAG_SOURCEPATH) && ./config.sh -local && make all install) # clean: uninstall VgaGames and make clean clean: vgagames-uninstall rm -f *.o mygame share/.vgag2.rc # uninstall VgaGames vgagames-uninstall: (cd $(VGAG_SOURCEPATH) && make uninstall clean) |