COORD loopedtimes = {(viewloc.X+viewsize.X-1)/realsize.X, (viewloc.Y+viewsize.Y-1)/realsize.Y};for (std::list::iterator itr = entities.begin(); itr != entities.end(); ++itr){ entity* ent = *itr; for (int Y = 0; Y < ent->Size().Y; ++Y) { for (int X = 0; X < ent->Size().X; ++X) { for (int j = 0; j <= loopedtimes.X; ++j) { for (int i = 0; i <= loopedtimes.Y; ++i) { COORD point = {ent->position.X + X, ent->position.Y + Y}; if (point.X >= realsize.X) point.X -= realsize.X; if (point.Y >= realsize.Y) point.Y -= realsize.Y; point.X += realsize.X * j - viewloc.X; point.Y += realsize.Y * i - viewloc.Y; if (point.X >= 0 && point.X < viewsize.X && point.Y >= 0 && point.Y < viewsize.Y) { tempbuf[point.Y * viewsize.X + point.X].Attributes = (*ent)[Y*ent->Size().X+X].Attributes; tempbuf[point.Y * viewsize.X + point.X].Char = (*ent)[Y*ent->Size().X+X].Char; } } // for each Y-looped point } // for each X-looped point } // for each X } // for each Y} // for each entity
While I was working on this, I wasn't sure what most of the changes I made actually did! I've tested this a bit (and I've gone through with the debugger) and it looks like it works, so I'm going to start working on an entity-loading system, and then a map system.
Questions about the algorithm? (I know I have plenty!)