The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Square Map

From Allegro Wiki
Jump to: navigation, search
Documentation.png
This code snippet requires documentation. If you understand how this code is intended to be used, please help Allegro by documenting it. Once the snippet is fully documented, you may remove this tag.


This article has been proposed for deletion.

  • Reason: Doesn't seem reusable and lacks any documentation.
  • Marked by: CGamesPlay 18:07, January 4, 2008 (UTC)

This article may be removed if the voting approves the decision. To discuss the deletion of this page, use Talk:Square Map.


Code

Tiless.png <highlightSyntax language="cpp"> int map[30][20]= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,10,10,15,10,10,11,10,10,11,11,10,10,11,10,10,15,10,10,21, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,22, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,22, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,23, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,22, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,22, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,22,

19, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0,23,
20, 0, 0, 0, 0, 7, 0, 0, 7, 7, 7, 7, 0, 0, 7, 0, 0, 0, 0,24,
18, 0, 0, 0, 0, 7, 0, 0, 7, 7, 7, 7, 0, 0, 7, 0, 0, 0, 0,22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 0: x=0; y=16*4; break;//background

case 1: x=0; y=0; break;//pink case 2: x=32*1; y=0; break;//brown case 3: x=32*2; y=0; break;//blue case 4: x=32*3; y=0; break;//grey case 5: x=32*4; y=0; break;//green case 6: x=32*5; y=0; break;//white case 7: x=0; y=16*1; break;//orange case 8: x=0; y=16*2; break;//red case 9: x=0; y=16*3; break;//yellow

case 10: x=32*1; y=16*0; break;//thin horizontle

case 11: x=32*2; y=16*0; break;//thick horizontle** case 12: x=32*3; y=16*0; break;//thick horizontle light case 13: x=32*3; y=16*2; break;//thick horizontal light dark case 14: x=32*3; y=16*1; break;//thick horizontal light light dark case 15: x=32*2; y=16*2; break;//thick horizontal dark case 16: x=32*3; y=16*2; break;//thick horizontal light dark

case 17: x=32*0; y=16*0; break;//left turn case 18: x=32*0; y=16*1; break;//thin vertical left case 19: x=32*0; y=16*2; break;//thick vertical left up case 20: x=32*0; y=16*3; break;//thick vertical left down

case 21: x=32*4; y=16*0; break;//right turn case 22: x=32*4; y=16*1; break;//thin vertical right case 23: x=32*4; y=16*2; break;//thick vertical right up case 24: x=32*4; y=16*3; break;//thick vertical right down } }

void drawmap() { for(int i=0;i<30;i++) for(int j=0;j<20;j++) { if (map[i][j]>=0 && map[i][j]<=9) { mapvalue(map[i][j]);//x and y is set from mapvalue blit((BITMAP*)dataGrafics[tile].dat,grid,x,y,j*32,i*16,32,16); } else if(map[i][j]>=10 && map[i][j]<=24) { mapvalue(map[i][j]);//x and y is set from mapvalue blit((BITMAP*)dataGrafics[wall].dat,grid,x,y,j*32,i*16,32,16); } }

blit(grid,buffer,0,0,0,0,SCREEN_W,SCREEN_H); }

void load_map() { FILE *files;

char text[30]; char mapfolder[6]="Maps\\";

sprintf(text,"%s%d",mapfolder,mapfile);

files=fopen(text,"rb"); if(!files) { end_game++; bGameComplete=TRUE; return;

} fread(&tmpmap,sizeof(int[30][20]),1,files); fclose(files); } </highlightSyntax>