Videojocs amb Allegro

De Wikijoan
Dreceres ràpides: navegació, cerca

Contingut

Referències i tutorial

Tutorial:

Instal.lació synaptic (v4.2)

instal.lo liballegro4.2, liballegro4.2-dev, els exemples, i liballegro4.2-plugin-jack (JACK audio plugin)

els exemples del paquet allegro-examples estan a /usr/bin/allegro-examples

Integració amb JACK (TBD)

Mirant el synaptic he vist el paquet: liballegro4.2-plugin-jack: JACK audio plugin for the Allegro library

Instal.lació SVN (v4.9)

$ mkdir /usr/share/allegro
$ cd /usr/share/allegro
$ svn co https://alleg.svn.sourceforge.net/svnroot/alleg/allegro/branches/4.9

README_make.txt discusses compilation with GNU make. This applies to Unix-like operating systems such as Linux, MacOS X and MinGW on Windows.

Linux users likely have all the dependencies already, except PhysicsFS
and DUMB. If your distribution uses separate development packages, they
will need to be installed.  The packages are probably named *-dev or *-devel.

These are the dependencies required for the addons:

- libpng and zlib, for PNG image support (Unix and older MinGW only)
  Home page: <http://www.libpng.org/pub/png/>
  Windows binaries: <http://gnuwin32.sourceforge.net/packages/libpng.htm>

- libjpeg, for JPEG image support (Unix and older MinGW only)
  Home page: <http://www.ijg.org/>
  Windows binaries: <http://gnuwin32.sourceforge.net/packages/jpeg.htm>

- FreeType, for TrueType font support.
  Home page: <http://freetype.sourceforge.net/>
  Window binaries: <http://gnuwin32.sourceforge.net/packages/freetype.htm>

- Ogg Vorbis, a free lossy audio format. (libogg, libvorbis, libvorbisfile)
  Home page: <http://www.vorbis.com/>

- FLAC, a free lossless audio codec. (libFLAC, libogg)
  Home page: <http://flac.sourceforge.net/>

- DUMB, an IT, XM, S3M and MOD player library. (libdumb)
  Home page: <http://dumb.sourceforge.net/>

- OpenAL, a 3D audio API.
  The audio addon can use OpenAL, although the 3D capabilities aren't used.
  <http://kcat.strangesoft.net/openal.html>

Anem a instal.lar-ho:

$ cd /usr/share/allegro (és on he descomprimit l'Allegro)
$ sudo mkdir Build (és on s'instal.larà)
$ cd Build
$ sudo cmake ..

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
...
-- Looking for sys/types.h
...
-- Looking for getexecname
...
-- Performing Test ALLEGRO_HAVE_PROCFS_ARGCV
-- Performing Test ALLEGRO_HAVE_PROCFS_ARGCV - Failed
-- Performing Test ALLEGRO_HAVE_SV_PROCFS_H
-- Performing Test ALLEGRO_HAVE_SV_PROCFS_H - Failed
-- Performing Test ALLEGRO_HAVE_VA_COPY
-- Performing Test ALLEGRO_HAVE_VA_COPY - Success
...
-- checking for module 'alsa'
--   found alsa, version 1.0.23
-- Could NOT find FLAC  (missing:  FLAC_INCLUDE_DIR OGG_LIBRARY FLAC_LIBRARY)
WARNING: libFLAC not found, disabling support.
-- Could NOT find DUMB  (missing:  DUMB_INCLUDE_DIR DUMB_LIBRARY)
WARNING: libdumb not found, disabling support. <http://dumb.sourceforge.net/>
-- Could NOT find VORBIS  (missing:  OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY)
WARNING: libvorbis not found, disabling support.
-- Found Freetype: /usr/lib/libfreetype.so
-- Could NOT find PHYSFS  (missing:  PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
-- checking for module 'gtk+-2.0'
--   found gtk+-2.0, version 2.20.1
-- checking for module 'gthread-2.0'
--   found gthread-2.0, version 2.24.2
-- Not building ex_physfs
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/share/allegro/Build

es genera el Build, i es veu les llibreries que tinc i les que no tinc. S'ha generat el Makefile:

$ sudo make
$ sudo make install

S'instal.la bé i ja puc veure algunes demos

$ /usr/share/allegro/Build/demos/speed
$ ./speed

i els exemples de codi (els binaris) i els codis font corresponents estan a:

$ cd /usr/share/allegro/Build/example (binaris)
$ cd /usr/share/allegro/examples (codis font)

Ja puc compilar el projecte més senzill:

main.cpp:

#include <allegro.h>



int main()

{

    allegro_init();
    install_keyboard();
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0);
    textout_centre_ex(screen, font, "Hello, World!", 160, 100, makecol(255, 255, 255), -1);
    readkey();
    return 0;

}
g++ main.cpp -o main `allegro-config --static`

The program 'allegro-config' is currently not installed.  You can install it by typing:
$ sudo apt-get install liballegro4.2-dev

però clar, de fet t'instal.la allegro4.2 quan de fet jo tinc instal.lat ara la versió 4.9

g++ main.cpp -o main `allegro-config --static`

i ara ja compila i s'executa el codi més simple.

Les llibreries estan a /usr/local/include/allegro5/. Per exemple, anem a compilar l'exemple ex_blit.c

No compila, però no és un problema de què no trobi la ruta /usr/local/include/allegro5/

Eines de l'usuari
Espais de noms
Variants
Accions
Navegació
IES Jaume Balmes
Màquines recreatives
CNC
Informàtica musical
joanillo.org Planet
Eines