Sign in to follow this  

Allegro Startout

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> 


volatile long speed_counter = 0; 

void increment_speed_counter() 

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


	install_int_ex(increment_speed_counter, BPS_TO_TIMER(60)); 
	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;
       c = getc(arq);     
       mapa[xm] = c;   
		while(xm >= 0)
                       if(mapa[xm] == '1')
                         draw_sprite(buffer, tile, tilex, tiley);
                       if(mapa[xm] == '2')
                         draw_sprite(buffer, tile2, tilex, tiley);
                       tilex += 32;
		blit(buffer, screen, 0,0,0,0,640,480); 
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this