Ловлю эту ошибку при попытке запустить проект на sfml из exeшника, а не из visual studio.
В чём может быть причина возникновения ошибки?
Код (простите за максимальную неоптимизированность, немонолитность и беспорядочность, но, вместо исправления этого, силы сейчас посланы на попытки сделать exe работоспособным хотя бы в dynamic debug конфигурации):
#include <SFML/Graphics.hpp>
#include <io.h>
#include <fcntl.h>
#include <iostream>
short gamemode = 0;
int score = 0;
class Player : public sf::Drawable
{
public:
float x = 120;
float y = 40;
sf::Sprite playerSprite;
float a = -0.5f;
float v = 0;
int score;
Player(float xu, float yu, sf::Sprite sprite) {
playerSprite = sprite;
};
void playerUpdate() {
if (y < -30 || y > 600) {
gamemode = 2;
}
v += a;
y -= v;
playerSprite.setPosition(x, y);
}
protected:
void draw(sf::RenderTarget& target, sf::RenderStates state) const
{
target.draw(playerSprite);
}
private:
};
class BackgroundImg {
public:
float y;
float a = 0.05f;
float v = 0;
BackgroundImg(float yu) {
y = yu;
};
float bgUpdate() {
v += a;
y -= v;
if (y < -40) {
v = 0;
y = -40;
}
return y;
}
};
class PipePair : public sf::Drawable{
public:
float y_gap = 150;
float x, uy, dy;
sf::Sprite spru;
sf::Sprite sprd;
PipePair(sf::Sprite sprite1, sf::Sprite sprite2, float x1, float y) {
spru = sprite1;
sprd = sprite2;
x = x1;
uy = y;
dy = uy + 470 + y_gap;
spru.setPosition(x, uy);
sprd.setPosition(x, dy);
}
void pipUPD(Player player) {
x += -10;
if (x < -100) {
x = 1200;
uy = -(rand() % 440);
dy = uy + 470 + y_gap;
}
spru.setPosition(x, uy);
sprd.setPosition(x, dy);
if ((player.x + 67 >= x && player.x + 67 <= x + 100) || (player.x + 32 >= x && player.x + 32 <= x + 100)) {
if (player.y + 1 > uy + 470 && player.y + 33 < dy) {
score += 1;
}
else {
gamemode = 2;
}
}
}
protected:
void draw(sf::RenderTarget& target, sf::RenderStates state) const
{
target.draw(spru);
target.draw(sprd);
}
};
int main()
{
srand(time(0));
_setmode(_fileno(stdout), _O_U16TEXT);
_setmode(_fileno(stdin), _O_U16TEXT);
_setmode(_fileno(stderr), _O_U16TEXT);
sf::RenderWindow window(sf::VideoMode(1100, 600), L"Rebuild Of Usi-Adventure");
sf::Image backImage;
backImage.loadFromFile("images/background.png");
sf::Image playerImage;
playerImage.loadFromFile("images/player.png");
sf::Image pipeImage;
pipeImage.loadFromFile("images/pipe.png");
sf::Texture backTexture;
backTexture.loadFromImage(backImage);
sf::Texture playerTexture;
playerTexture.loadFromImage(playerImage);
sf::Texture pipeTex;
pipeTex.loadFromImage(pipeImage);
sf::Sprite backSprite;
backSprite.setTexture(backTexture);
sf::Sprite playerSprite;
playerSprite.setTexture(playerTexture);
sf::Sprite pipeSD;
sf::Sprite pipeSU;
pipeSD.setTexture(pipeTex);
pipeSU.setTexture(pipeTex);
float x = 10;
float y = 200;
playerSprite.setPosition(x, y);
Player player(x, y, playerSprite);
float xbg = -30, ybg = -40;
backSprite.setPosition(xbg, ybg);
BackgroundImg back(ybg);
PipePair pip1(pipeSU, pipeSD, 900, -100);
PipePair pip2(pipeSU, pipeSD, 1500, -300);
while (window.isOpen())
{
sf::Event event;
sf::Clock clock;
float time;
window.setVerticalSyncEnabled(true);
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (gamemode == 0) {
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
gamemode = 1;
}
}
else if (gamemode == 1) {
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
player.v = 12;
back.v = -0.9F;
}
}
else if (gamemode == 2) {
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
gamemode = 1;
}
}
}
window.clear();
time = clock.getElapsedTime().asMilliseconds();
clock.restart();
window.draw(backSprite);
if (gamemode == 1) {
player.playerUpdate();
pip1.pipUPD(player);
pip2.pipUPD(player);
playerSprite.setPosition(player.x, player.y);
backSprite.setPosition(xbg, back.bgUpdate());
window.draw(pip1);
window.draw(pip2);
window.draw(player);
}
window.display();
}
return 0;
}