# Allegro Startout

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

## 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;

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 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.