SHARE
TWEET

Untitled

a guest May 19th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <allegro.h>
  2. #include <iostream>
  3. #include <map>
  4.  
  5. using namespace std;
  6. BITMAP* buffer=NULL;
  7. void set_Up_Allegro();
  8.  
  9. void mapl(char *list){
  10.     int width=32;
  11.     int x=0;
  12.     int y=0;
  13.     int color;
  14.     while(*list != 3){
  15.     switch(*list){
  16.             case 1:
  17.                 color = makecol(255, 255, 255);
  18.                 break;
  19.             case 2:
  20.                 y++;
  21.                 break;
  22.             default:
  23.                 color = makecol(0, 255, 0);
  24.                 break;
  25.         }
  26.         rectfill(buffer, x*width, y*width, width, width, color);
  27.         x++;
  28.         list++;
  29.     }
  30. }
  31.  
  32. void main(void){   
  33.     char map[]={
  34.     0,0,0,0,0,0,2,
  35.     0,0,0,0,0,0,2,
  36.     0,0,0,0,0,0,2,
  37.     0,0,0,0,0,0,2,
  38.     0,0,0,0,0,0,2,
  39.     1,1,1,1,1,1,3
  40.     }; 
  41.     set Up Allegro();
  42.     while(!key[KEY_ESC]){
  43.         mapl(map);
  44.     }
  45.     blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  46.     clear_bitmap(buffer);
  47. }
  48. END_OF_MAIN()
  49.  
  50. void set_Up_Allegro(){
  51.     allegro_init();
  52.     install_keyboard();
  53.     int ret=set_gfx_mode(GFX_AUTODETECT_WINDOWED,640, 480, 0, 0);
  54.     if(ret !=0){
  55.         allegro_message(allegro_error);
  56.     }
  57.     buffer = create_bitmap(SCREEN_W, SCREEN_H);
  58. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Top