-
some help with fstream
ok i downloaded this code from www.gametutorials.com (i think thats the site, ill double check after this post) which is a basic code which generates a random maze, and puts green '#' where the walls are. i want to modify it so i can use static mazes, like maybe for an rpg, and so i was thinking i could "draw" it in a .txt file and have the program open it and make the maze based on that. but im not sure how i would go about doing that, and help is greatly appreciated.
(and note: this is specificy written for dev-cpp, so i included the exe in it in case someone didnt have dev and couldnt compile it. if you dont trust to run an exe from me, go to gametutorials and download it there.)
-
hm, maybe that was a bad question?
well anyway, i have an idea of what i could try:
Code:
...
int main()
{
fstream map("map.txt", ios::in | ios::out);
...
for(int y = 0; y < buffersize.y; y++)
{
for (int x = 0; x < buffersize.x; x++)
{
int number = (x * 30) + y; //the map is 30 spaces wide, so in order for each space to have
//a unique value with only one number, yoou cant just add x and y.
char currentSpace = map.seekg (number, ios::beginning)
if (currentSpace == '#')
{
screenBuffer[x + y * SCREEN_WIDTH].Char.AsciiChar = WALL;
screenBuffer[x + y * SCREEN_WIDTH].Attributes = FOREGROUND_GREEN;
//rest of code as found in attachment in my previous post
but that doesnt work, i think its the char currentSpace = map.seekg (number, ios::beginning) with what can i replace that?