how can i make my code show this output im new to smfl and codeblock i dont know how to call sprite and make it move me and my friend are confuse during this pandemic online classes are hard :(
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
class Game
{
public:Game();
void run();
private:
void processEvents();
void update(sf::Time deltaTime);
void render();
void handlePlayerInput(sf::Keyboard::Key key,bool isPressed);
private:
sf::RenderWindow mWindow;
sf::CircleShape mPlayer;
bool mIsMovingUp = false;
bool mIsMovingDown = false;
bool mIsMovingLeft = false;
bool mIsMovingRight = false;
float PlayerSpeed = 10.0f;
sf::Time TimePerFrame = sf::seconds(1.f / 60.f);
};
Game::Game()
: mWindow(sf::VideoMode(640, 480), "SFML Application")
, mPlayer()
{
mPlayer.setRadius(40.f);
mPlayer.setPosition(100.f, 100.f);
mPlayer.setFillColor(sf::Color::Cyan);
}
here is the link to the full code https://pastebin.com/g4v2DzgF PLEASE SEND HELP S.O.S
First you need to load the texture.
sf::Texture texture;
texture.loadFromFile("ship.png");
Do not delete the texture. It has to exist for you to use it.
Next you need to create a sprite using the texture.
sf::Sprite sprite(texture);
Remember to draw the sprite, this is done in the same way you draw the player.
You can also move the sprite the same way you move the player.
Check out the documentation for more details: