Loading a map from a text file in SFML

Dec 5, 2019 at 5:57pm
Hey everyone,
I am trying to create an SFML program that loads directly from a .txt file. To clarify, the .txt file contains a matrix
For instance,

0 1
2 3

assume 0 is land, 1 is car, 2 is animal, and 3 is bridge.
(Note: that the objects must all be loaded on land)
How can I do this? I need this simple idea for a much complex project I am working on but I really can't find any online resources on this issue.
Please help
Thanks
Dec 5, 2019 at 6:55pm
Do you not know how to read in the numbers? Or do you know how to read in the numbers but you don't have an idea of how to use them to create some kind of representation of a 2D space?
Dec 5, 2019 at 7:03pm
I know how to read in the numbers but not in matrix form I have a really simple idea about this, but I don't know how to represent them in 2d space
Dec 5, 2019 at 7:23pm
The code to read in four numbers from this file:
1 2 3 4

is identical to this file:
1
2
1 2
3 4


It's just infile >> variable; four times.
Topic archived. No new replies allowed.