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

Author Topic: 'argument': conversion from 'int' to 'T' possible loss of data  (Read 355 times)

0 Members and 1 Guest are viewing this topic.

evgn

  • Newbie
  • *
  • Posts: 1
    • View Profile
[code=cpp][color=limegreen]#include <SFML/Graphics.hpp>

int main()
{

    sf::RenderWindow window(sf::VideoMode(1280, 720), "hmmmm");

    window.setFramerateLimit(30);

    //draw

    short int a[1280][720] = { 0 };

    sf::RectangleShape pix;

    pix.setSize(sf::Vector2f(1,1));

    pix.setPosition(sf::Vector2f( 640, 0));

    a[640][0] = 1;




    //graphics


    window.clear();

    window.draw(pix);

    for (int y = 1; y <= 719;y++)
    {
        for (int x = 1; x <= 1279; x++)
        {
            pix.setPosition(sf::Vector2f(x, y));

            if ( (a[x-1][y-1] + a[x+1][y-1]) % 2 == 1)
            {
                window.draw(pix);

                a[x][y] = 1;

            }
               

        }
    }

    window.display();





    //later



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


    }


    return 0;
}
« Last Edit: August 17, 2023, 05:04:19 pm by evgn »

Hapax

  • Hero Member
  • *****
  • Posts: 3349
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: no instance of overloaded function matches the argument list argument
« Reply #1 on: August 16, 2023, 09:03:12 pm »
An sf::RectangleShape takes a float vector (sf::Vector2f) as a size, not an integer vector (sf::Vector2i).

See here:
https://www.sfml-dev.org/documentation/2.6.0/classsf_1_1RectangleShape.php#a5c65d374d4a259dfdc24efdd24a5dbec
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything