Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - nmb

Pages: [1]
1
SFML projects / Re: chess piece representation using fonts
« on: January 26, 2017, 06:53:11 pm »
OK. I got something working.

#include <TGUI/TGUI.hpp>

#include <iostream>

const int board[24] = {
-1,-2,-1,-1,
-1,-1,-1,-1,
 0, 0, 0, 0,
 0, 0, 0, 0,
 1, 1, 1, 1,
 1, 1, 2, 1
};

const int fsize = 80;

int main()
{
        sf::RenderWindow window{ sf::VideoMode{ 800, 600 }, "Test Chess Font" };

        sf::Font font;

        if (!font.loadFromFile("data/Avenfont.ttf"))
        {
                // error...
                std::cout << "error loading font" << std::endl;
        }

        sf::Text text[16];

        int cnt = 0;

        for (int i = 0; i < 24; i++)
        {
                if (board[i] != 0)
                {
                        int r = int(i / 4);
                        int c = int(i % 4);

                        text[cnt].setFont(font);
                        text[cnt].setCharacterSize(80);

                        switch (board[i])
                        {
                        case -1:
                                text[cnt].setString("p");
                                text[cnt].setFillColor(sf::Color::Black);
                                text[cnt].setPosition(sf::Vector2f(c * 80, r * 80));
                                //std::cout << r << " " << c << std::endl;
                                break;
                        case 1:
                                text[cnt].setString("p");
                                text[cnt].setFillColor(sf::Color::Red);
                                text[cnt].setPosition(sf::Vector2f(c * 80, r * 80));
                                //std::cout << r << " " << c << std::endl;
                                break;
                        case -2:
                                text[cnt].setString("q");
                                text[cnt].setFillColor(sf::Color::Black);
                                text[cnt].setPosition(sf::Vector2f(c * 80, r * 80));
                                //std::cout << r << " " << c << std::endl;
                                break;
                        case 2:
                                text[cnt].setString("q");
                                text[cnt].setFillColor(sf::Color::Red);
                                text[cnt].setPosition(sf::Vector2f(c * 80, r * 80));
                                //std::cout << r << " " << c << std::endl;
                                break;
                        }
                        cnt++;
                }
        }

        std::cout << cnt << std::endl;

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();

                }

                window.clear(sf::Color::White);

                for (int i = 0; i < 16; i++)
                {
                        window.draw(text[i]);
                }

                window.display();
        }

        return EXIT_SUCCESS;
}
 


2
SFML projects / chess piece representation using fonts
« on: January 26, 2017, 03:44:37 pm »
Hi,

I want to draw chess pieces using text font. How do that in SFML?

Thanks in advance.

Norm

3
SFML projects / Re: Screenshot Thread
« on: January 12, 2017, 01:34:38 am »
This is a test.


4
SFML projects / Re: Simple Chess Variant
« on: January 06, 2017, 04:39:14 pm »
Thanks for the feedback. I'll look into the idea of getting rid of  the textures. In the meantime, I have uploaded an updated version of the program (0.6) which should be more stable. The data folder has also been updated.

NMB

 

5
SFML projects / Re: Simple Chess Variant
« on: January 04, 2017, 06:47:16 pm »
I have uploaded a new version of Slip.exe improving the mouse behavior and the game management.

Thanks for trying the game,

NMB

6
SFML projects / Re: Simple Chess Variant
« on: January 04, 2017, 10:23:26 am »
Hi,

Thanks for the advice. I made the changes and I have also attached a screenshot of the interface.

NMB

https://github.com/nmblais/Slip

7
SFML projects / Simple Chess Variant
« on: January 03, 2017, 11:53:33 pm »
Hi,

I'm writing and interface to play a game that I called Slip (a chess variant) using SFML and TGUI. Using the program, one can play against one of the three engines that comes with it or make two engines play against each other. I have added a readme file with all the rules to play the game.

Thanks,

NMB

https://github.com/nmblais/Slip

Pages: [1]
anything