please help =) tilebased map ...
ok, here i come... with sort of a dumb question :
hmmm, how to tell my problem...
well, i want to make a tiny tilebased program like pacman
the problem is that i dont know how to make the map routine!
i want a routine which looks like this :
#define GRASS 0 //i use different graphics for
#define STONE 1 //every ground structure, of course =)
#define WATER 2 //
#define PLAYER 3 //
int map_load()
{
int map[5][5] = { //now a simple map...
{0,0,0,1,1}, //with the defined elements
{0,1,2,0,0},
{0,1,2,2,2},
{1,1,0,0,2},
{3,0,0,2,2}
}
//BUT WHAT HAS TO BE HERE???
//i want the map to be displayed on the screen with a
//for-routine(for(x=0;....)
//
}
HOW(!!!) do i do that ?
i have made some simple graphics already, and im using the DJGPP compiler with the ALLEGRO game library
who can post some code???
thx, Freddy
Well first i will need to copy the 'tiles' to the 'backbuffer-surface' which you later 'flip' with the 'primary-surface'.
I don't know allegro. And i am a kind of noobee myself but i guess the loop must look like:
copy_bitmap_to_backsurface(char * texture,int tile_height,int tile_height,int tile_nr)
{
}
for(int x=0;x<5;x++)
for(int y=0;y<5;y++)
{
copy_bitmap_to_backsurface("myCrazyBMP",48,48,map[x][y]);
}
flip_surface();
I don't know how the copy_bitmap_to_backsurface function must look in your program and how to implement it with allegro.
Edited by - Jonus on August 1, 2001 7:03:18 AM
I don't know allegro. And i am a kind of noobee myself but i guess the loop must look like:
copy_bitmap_to_backsurface(char * texture,int tile_height,int tile_height,int tile_nr)
{
}
for(int x=0;x<5;x++)
for(int y=0;y<5;y++)
{
copy_bitmap_to_backsurface("myCrazyBMP",48,48,map[x][y]);
}
flip_surface();
I don't know how the copy_bitmap_to_backsurface function must look in your program and how to implement it with allegro.
Edited by - Jonus on August 1, 2001 7:03:18 AM
thx...
i tried it that way u described, but it doesnt work
i think i has to be done anything like this(with arrays in a array )
FOR(x=0;x<5;x++)
FOR(y=0;y<5;y++)
copy_bitmap_to_backsurface(BITMAP[bmp],height,widht,...)
i got problems finding out which bitmap the program has to load(water, stone, player, grass, etc)
i shall work like a parser, or something like that...
the program ''reads'' the map structure and then ''prints'' the bitmap on the screen
copy_bitmap_to_backsurface(bitmap[map[x][y]],...) perhaps like that...
cheers, freddy
i tried it that way u described, but it doesnt work
i think i has to be done anything like this(with arrays in a array )
FOR(x=0;x<5;x++)
FOR(y=0;y<5;y++)
copy_bitmap_to_backsurface(BITMAP[bmp],height,widht,...)
i got problems finding out which bitmap the program has to load(water, stone, player, grass, etc)
i shall work like a parser, or something like that...
the program ''reads'' the map structure and then ''prints'' the bitmap on the screen
copy_bitmap_to_backsurface(bitmap[map[x][y]],...) perhaps like that...
cheers, freddy
Yup you got it the Bmp[map[y][x]] will work to find out what graphic to draw at that location! Also I think there are some decent windows compilers out there I would switch to direct draw or direct 3d or opengl. More compatible and I personally think easier to use! Dunno if you have done any windows programming before but its scary looking at first but not that bad everything is the same just has different names plus you''ll save yourself a headache I think I tried to write a decent tile engine using allegro(isn''t that also hair growth stuff?)and boy that wasn''t fun! Opengl which I prefer after working with Direct Draw (havent tried D3d yet) is pretty easy to do 2d in and 3d one you set up the main windows loop and setup the window and stuff...you dont have to worry about it anymore and focus on logic also Direct Input is a wonderul API! Microsoft will make it so you have to conform sooner or later so why not now!
thx derilect!
i tried to do it like i guessed... but it does only print one bitmap, even if i make a map with another structure...
but u told me to use openl.. i know that it is the 'best' api but i even dont understand the main loop to init opengl
could u give me some hints where to begin coding in opengl??
and can u give me some hints what compiler i could use then... dont tell me to use microsoft visual c++
most likely i would like to code opengl with LCC if u know this one...
cheers
Edited by - _Hybrid_ on August 1, 2001 8:07:38 AM
i tried to do it like i guessed... but it does only print one bitmap, even if i make a map with another structure...
but u told me to use openl.. i know that it is the 'best' api but i even dont understand the main loop to init opengl
could u give me some hints where to begin coding in opengl??
and can u give me some hints what compiler i could use then... dont tell me to use microsoft visual c++
most likely i would like to code opengl with LCC if u know this one...
cheers
Edited by - _Hybrid_ on August 1, 2001 8:07:38 AM
Why don''t you want to use VC++? Everyone uses it, and despite the fact that its Microsoft, it is the industry standard.
VC++ happens to be one of the only good programs Microsoft has ever made, you should at least give it a go ;-)
If you want a compiler recommendation I highly recommend Borland''s compiler. It makes a leaner and usually fast executable than MSVC++. Visual C++ is a bit too bloated and slow for my tastes, however it''s IDE is usually better than Borland''s. I personally use Borland C++ Builder 5 and I love it. It strips out all the dead code from the compiled EXE, but it''s IDE is a bit buggy at times I have found.
The Borland compiler is also free for download. It is just the compiler though, there''s no interface to it.
Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.
The Borland compiler is also free for download. It is just the compiler though, there''s no interface to it.
Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.
quote:Original post by _Hybrid_
I tried it that way u described, but it doesnt work
i think i has to be done anything like this(with arrays in a array )
FOR(x=0;x<5;x++)
FOR(y=0;y<5;y++)
copy_bitmap_to_backsurface(BITMAP[bmp],height,widht,...)
No i don''t think that your problems are related to the map structure or the for-loop.(btw why is FOR capitalized?)
quote:Original post by _Hybrid_
I got problems finding out which bitmap the program has to load(water, stone, player, grass, etc)
Which bitmap? First, all your map-tiles should be on in ONE bmp-file. And then you can make something like:
struct stiles
{
flaot x1,x2,y1,y2;
}
sTiles MAP_TILES[5];
// Then init the array with coorrect source coordiantes
quote:Original post by _Hybrid_
i shall work like a parser, or something like that...
the program ''reads'' the map structure and then ''prints'' the bitmap on the screen
copy_bitmap_to_backsurface(bitmap[map[x][y]],...) perhaps like that...
This function should look like:
copy_bmp(sTiles & source_rect,target_x,target_y,nummber)
{
}
Yeah the reason ya got only 1 bitmap is because you need move move them over or you''ll just keep drawing one on top of the other so just keep track of your x and y locations so first tile lets say draws from 0-31 on the x and 0-31 on the y. for the next tile start at 32-64 on the x and keel 0-31 on the y until you have to draw the next row and so on
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement