Edit: I fixed it already, no need to help anymore.
Okay... I'm trying to use a .txt (Already am using a .cpp file to prevent errors) file to load a map into a game. But wen I run my code, I get blank white screen (SFML window) with which I can do nothing. I get no errors, although I did get RAM reading errors before. #include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <fstream>
#include <iostream>
sf::Sprite Sprite[2];
sf::Texture grass;
sf::Texture brick;
char textChar[2];
int numCharacters = 0;
int i = 0;
sf::RenderWindow window(sf::VideoMode(512, 384), "Map testing");
int main() {
std::ifstream myfile("Map test.cpp");
//Specific to my images, I know bad names...
brick.loadFromFile("New Piskel.png");
grass.loadFromFile("Grass_double.jpg");
while (window.isOpen())
{
window.clear();
if (myfile.is_open())
{
while (!myfile.eof())
{
myfile >> myArray[i];
i++;
num_characters++;
}
for (i = 0; i <= num_characters;)
{
if (myArray[i] == '1') {
Sprite[i].setTexture(brick);
window.draw(Sprite[i]);
i++;
}
if (myArray[i] == '2') {
Sprite[i].setTexture(grass);
Sprite[i].setPosition(64, 0); //For testing purposes
window.draw(Sprite[i]);
i++;
}
}
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.display();
}
}
}
(Please do not comment on the lack of comments, I am aware of that)
Can someone please help me with this? The .cpp contains the text "12" and the images are 64 by 64. I really have no idea what's going wrong.
Edit: I'm using an Amd processor and Windows 10 x64.