I'm making a rogue like game using pdcurses in C++ and all it's going ok at the moment. But I'm facing a problem right now that I don't know how to solve.
Let's see a screenshot of the problem for better understanding:
As you can see, if you zoom in the upper red circle, you can see how the player character is overlapping the enemy troll (t) about 2 pixels on its left side. The problem is that if the player moves to another position, the enemy troll has lost that 2 pixels forever, so this is not a thing that just happens while the player is on the left side, but it's permanent.
In the other circle the player has moved from right to left on the corridor, and the corridor tiles (#) have lost their left side pixels too.
So here is where I update all the graphics stuff:
dungeon_.generate();
while(state_ == State::Running)
{
if(manageInput(windows_[0]) != -1)
{
// Update here monsters behavior
}
dungeon_.draw(windows_[0]);
player_->draw(windows_[0]);
refreshWindows(windows_);
}
This is the refreshWindows(std::vector windows) method:
void Game::refreshWindows(std::vector<WINDOW *> windows)
{
for(auto w : windows)
{
Curses::wbox(w, 0, 0);
Curses::refresh(w);
}
}
Both draw methods of player and dungeon do this, but dungeon also different cases for every tile in the map on drawing:
void Player::draw(WINDOW *win)
{
Curses::mvwaddch(win, location_.y, location_.x,
static_cast<char>(type_) |
COLOR_PAIR(static_cast<int>(GameObject::Color::White_Green)));
}
And this is how int manageInput(WINDOW *win) looks like:
int Game::manageInput(WINDOW *win)
{
int key = Curses::wgetch(win);
if(key != -1)
{
// Player movement
if(key == static_cast<int>(Curses::Key::Up))
{
player_->moveNorth(dungeon_.map());
}
[...]
}
return key;
}
As you can see, it's a really simple approach which I'm using in my game loop, so I don't know why the hell it's not working. These are things I have tested:
And that's all. I don't know what to do to fix it. If you need more information you can find here the git repository: https://github.com/SantiagoSanchez/Ruoeg
Thanks in advance.
Ok, it seems like I have found the source of the problem.
It doesn't have to be with curses library, but bitmap fonts at Windows console.
More details: https://stackoverflow.com/a/9814766/368299