Mail Archives: djgpp/1998/11/21/11:41:26
| From: | Daniel Bardsley <daniel DOT bardsley AT dial DOT pipex DOT com> | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Help Needed with spotlight effects. | 
| Date: | Sat, 21 Nov 1998 16:37:26 +0000 | 
| Organization: | UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom) | 
| Lines: | 123 | 
| Message-ID: | <3656EC46.5EB99441@dial.pipex.com> | 
| NNTP-Posting-Host: | userm496.uk.uudial.com | 
| Mime-Version: | 1.0 | 
| X-Mailer: | Mozilla 4.5b2 [en] (Win95; I) | 
| X-Accept-Language: | en | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
***  I posted this before but forgot to attach the source. (Doh!) ***
Hey,
I'm pretty new to djgpp and Allegro.  I'm just messing about with the
functions to see what they can do etc.  I thought ex24 (the spotlight
effect) was pretty cool so I tried to implement it in a simple program.
I also thought it would look good with two spot lights so I set this up
but I need the two lights to cross and when this happens the unmasked
square is visable.  Is there anyway around this?  I may have confused
some of you here so I've include the sample program below take a look
and please help me if you can......
E-Mail any responce to me at daniel DOT bardsley AT dial DOT pipex DOT com because I
don't read this news group often.  Thanks in advance.
Daniel Bardsley
CODE IS AS FOLLOWS:
/*  Spotlight on a 32-bit backdrop */
/* Created by Daniel Bardsley */
/* Last updated: 21-Nov-98 */
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include "allegro.h"
RGB_MAP rgb_table;
COLOR_MAP light_table;
COLOR_MAP trans_table;
/* Progress indicator for the color table calculations. */
void callback_func()
{
 putch('.');
}
int main()
{
 PALLETE pal;
 BITMAP *s;
 BITMAP *s2;
 BITMAP *spotlight;
 BITMAP *spotlight2;
 BITMAP *background;
 int i, x, y;
 int x2, y2;
 char buf[80];
 char *filename;
 allegro_init();
 install_keyboard();
 install_mouse();
 /* Load the main image to screen */
 strcpy(get_filename(buf), "bardsley.bmp");
 filename = buf;
 background = load_bitmap(filename, pal);
 if(!background)
 {
  printf("Error reading %s!\n", filename);
  return 1;
 }
 /* Generate color tables etc. */
 printf("Generating RGB TAble (3.25 lines to go)\n");
 create_rgb_table(&rgb_table, pal, callback_func);
 rgb_map = &rgb_table;
 printf("\nGenerating Lighting table (3.25 lines to go)\n");
 create_light_table(&light_table, pal, 0, 0, 0, callback_func);
 printf("\nGenerating Transparancy Table (3.25 lines to go)\n");
 create_trans_table(&trans_table, pal, 128, 128, 128, callback_func);
 set_gfx_mode(GFX_VESA1, 800, 600, 0, 0);
 set_pallete(pal);
 s = create_bitmap(800,600);
 spotlight = create_bitmap(256,256);
   spotlight2 = create_bitmap(256, 256);
 /* Generate spotlight images */
 clear(spotlight);
   clear(spotlight2);
 for(i=0; i<256; i++)
 {
  circlefill(spotlight, 128, 128, 128-i/2, i);
  circlefill(spotlight2, 128, 128, 128-i/2, i);
 }
 /* select the lighting table */
 color_map = &light_table;
 /* Display spotlight effect */
 y = 150;
 y2 = 150;
   x2 = 800;
 for(x=-256; x< 800; x++)
 {
  x += 4;
  x2 -= 5;
  if(keypressed())
   exit(0);
  clear(s);
  blit(background, s, x, y, x, y, 256, 256);
  draw_trans_sprite(s, spotlight, x, y);
  blit(background, s, x2, y2, x2, y2, 256, 256);
  draw_trans_sprite(s, spotlight2, x2, y2);
  blit(s, screen, 0, 0, 0, 0, 800, 600);
 }
 destroy_bitmap(s);
 destroy_bitmap(spotlight);
 destroy_bitmap(background);
 return 0;
}
- Raw text -