Я пытаюсь сделать простую программу с SFML.Пока у меня есть основной файл и файл, чтобы открыть окно, и заголовок этого файла.Дело в том, что у меня возникла проблема с заголовком:
#ifndef Window.hpp
#define Window.hpp
Window();
int Loop();
#endif
Я получаю эту ошибку:
C: ... \ Window.hpp | 4 | ошибка: ожидается неквалифицирован-идентификатор перед "."токен |
Файл окна:
#import <SFML/Window.hpp>
#import <iostream>
// This file needs to create and maintain the program's window, and change it's state.
class Window
{
sf::RenderWindow appWindow;
sf::Image charImage;
sf::Sprite charSpriteSheet;
public:
Window();
int Loop();
}
Window::Window()
{
appWindow.Create(sf::VideoMode( 800, 600, 32), "AI_Fighter");
if( !charImage.LoadFromFile("Bass.png") )
{
cout << "Problem opening file 'Bass.png'";
}
charSpriteSheet.SetImage(charImage);
}
int Window::Loop()
{
// Start game loop
while (appWindow.IsOpened())
{
sf::Event evt;
while (appWindow.GetEvent(evt))
{
// Window closed
if (evt.Type == sf::Event::Closed)
appWindow.Close();
// Escape key pressed
if ((evt.Type == sf::Event::KeyPressed) && (evt.Key.Code == sf::Key::Escape))
appWindow.Close();
}
// Get elapsed time
float ElapsedTime = appWindow.GetFrameTime();
// Move the sprite
if (appWindow.GetInput().IsKeyDown(sf::Key::Left)) charSpriteSheet.Move(-100 * ElapsedTime, 0);
if (appWindow.GetInput().IsKeyDown(sf::Key::Right)) charSpriteSheet.Move( 100 * ElapsedTime, 0);
if (appWindow.GetInput().IsKeyDown(sf::Key::Up)) charSpriteSheet.Move(0, -100 * ElapsedTime);
if (appWindow.GetInput().IsKeyDown(sf::Key::Down)) charSpriteSheet.Move(0, 100 * ElapsedTime);
// Rotate the sprite
if (appWindow.GetInput().IsKeyDown(sf::Key::Add)) charSpriteSheet.Rotate(-100 * ElapsedTime);
if (appWindow.GetInput().IsKeyDown(sf::Key::Subtract)) charSpriteSheet.Rotate( 100 * ElapsedTime);
// Clear the screen (fill it with black color)
appWindow.Clear(sf::Color( 0, 0, 0));
appWindow.Draw(charSpriteSheet);
// Display window contents on screen
appWindow.Display();
}
}