-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBoard.cpp
More file actions
44 lines (35 loc) · 1.48 KB
/
Board.cpp
File metadata and controls
44 lines (35 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Board.hpp"
Board::Board(){
}
Board::Board(sf::Texture* vM, sf::Image* cM){
// std::cout << "vM ---- " << vM->getSize().x << std::endl;
// std::cout << "map ---- " << map.getTexture()->getSize().x << std::endl;
visibleMap = *vM;
// std::cout << "visibleMap ---- " << visibleMap.getSize().x << std::endl;
colorMap = *cM;
// std::cout << "colorMap ---- " << colorMap.getSize().x << std::endl;
}
std::string Board::getPixelColor(float px, float py){
if(colorMap.getPixel(px,py) == sf::Color::Red) return "Red";
if(colorMap.getPixel(px,py) == sf::Color::Blue) return "Blue";
if(colorMap.getPixel(px,py) == sf::Color::Green) return "Green";
if(colorMap.getPixel(px,py) == sf::Color::Black) return "Black";
if(colorMap.getPixel(px,py) == sf::Color::White) return "White";
return "Penguins";
}
sf::Color Board::get_pixel_color(float px, float py){
return colorMap.getPixel(px, py);
}
void Board::setPixel(float px, float py, sf::Color c){
colorMap.setPixel(px, py, c);
colorMap.loadFromFile("res/mapaColors.png");
}
void Board::draw(sf::RenderWindow* rW){
// rT->clear(sf::Color::Red);
// std::cout << "bmo " << visibleMap.getSize().x << std::endl;
// std::cout << "map ---- " << map.getTexture()->getSize().x << std::endl;
map.setTexture(visibleMap);
// map.scale(rW->getSize().x/map.getGlobalBounds().width, rW->getSize().y/map.getGlobalBounds().height);
rW->draw(map);
// std::cout << "BMO" << std::endl;
}