Jump to content
  • Advertisement
Sign in to follow this  
MadHippie

Allegro Startout

This topic is 3028 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. This is my first try with allegro, im willing to make a simple 1 dimension tile map in the screen based on a .txt file. This is the code i have so far:
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h> 


END_OF_FUNCTION(desenhamapa); 


volatile long speed_counter = 0; 

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

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, *tile, *tile2; 
	my_pic = load_bitmap("neguim.bmp", NULL); 
	tile = load_bitmap("tile1.bmp", NULL); 
	tile2 = load_bitmap("tile2.bmp", NULL); 
	
	BITMAP *buffer; 
	
	buffer = create_bitmap(640,480); 
	
	char mapa[10];		
    int xm = 0;
    FILE *arq;
    arq = fopen("data.txt", "r");
    char c;
    int tilex, tiley;
    tilex = 50; tiley = 50;
    
    while(!feof(arq))
    {
       c = getc(arq);     
       mapa[xm] = c;   
       xm++;          
    }
		
		while(xm >= 0)
		{
                       if(mapa[xm] == '1')
                         draw_sprite(buffer, tile, tilex, tiley);
                       if(mapa[xm] == '2')
                         draw_sprite(buffer, tile2, tilex, tiley);
                       xm--;
                       tilex += 32;
                }
		blit(buffer, screen, 0,0,0,0,640,480); 
		clear_bitmap(buffer);
} 
	
This is part of the code that shows how the simple mapping should be done. But it aint working. The tiles aint showing. The idea is to add the tile map into tha buffar to make it scrollable. This is my first tryout to make a simple map system. I know there are some already done , but i wish to make all by myself so thats how i can learn. Thanx for any help. []´s

Share this post


Link to post
Share on other sites
Advertisement
is this so noobish that no one doesnt even know ? i see more ppl using SDL then Allegro, wish to know why is that. Is SDÇ better then allegro ? I couldnt find any good tutorials for it that i could start out playng on it.

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!