Mail Archives: djgpp/1998/01/24/03:30:57
From: | jromano AT slate DOT Mines DOT EDU (Jean-Luc Romano)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | fade_out()
|
Date: | 24 Jan 1998 08:12:48 GMT
|
Organization: | Colorado School of Mines
|
Lines: | 113
|
Message-ID: | <6ac7q0$j2c$1@herald.Mines.EDU>
|
NNTP-Posting-Host: | slate.mines.edu
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Dear All,
When programming in C using DJGPP and the Allegro graphics
library, the fade_out() routine only seems to work once.
The second fade_out() routine will only work if the first
fade_out() routine has been commented out.
Try compiling my code below if you have trouble understanding
what I mean (the last fade_out() is in the third line from the
bottom).
Any suggestions? Thanks in advance.
Jean-Luc Romano
/*
* "Moving the Moon"
* by Jean-Luc Romano (jromano AT mines DOT edu)
* http://www.mines.edu/students/j/jromano/
* My first attempt at game programming, so don't laugh.
* Use the arrow keys and/or the joystic to control the moon.
* ESC key quits.
* The last fade_out() doesn't seem to work. Any ideas?
* Special thanks to: DJ Delorie and Shawn Hargreaves
*/
#include <stdio.h>
#include <allegro.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define PIXELMOVE 5
/* Function prototype(s): */
void main_code(void);
int main(void)
{
allegro_init();
install_keyboard();
if (initialise_joystick())
{
printf("Could not detect joystick.\n");
}
/*
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL))
{
printf("Install_sound failed to work.\n");
exit(1);
}
*/
install_timer();
main_code();
clear_keybuf();
allegro_exit();
return 0;
}
void main_code(void)
{
int i, j; /* counter(s) -- nothing more */
int radius;
int colour;
BITMAP* temp_bitmap = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT);
BITMAP* bgmap = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT);
/*
MIDI *the_music = load_midi("CANYON.MID");
play_midi(the_music, TRUE);
*/
fade_out(3); /* first use of fade_out() -- this works just fine */
set_gfx_mode(GFX_AUTODETECT, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
clear(screen);
clear_to_color(temp_bitmap, 0);
radius = 100;
circlefill(temp_bitmap, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, radius, 14);
text_mode(-1);
textout_centre(temp_bitmap, font, "Watch for werewolves!", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 9);
i = j = colour = 0;
while(!key[KEY_ESC])
{
poll_joystick();
if (key[KEY_UP] || joy_up)
j -= PIXELMOVE;
if (key[KEY_DOWN] || joy_down)
j += PIXELMOVE ;
if (key[KEY_RIGHT] || joy_right)
i += PIXELMOVE;
if (key[KEY_LEFT] || joy_left)
i -= PIXELMOVE;
clear_to_color(bgmap, colour);
blit(temp_bitmap, bgmap, SCREEN_WIDTH / 2 - radius, SCREEN_HEIGHT / 2 - radius, SCREEN_WIDTH / 2 - radius + i, SCREEN_HEIGHT / 2 - radius + j, radius * 2, radius * 2);
blit(bgmap, screen, 0, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
vsync();
}
/*
stop_midi(the_music);
destroy_midi(the_music);
*/
fade_out(3); /* This fade_out doesn't seem to work. Any ideas? */
return;
}
- Raw text -