[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Debugging and Collision Map
From: |
Gervase Lam |
Subject: |
Debugging and Collision Map |
Date: |
Sun, 22 Sep 2002 15:21:52 +0100 |
A bit a code I made up to find out why Pingus were getting stuck. I don't
think it is useful with more than 1 Pingu as the code is. Adding Pingu ID
to it would mean that grep could be used. So a few more Pingus can be
handled. Too many and you don't know which Pingu ID represents which
Pingu on the screen.
As well as slowing the game down, the log file generated will be enormous.
The largest log file that I generated for one Pingu was about 5Mb.
void
Pingu::set_pos (float x, float y)
{
set_x (x);
set_y (y);
show_col_area(); // DEBUG
}
void
Pingu::show_col_area (void)
{
std::cout << std::endl << std::endl << pos_x << "," << pos_y;
// 26 is the Pingu height
for (int y = 26 + 3; y > -9; --y)
{
std::cout << std::endl;
// If at top or bottom of Pingu
if (y == 26 || y == 0)
{
if (direction > 0)
std::cout << ">";
else
std::cout << "<";
}
else
{
std::cout << " ";
}
for (int x = -30; x < 30; ++x)
{
// If on first or last line of display
if (y == 26 + 3 || y == -8)
{
if (x == 0)
std::cout << "|";
else
std::cout << " ";
}
else
{
int ground_type =
WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pos_x + x),
static_cast<int>(pos_y - y));
switch (ground_type)
{
case Groundtype::GP_NOTHING:
std::cout << " ";
break;
case Groundtype::GP_SOLID:
std::cout << "s";
break;
case Groundtype::GP_TRANSPARENT:
std::cout << "t";
break;
case Groundtype::GP_GROUND:
std::cout << "g";
break;
case Groundtype::GP_BRIDGE:
std::cout << "b";
break;
case Groundtype::GP_WATER:
std::cout << "w";
break;
case Groundtype::GP_LAVA:
std::cout << "l";
break;
case Groundtype::GP_REMOVE:
std::cout << "r";
break;
case Groundtype::GP_OUTOFSCREEN:
std::cout << ".";
break;
default:
std::cout << "?";
}
}
}
}
std::cout << std::endl;
}
Thanks,
Gervase.
- Debugging and Collision Map,
Gervase Lam <=