Jump to content
  • Advertisement
Sign in to follow this  
polisasimo

Allegro progress .... followed by questions

This topic is 4804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone here is the progress I have made so far using the allegro game library and a couple of sprites
#define USE_CONSOLE
#include <allegro.h> 
//Global
volatile long speed_counter = 0;
//Speed counter increment function

int detect_digi_driver(int driver_id);
int detect_midi_driver(int driver_id);
int install_sound(int digi, int midi, const char *cfg_path);


void increment_speed_counter() 
{
  speed_counter++; 
}
END_OF_FUNCTION(increment_speed_counter);
void initialise_all();

int main(int argc, char *argv[])
{

	initialise_all();
	BITMAP *my_pic1 = load_bitmap("dk1.bmp", NULL);
	BITMAP *my_pic2 = load_bitmap("dk2.bmp", NULL);
	BITMAP *my_pic3 = load_bitmap("dk3.bmp", NULL);
	BITMAP *buffer; 
	buffer = create_bitmap(640,480); 
	int my_pic_x = 0, my_pic_y = 0, frame_counter = 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 --;
				frame_counter ++;
				if(frame_counter > 240)
				{
				frame_counter = 0;
				}

		}
	acquire_screen();	
	if(frame_counter < 60)
		{
		draw_sprite(buffer, my_pic1, my_pic_x, my_pic_y);
				}
	else if(frame_counter >= 60 && frame_counter < 120)
		{
		draw_sprite(buffer, my_pic2, my_pic_x, my_pic_y);		
		}
	else if(frame_counter >= 120 && frame_counter < 180)
		{
		draw_sprite(buffer, my_pic1, my_pic_x, my_pic_y);
				}
	else
		{
		draw_sprite(buffer, my_pic3, my_pic_x, my_pic_y);
		}
	blit(buffer, screen, 0,0,0,0,640,480);
	clear_bitmap(buffer);
	release_screen();
	}
	destroy_bitmap(my_pic1);
	destroy_bitmap(my_pic2);
	destroy_bitmap(my_pic3);
	destroy_bitmap(buffer);//Release the bitmap data 
	return(0);
}
END_OF_MAIN(); 

void initialise_all()
{
	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(24); 						
	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); 

}

this is basically a short animation involving donkey kong. Anyway, just wondering if anyone has a link to a good sound tutorial and or, using transparent sprites. (laimans terms whenever I use the keypad to move my_pic1 over another spite bitmap my_pic1..2..3 will basicly overwrite the other sprite) I am hoping to display another bitmap as a backround. Thanks for the advice and please feel free to critisize the code.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!