C++ Project 2016-2017: Arkanoid
wall_sfml.cpp
Go to the documentation of this file.
1 
3 #include "wall_sfml.h"
4 
5 #include <SFML/Graphics.hpp>
6 #include <iostream>
7 
8 using namespace std;
9 
10 namespace arkanoidSFML {
11 
12  WallSFML::WallSFML(double x, double y, sf::RenderWindow &window, const string &textureFile) : windowSFML(window), transformation(Transformation::getInstance()) {
13 
14  // Set texture
15  if(!texture.loadFromFile(textureFile)) {
16  throw runtime_error("Couldn't load wall texture image: " + textureFile);
17  }
18  texture.setSmooth(true);
19  sprite.setTexture(texture);
20 
21  // Set position
22  sprite.setPosition(x, y);
23  setPosition(std::move(transformation->convertVector(sprite.getPosition())));
24 
25  // Set size (width and height) of WallSFML
26  sf::FloatRect rect = sprite.getLocalBounds();
27  setSize(make_pair(transformation->convertX(rect.width), transformation->convertY(rect.height)));
28  }
29 
31 
33  // ...
34  }
35 
36  void WallSFML::draw() const {
37  windowSFML.draw(sprite);
38  }
39 
40 }
void setSize(pair< double, double > newSize)
Definition: entity.cpp:30
Singleton: This class provides a method to convert screen pixels to their corresponding coordinates i...
All the game gui elements of the Arkanoid game.
Definition: ball_sfml.cpp:10
arkanoid::Vector2D convertVector(const sf::Vector2f &vector)
void setPosition(double x, double y)
Definition: entity.cpp:21