Hey
I have problem
#define NOMINMAX
#define SFML_NO_DEPRECATED_WARNINGS
#include <iostream>
#include <Windows.h>
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Audio.hpp>
#include <SFML\Window.hpp>
#include <algorithm>
using namespace sf;
using namespace std;
int main()
{
Sprite sgracz; //sprite
//Sprite smapa1;
Texture gracz;
//Texture mapa1;
gracz.loadFromFile("Textures/Player.png");
sgracz.setTexture(gracz);
sgracz.setPosition(Vector2f(120, 200));
enum enumStates { MENU, GAME, GAMEOVER, END };
enumStates state = MENU;
RenderWindow window(VideoMode(1500, 900), "Rise of the Cyborg Story");
while (window.isOpen())
{
Font font;
if (!font.loadFromFile("Fonts/arial.ttf"))
{
//Error
}
////// Menu //////
// Nagłówek //
Text title("Rise of the Cyborg Story", font, 80);
title.setStyle(Text::Bold);
title.setPosition(1280 / 2 - title.getGlobalBounds().width / 2, 20);
Text Play;
Text Options;
Text Exit;
// Play //
Play.setFont(font);
Play.setCharacterSize(65);
Play.setString("Play");
Play.setPosition(1280 / 2 - Play.getGlobalBounds().width / 2, 250);
// Options //
Options.setFont(font);
Options.setCharacterSize(65);
Options.setString("Options");
Options.setPosition(1280 / 2 - Options.getGlobalBounds().width / 2, 250 + 120);
// Exit //
Exit.setFont(font);
Exit.setCharacterSize(80);
Exit.setString("Exit");
Exit.setPosition(1280 / 2 - Exit.getGlobalBounds().width / 2, 250 + 240);
//// Działanie menu ////
Vector2f mouse(Mouse::getPosition(window));
Event event;
int selected = 1;
// Wyłączanie gry //
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
{
window.close();
}
else if (Exit.getGlobalBounds().contains(mouse) &&
event.type == Event::MouseButtonReleased && event.key.code == Mouse::Left)
{
window.close();
}
}
Text wybrane1;
Text wybrane2;
// Podświetlanie się napisów w menu //
if (Play.getGlobalBounds().contains(mouse))
Play.setColor(Color::Cyan);
else (Play.setColor(Color::White));
if (Options.getGlobalBounds().contains(mouse))
Options.setColor(Color::Cyan);
else (Options.setColor(Color::White));
if (Exit.getGlobalBounds().contains(mouse))
Exit.setColor(Color::Cyan);
else (Exit.setColor(Color::White));
if (state == MENU)
{
window.draw(title);
window.draw(Play);
window.draw(Options);
window.draw(Exit);
}
////// Koniec Menu //////
if (Play.getGlobalBounds().contains(mouse) && event.type == Event::MouseButtonPressed && event.key.code == Mouse::Left)
{
state = GAME;
}
if (state == GAME)
{
window.clear();
Event poruszanieSie;
while (window.pollEvent(poruszanieSie))
{
if ( poruszanieSie.type == Event::KeyPressed && poruszanieSie.key.code == Keyboard::Right)
{
sgracz.move(Vector2f( 50, 0));
}
if (poruszanieSie.type == Event::KeyPressed && poruszanieSie.key.code == Keyboard::Left)
{
sgracz.move(Vector2f(-50, 0));
}
}
window.draw(sgracz);
}
window.display();
}
return EXIT_SUCCESS;
}
So I want to move my sprite when i will click button but it doesnt work