Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// File: "Level.cpp"
- /// Project: "Tilemap.cbp"
- ///
- /// Please refer to main.cpp for more information.
- //Preprocessor directives
- #include "Level.h"
- #include "Tile.h"
- #include <allegro.h>
- //End of preprocessor directives.
- //Constructor
- Level::Level()
- {
- map = { {6, 6, 6, 6, 6, 6, 6, 6, 6, 6}
- ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
- ,{6, 0, 2, 5, 3, 3, 4, 2, 0, 6}
- ,{6, 0, 1, 1, 1, 1, 1, 1, 0, 6}
- ,{6, 0, 7, 7, 7, 7, 7, 7, 0, 6}
- ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
- ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
- ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
- ,{6, 0, 0, 0, 0, 0, 0, 0, 0, 6}
- ,{6, 6, 6, 6, 6, 6, 6, 6, 6, 6} };
- }
- //End of constructor
- //Destructor
- Level::~Level()
- {
- }
- //End of Destructor
- //Map load function
- void Level::Load_Map (void)
- {
- register int i1, j1;
- //Assigning the number in the map array to the map ID (*64 for pixel calculations)
- for (i1 = 0; i1 < 10; i1++)
- {
- for (j1 = 0; j1 < 10; j1++)
- {
- tile[i1][j1].identifier = map[i1][j1];
- }
- }
- }
- //End of map load function
- //Map draw function
- void Level::Draw_Map(BITMAP *buffer, int x1, int y1)
- {
- register int i1, j1;
- //Base level blitting.
- for (i1 = 0; i1 < 10; i1++)
- {
- for (j1 = 0; j1 < 10; j1++)
- {
- //Drawing a tile at an appropriate area by incrementing the loop and then adding the coordinates.
- 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.
- }
- }
- }
- //End of map draw function.
Advertisement
Add Comment
Please, Sign In to add comment