Vgagames: General terms and compiling:
======================================

 

vgagames is a package of libraries, servers and programs for use of coding
vga based games (320x200 with 256 colors) with different graphic libraries.

Currently are supported:
 - svgalib  (Linux)
 - libvgl   (FreeBSD)
 - X window (XFree86,Xorg)

Your game program code however is the same for any of these libraries.



The library contains functions for:
-----------------------------------

 - graphical output
 - drawing and manipulating graphics
 - keyboard and mouse functions
 - sound functions (wave, midi and mp3)
 - multiplayer support via tcp/ip


Installing the vgagames package:   see file "0-INSTALL".
--------------------------------


Coding your game program with the vgagames library:
---------------------------------------------------

 - include header file <vgagames.h> into your program
 - in your main function you have to do:
    + some initialization:
       * switching to graphic mode or opening a window with: open_window()
       * if needed starting sound server with: init_sound()
       * if needed starting the network server with: start_nettcp()
       * if needed connecting to a started network server with: connect_nettcp()
    + your playing loop with the other vgagames functions
    + ending:
       * if needed closing network connection with: close_nettcp()
       * if needed exiting sound server with: end_sound()
       * switching to text mode or closing window with: close_window()

If a vgagames function returns with an error, the error message is in the
global variable: char errmsg[].
For example programs see directory "example".


Compiling your game program:
----------------------------

For compilation there are needed some system libraries. When vgagames is
installed, a config script "vgag-config.sh" is installed in /usr/bin.

To test whether the needed version of vgagames is installed,
use vgag-config.sh with option -v, which gives you the version as a number:
  vgag-config.sh -v    echoes (e.g. for version 1.10): "110" 

***** Usage for compiling:
 - first check whether a console library or X window devel library is installed
   (vgag-config.sh <-cons | -x>)
 - then compile
   (vgag-config.sh <-cons | -x> "<game source file(s)>")
 --> e.g.
  # for console libraries
  if vgag-config.sh -cons
  then
    gcc -Wall -O2 `vgag-config.sh -cons game.c` -o game-cons
    chmod 4755 game-cons  # setuid root bit
  fi
  # for X window
  if vgag-config.sh -x
  then
    gcc -Wall -O2 `vgag-config.sh -x game.c` -o game-x
  fi


If you want to compile more than one file, put them together into quotation
marks, e.g.:  gcc -Wall -O2 `vgag-config.sh -cons "game1.c game2.c"` -o game

***** There is also another usage "vgag-config.sh":
  vgag-config.sh wave-midi [<M|S> <samplefrequence> <midi file>]
With these parameters a midi file can be converted to a wave file.
To check whether midi-to-wave-converter is installed, use:
  vgag-config.sh wave-midi
for example: "if vgag-config.sh wave-midi; then ... ; fi"
To convert a midi to wave, use:
  vgag-config.sh wave-midi <M|S> <samplefrequence> <midi file>
for example: "vgag-config.sh wave-midi M 11025 ../jb.mid"
             --> creates mono (M), 11025 samplefrequence, wave file ../jb.wav

And with "vgag-config.sh wave-mp3 [...]" you can convert a mp3 file to a wave
file.

A short description is given when calling vgag-config.sh without parameters.


Now an example for a Makefile of game "mygame":
   # Makefile for mygame
   #CC = gcc
   CFLAGS = -Wall -O2
   GAME=mygame

   all: clean $(GAME)-cons $(GAME)-x

   clean:
        rm -f *.o $(GAME)-cons $(GAME)-x

   # console graphic library game
   $(GAME)-cons: testlib $(GAME).c $(GAME).h
        if vgag-config.sh -cons; then \
          $(CC) $(CFLAGS) `vgag-config.sh -cons $(GAME).c` -o $(GAME)-cons; \
          chmod 4755 $(GAME)-cons; \
        fi

   # X window graphic library game
   $(GAME)-x: testlib $(GAME).c $(GAME).h
        if vgag-config.sh -x; then \
          $(CC) $(CFLAGS) `vgag-config.sh -x $(GAME).c` -o $(GAME)-x; \
        fi

   # check vgagames library version, must be >= 1.10 for mygame
   testlib: 
        @if ! vgag-config.sh -v || [ `vgag-config.sh -v` -lt 110 ]; then \
          echo "Sorry, you need at least vgagames version 1.10"; \
          exit 1; \
        fi



 

Home | Previous: Index | Next: Initializing and ending functions