There's no attachment. Where are you loading the AniFrame and lit fields of the tile struct? Are they part of the file? Also, this shouldn't be related to your problem but you should use strcpy() for your MapName.
There's no attachment. Where are you loading the AniFrame and lit fields of the tile struct? Are they part of the file? Also, this shouldn't be related to your problem but you should use strcpy() for your MapName.
I should've commented those lines out.
I am not done with LoadMap() yet. I want to get THIS done b4 I start working on lighting effects or animation (those two variables are for that purpose).
And I thought I did attach it. Well, I'll try again.
I suspect your problems are either something due to Allegro or from something you haven't posted as my cut and paste job from your snipets appears to work -
Code:#include <iostream> #include <fstream> #include <cstdlib> using namespace std; #define MTX 60 #define MTY 45 // Max Deminsions #define ML 3 struct tile { int type; int AniFrame; bool lit; }; class map { private: tile tiles[MTX][MTY][ML]; int width, height; int camerax, cameray; char *MapFileName; char MapName[256]; bool ExcludeSecondLayer; public: void LoadMap(char *file); int GetTileType(int positX, int positY, int positL); }; int map::GetTileType(int positX, int positY, int positL) { return tiles[positX][positY][positL].type; } void map::LoadMap(char *FileToLoad) { MapFileName = FileToLoad; ExcludeSecondLayer = false; char buffer[256]; ifstream MapFile(FileToLoad); while (!MapFile.eof() && strcmp(buffer,"[INITIALIZATION]")) { MapFile >> buffer; } while (!MapFile.eof() && strcmp(buffer,"[TILES]")) { MapFile >> buffer; if (!strcmp(buffer,"WIDTH")) { MapFile >> buffer; width = atoi(buffer); } else if (!strcmp(buffer,"HEIGHT")) { MapFile >> buffer; height = atoi(buffer); } else if (!strcmp(buffer,"S_CAMX")) { MapFile >> buffer; camerax = atoi(buffer); } else if (!strcmp(buffer,"S_CAMY")) { MapFile >> buffer; cameray = atoi(buffer); } else if (!strcmp(buffer,"EX_LAYER2")) ExcludeSecondLayer = true; else if (!strcmp(buffer,"MAPNAME")) { MapFile.getline(buffer,256); MapName = buffer; } } while (!MapFile.eof() && strcmp(buffer,"ENDMAP")) { MapFile >> buffer; if (!strcmp(buffer,"LAYER1")) { MapFile >> buffer; int LoadPositionX = 0; int LoadPositionY = 0; for (int i=0; i < width; i++) { for (int j=0; j < height; j++) { MapFile >> buffer; tiles[LoadPositionX][LoadPositionY][0].type = atoi(buffer); cout << tiles[LoadPositionX][LoadPositionY][0].type; LoadPositionX++; } LoadPositionX = 0; LoadPositionY++; } MapFile >> buffer; } } MapFile.close(); } int main() { map CurrentMap; CurrentMap.LoadMap("test.txt"); cout << "\nGetTileType:" << CurrentMap.GetTileType(4,3,0); return 0; }
Well it all seems to work when I swapped width and height over
You'll notice that I made your test data unique in the corners, to make sure it matched up with the corners when the data was being read in.
you didn't modify it at all and it still worked?
WTF?
And no it's not allegro, because it doesn't have anything to do with allegro, plus it IS working right in the loadmap function just not outside that function.
This is weird.
PS: I already tried flipping, but it loops forever doing that
> you didn't modify it at all and it still worked?
All I swapped over was width and height in the for loops, and made the condition < instead of <=
Also swapped over the array to make it [row][column] not [column][row]
My zip file contains code, input and results - and it seems to work compiled with DJGPP.
puzzling....
what in the hell?
now it works.
You said you just flipped around the x and the y. I tried that a half hour ago, but it didn't work.
I think it is just because you are magic!
> I think it is just because you are magic!
<fx: bows>
void hat ( const char *rabbit );
...except "const" implies that the value is unchanging. I believe your prototype would be "virtual void hat ( char *rabbit );"void hat ( const char *rabbit );
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }