My level map data is in a .txt file e.g which gets compiled. but I want to put the level data in my datafile.dat, making it more compacked.
const short leve2_blocks_map[9087] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 8}
I want to have this as a data file as 1111111111111111118888, which i'll use a pointer to access the correct data in the file.
I using mappy for may maps, jsut a binary file type would do.
Can any one recommend a differant map editor or a simple program to convert one to the other.
If not i'll write one my self.
Thanks
John.
Hi John.
On the Mappy web-page, you can download some code to display Mappy maps in an Allegro program.
Alternatively, mappy lets you write exporters in Lua so you can get it to export it's data in whatever format you want.
AE.
I found one called hd.exe, it outputs to binary file, works a treat.
Thanks for the help.
john.
why not just write your own
This is assuming that the text file reads as a series of numbers
e.g. 11235411111118888
1 | // not tested |
2 | #include <allegro.h> |
3 | |
4 | void output( PACKFILE *in, PACKFILE *out ) |
5 | { |
6 | while ( !pack_feof( in ) ) |
7 | { |
8 | // if the values are only 0 to 9 |
9 | packputc( packgetc( in ) - '0', out ); |
10 | |
11 | else |
12 | //packputc( packgetc( in ), out ); |
13 | } |
14 | } |
15 | |
16 | int main( int argc, char **argv ) |
17 | { |
18 | PACKFILE *in = NULL; |
19 | PACKFILE *out = NULL: |
20 | |
21 | if ( argc == 3 ) |
22 | { |
23 | if ( in = pack_fopen( argv[ 1 ], "r" ) ) |
24 | { |
25 | if ( out = pack_fopen( argv[ 2 ], "wb" ) ) |
26 | { |
27 | output( in, out ); |
28 | pack_fclose( out ); |
29 | } |
30 | pack_fclose( in ); |
31 | } |
32 | } |
33 | |
34 | return 0; |
35 | } |
36 | END_OF_MAIN() |
Did something differant,
Converted the txt level_1.txt to binary level_1.raw , no problem.
Loaded it into my paint program as raw data (231 x 40)
Saved it as a level_1.bmp as run length encoding , went down from 10k to 3k, great.
Imported it into allegro grabber.
Not only do i have it as data and its smaller, but i can see the data as it should be.
I have a quick way of using bitmap data as level data.
Create a small BITMAP* 231 BY 41, as a buffer area.
Value = GETPIXEL(x,y) of buffer area or something like that.