xemerau

Level.cpp

Oct 14th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. /// File:       "Level.cpp"
  2. /// Project:    "Tilemap.cbp"
  3. ///
  4. /// Please refer to main.cpp for more information.
  5.  
  6. //Preprocessor directives
  7. #include "Level.h"
  8. #include "Tile.h"
  9. #include <allegro.h>
  10. //End of preprocessor directives.
  11.  
  12. //Constructor
  13. Level::Level()
  14. {
  15.     map = {  {6, 6, 6, 6, 6, 6, 6, 6, 6, 6}
  16.             ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
  17.             ,{6, 0, 2, 5, 3, 3, 4, 2, 0, 6}
  18.             ,{6, 0, 1, 1, 1, 1, 1, 1, 0, 6}
  19.             ,{6, 0, 7, 7, 7, 7, 7, 7, 0, 6}
  20.             ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
  21.             ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
  22.             ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
  23.             ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
  24.             ,{6, 6, 6, 6, 6, 6, 6, 6, 6, 6} };
  25. }
  26. //End of constructor
  27.  
  28. //Destructor
  29. Level::~Level()
  30. {
  31. }
  32. //End of Destructor
  33.  
  34. //Map load function
  35. void Level::Load_Map (void)
  36. {
  37.     register int i1, j1;
  38.  
  39.     //Assigning the number in the map array to the map ID (*64 for pixel calculations)
  40.     for (i1 = 0; i1 < 10; i1++)
  41.     {
  42.         for (j1 = 0; j1 < 10; j1++)
  43.         {
  44.             tile[i1][j1].identifier = map[i1][j1];
  45.         }
  46.     }
  47. }
  48. //End of map load function
  49.  
  50. //Map draw function
  51. void Level::Draw_Map(BITMAP *buffer, int x1, int y1)
  52. {
  53.     register int i1, j1;
  54.  
  55.     //Base level blitting.
  56.     for (i1 = 0; i1 < 10; i1++)
  57.     {
  58.         for (j1 = 0; j1 < 10; j1++)
  59.         {
  60.             //Drawing a tile at an appropriate area by incrementing the loop and then adding the coordinates.
  61.             masked_blit(tile[i1][j1].image, buffer, tile[i1][j1].identifier*64, 0, (j1*64) + x1, (i1*64) + y1, 64, 64); //Multiplying j1 & i1 by 64, because it's the tilesize.
  62.         }
  63.     }
  64. }
  65. //End of map draw function.
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment