Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Map::Draw(int idmap)
- {
- int camx, camy;
- Camera::Get().GetPos(camx, camy);
- camx -= GameConfig::Get().MapViewSizeW / 2;
- camy -= GameConfig::Get().MapViewSizeH / 2;
- const int tilesize = GameConfig::Get().TileSize;
- // рисуем только в видимой области экрана
- for ( int x = 0; x < GameConfig::Get().MapViewSizeW; x++ )
- {
- for ( int y = 0; y < GameConfig::Get().MapViewSizeH; y++ )
- {
- int tx = x + camx;
- int ty = y + camy;
- if ( tx >= 0 && ty >= 0 )
- DrawBlock(idmap, tx, ty, x*tilesize, y*tilesize);
- }
- }
- }
- void Map::DrawBlock(int idmap, int x, int y, int tx, int ty)
- {
- // рисуем блок текущей карты
- m_blocks[x][y].Draw(tx, ty, (float)idmap / GameConfig::Get().MapZ);
- // если это специальный пустой блок, то рисуем под ним блок с нижней карты и так до самого дна
- if ( m_blocks[x][y].IsFree() )
- {
- if ( idmap < (World::Get().GetMaps().size() - 1) )
- World::Get().GetMaps()[idmap + 1].DrawBlock(idmap + 1, x, y, tx, ty);
- }
- }
- // функция рисования спрайта
- void Sprite::Draw(float x, float y, float z)
- {
- Render::Get().GetDefQuad().SetDepth(z);
- m_tex.Bind();
- Render::Get().GetDefQuad().SetSize(glm::vec2((float)m_tex.GetWidth(), (float)m_tex.GetHeight()));
- Render::Get().GetDefQuad().SetTexRect(glm::vec4(m_rect.x, m_rect.y,
- m_rect.z + m_rect.x - 1, m_rect.w + m_rect.y - 1));
- Render::Get().GetDefQuad().SetSize(m_size);
- Render::Get().GetDefQuad().SetFlip(m_flip.x, m_flip.y);
- Render::Get().GetDefQuad().Draw(glm::vec2(x, y));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement