Hello everyone, I'm trying to make a small program in which a red rectangle (player) can walk on blocks of dirt (terrain) and when I try to put the player's sprite in the window.draw it gives me Gravity Code Description no instance overload function "sf :: RenderWindow :: draw" corresponding to the list of arguments.
There's the code:
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
int main()
{
RenderWindow window(VideoMode(640, 480), "Title");
Texture t;
t.loadFromFile("images/Terrain.png");
Sprite s(t);
Texture p;
p.loadFromFile("images/player.png");
Sprite g(p);
s.setTextureRect(IntRect(0, 0, 64, 64));
s.setPosition(Vector2f(20, 60));
s.setTexture(t);
cout << s.getPosition().x << endl;
cout << s.getPosition().y << endl;
while (window.isOpen())
{
Event e;
while (window.pollEvent(e))
{
if (e.type == Event::Closed)
window.close();
if (e.KeyPressed && e.key.code == Keyboard::Escape)
window.close();
}
window.clear();
window.draw(s,g);
window.display();
}
return 0;
}
(sorry for the bad english)
(sorry for the bothering)