What i'm trying to do is. Lets say PlayerOne and PlayerTwo. IF PlayerOne reach the edge of the screen then display playerOne Wins! Else PlayerTwo Wins AND display playerTwo Wins!.
Something like this. Sorry my first time on c++ and on a game..
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
int main()
{
// Create the main window
RenderWindow window(VideoMode(1000, 625), "SFML window");
window.setKeyRepeatEnabled(false);
// Load a sprite to display
Texture backgroundTexture;
Texture tilesTexture;
Texture bikerTexture;
Texture biker2Texture;
backgroundTexture.loadFromFile("data/images/background.png");
tilesTexture.loadFromFile("data/images/tiles.png");
bikerTexture.loadFromFile("data/images/biker.png");
biker2Texture.loadFromFile("data/images/biker2.png");
Sprite backgroundSprite(backgroundTexture);
Sprite bikerSprite(bikerTexture);
Sprite biker2Sprite(biker2Texture);
Sprite tilesSprite(tilesTexture);
bikerSprite.setPosition(0,500);
biker2Sprite.setPosition(0,555);
tilesSprite.setPosition(Vector2f(0,500));
// Start the game loop
while (window.isOpen())
{
// Process events
Event eventCheck;
while (window.pollEvent(eventCheck)) {
switch (eventCheck.type) {
case Event::Closed:
window.close();
break;
case Event::KeyPressed:
switch (eventCheck.key.code) {
case Keyboard::Space:
if (Keyboard::isKeyPressed(Keyboard::Space)) {
bikerSprite.move(10,0);
}
break;
case Keyboard::Enter:
if (Keyboard::isKeyPressed(Keyboard::Enter)) {
biker2Sprite.move(10,0);
}
break;
}}}
// Clear screen
window.clear();
// Draw the sprite
window.draw(backgroundSprite);
window.draw(tilesSprite);
window.draw(bikerSprite);
window.draw(biker2Sprite);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}