View Single Post
Old 07-24-2006, 01:51 AM   #1 (permalink)
naruto1327
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default I need help with Allegro

Code:
#include <allegro.h>
void increment_speed_counter();
volatile long speed_counter = 0;
int main(int argc, char *argv[])
{
 	allegro_init();
 	install_keyboard();
 	install_timer();
	LOCK_VARIABLE(speed_counter);
	LOCK_FUNCTION(increment_speed_counter);
	install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
	BITMAP *my_pic;
	my_pic = load_bitmap("image.bmp", NULL);
	BITMAP *buffer;
	buffer = create_bitmap(640,480);
	int my_pic_x = 0;
	int my_pic_y = 0;
	while(!key[KEY_ESC])
	{
		while(speed_counter > 0)
		{
			if(key[KEY_RIGHT])
			{
			my_pic_x++;
			}
			else if(key[KEY_LEFT])
			{
			my_pic_x--;
			}
			else if(key[KEY_UP])
			{
			my_pic_y--; 
			}
			else if(key[KEY_DOWN])
			{
			my_pic_y++;
			}
			speed_counter--;
		}
		draw_sprite(buffer, my_pic, my_pic_x, my_pic_y);
		blit(buffer, screen, 0,0,0,0,640,480);
		clear_bitmap(buffer);
	}
	destroy_bitmap(my_pic);
	destroy_bitmap(buffer);
	return 0;
}
END_OF_MAIN();
void increment_speed_counter()
{
	speed_counter++;
}
END_OF_FUNCTION(increment_speed_counter);
This is the main.cpp file.
The file "image.bmp" DOES exist, but nothing shows up. Just blackness...

Whats wrong?

Last edited by naruto1327; 07-24-2006 at 01:53 AM.
naruto1327 is offline