That's My Code .. #include <SFML/Graphics.hpp>
int main(){
///Window Parameters///////////////////////////////////////////////
sf::ContextSettings settings;
settings.antialiasingLevel = 13;
sf::RenderWindow window(sf::VideoMode(800, 600), "AlaEddine", sf::Style::Default, settings);
bool x;
bool y;
///Loading PLAYER.PNG////////////////////////////
sf::Texture pTexture;
sf::Sprite player;
if(pTexture.loadFromFile("player.png"))
player.setPosition(x,y);
///loading bullet.png ////////////////////////////
sf::Texture bTexture;
sf::Sprite bullet;
if(bTexture.loadFromFile("bullet.png"))
///Texturing Player.png/////
player.setTexture(pTexture);
///Texturing Bullet.png/////
bullet.setTexture(bTexture);
bullet.setScale(-10000,-10000);
while(window.isOpen())
{
sf::Event Event;
while(window.pollEvent(Event))
{
///Exit When Escape Pressed////////////////////////////////////////////////
if(Event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
window.close();
}
}
/// //MOVING PLAYER//////////////////////////////
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
{
player.move(0,-1.5);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
player.move(0,1.5);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)){
player.move(-1.5,0);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
player.move(1.5,0);
}
///ROTATION////////////////////////////////////////////
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
player.rotate(2);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
player.rotate(-2);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)){
bullet.setPosition(player.getPosition());
bullet.setScale(1,1);
}
window.draw(bullet);
window.display();
window.clear(sf::Color::Cyan);
///Showing Player To Screen
window.draw(player);
}
}