Advertisement
Guest User

Map.cpp

a guest
Oct 15th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include "Map.h"
  2. #include "FrameworkTest.h"
  3. #include "Tile.h"
  4. #include <iostream>
  5.  
  6.  
  7.  
  8.  
  9.  
  10. Map::Map()
  11. {
  12. }
  13.  
  14. Map::Map(int theSpriteNumber)
  15. {
  16.     mySpriteNumber = theSpriteNumber;
  17. }
  18.  
  19. Map::~Map()
  20. {
  21. }
  22.  
  23. int Map::mapCreate()
  24. {
  25.     int screenW;
  26.     int screenH;
  27.  
  28.     pFramework->GetScreenSize(screenW, screenH);
  29.  
  30.     int grid[13][15] = {
  31.        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  32.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  33.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  34.        1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
  35.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  36.        1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1,
  37.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  38.        1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1,
  39.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  40.        1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  41.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  42.        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
  43.        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  44.     };
  45.  
  46.     for (int i = 0; i < 13; i++)
  47.     {
  48.         for (int j = 0; j < 15; j++)
  49.         {
  50.             if (grid[i][j] == 1)
  51.             {
  52.                 int temp = pFramework->DuplicateSprite(pFramework->m_iPlatformSprite);
  53.                 Tile* block = new Tile(temp);
  54.                 block->tilePos = grid[i][j];
  55.                 block->xPos = j * screenW / TILE_SIZE;
  56.                 block->yPos = i * screenH / TILE_SIZE;
  57.                 block->xSize = TILE_SIZE;
  58.                 block->ySize = TILE_SIZE;
  59.                 block->pFramework = this->pFramework;
  60.                 pFramework->myObjects.push_back(block);
  61.                 std::cout << "tile spawned" << std::endl;
  62.             }
  63.         }
  64.     }
  65.     return true;
  66. }
  67.  
  68.  
  69. bool Map::Draw()
  70. {
  71.     pFramework->DrawSprite(mySpriteNumber);
  72.  
  73.     return true;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement