#include <SFML/Graphics.hpp>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
class texts{
public:
sf::Text textClass;
texts();
texts(sf::Font font, string symbol, int characterSize, float e, float f){
textClass.setFont(font);
textClass.setString(symbol);
textClass.setCharacterSize(characterSize);
textClass.setColor(sf::Color::Red);
textClass.setStyle(sf::Text::Bold);
textClass.setPosition(e, f);
}
unsigned int charSize(){
return textClass.getCharacterSize();
}
string returnString(){
return textClass.getString();
}
};
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Project Talon!");
sf::Font font;
if (!font.loadFromFile("OpenSans-Bold.ttf"))
{
// error...
}
int RLmap[3][3];
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
RLmap[i][j] = 1;
}
}
RLmap[1][1] = 0;
sf::Text text;
text.setFont(font);
text.setString("@");
text.setCharacterSize(24);
text.setColor(sf::Color::Red);
text.setStyle(sf::Text::Bold);
float x = 48;
float y = 48;
vector<texts> allTexts;
while (window.isOpen())
{
for(int a=0; a<3; a++){
for(int b=0; b<3; b++){
if(RLmap[a][b] == 1){
float c = a*24;
float d = b*24;
allTexts.push_back(texts(font, "#", 24, c, d));
}
if(RLmap[a][b] == 0){
float c = a*24;
float d = b*24;
allTexts.push_back(texts(font, ".", 24, c, d));
}
}
}
text.setPosition(x,y);
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::S)
{
y = y+24;
}
if (event.key.code == sf::Keyboard::W)
{
y = y-24;
}
if (event.key.code == sf::Keyboard::A)
{
x = x-24;
}
if (event.key.code == sf::Keyboard::D)
{
x = x+24;
}
}
}
window.clear();
window.draw(text);
while(!allTexts.empty()){
window.draw(allTexts.back().textClass);
allTexts.pop_back();
}
window.display();
}
return 0;
}