Code Search for Developers
 
 
  

expal.c from Allegro game programming library at Krugle


Show expal.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This program demonstrates how to manipulate the palette. It draws
 *    a set of concentric circles onto the al_screen and animates them by
 *    cycling the palette.
 */


#include "allegro.h"



int main()
{
   AL_PALETTE palette;
   AL_RGB temp;
   int c;

   allegro_init();
   al_install_keyboard(); 
   if (al_set_gfx_mode(AL_GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
      if (al_set_gfx_mode(AL_GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
	 al_show_message("Error setting graphics mode\n%s\n", al_error);
	 return 1;
      }
   }

   /* first set the palette to black to hide what we are doing */
   al_set_palette(al_black_palette);

   /* draw some circles onto the al_screen */
   al_acquire_screen();

   for (c=255; c>0; c--)
      al_draw_circle_fill(al_screen, AL_SCREEN_W/2, AL_SCREEN_H/2, c, c);

   al_release_screen();

   /* fill our palette with a gradually altering sequence of colors */
   for (c=0; c<64; c++) {
      palette[c].r = c;
      palette[c].g = 0;
      palette[c].b = 0;
   }
   for (c=64; c<128; c++) {
      palette[c].r = 127-c;
      palette[c].g = c-64;
      palette[c].b = 0;
   }
   for (c=128; c<192; c++) {
      palette[c].r = 0;
      palette[c].g = 191-c;
      palette[c].b = c-128;
   }
   for (c=192; c<256; c++) {
      palette[c].r = 0;
      palette[c].g = 0;
      palette[c].b = 255-c;
   }

   /* animate the image by rotating the palette */
   while (!al_key_pressed()) {
      temp = palette[255];
      for (c=255; c>0; c--)
	 palette[c] = palette[c-1];
      palette[0] = temp;
      al_set_palette(palette);
   }

   return 0;
}

AL_END_OF_MAIN();




See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  allegro.pcx
  ex12bit.c
  ex3buf.c
  ex3d.c
  exaccel.c
  exalpha.c
  example.dat
  example.h
  examples.txt
  exbitmap.c
  exblend.c
  excamera.c
  excolmap.c
  excustom.c
  exdata.c
  exdbuf.c
  exdodgy.c
  exexedat.c
  exfixed.c
  exflame.c
  exflip.c
  exgui.c
  exhello.c
  exjoy.c
  exkeys.c
  exlights.c
  exmem.c
  exmidi.c
  exmouse.c
  expal.c
  expat.c
  exquat.c
  exrgbhsv.c
  exsample.c
  exscale.c
  exscn3d.c
  exscroll.c
  exshade.c
  exspline.c
  exsprite.c
  exstars.c
  exstream.c
  exswitch.c
  extimer.c
  extrans.c
  extruec.c
  exunicod.c
  exupdate.c
  exxfade.c
  exzbuf.c
  mysha.pcx
  planet.pcx
  running.dat
  running.h
  unifont.dat