Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I don't think you will find someone here, who checks all that code and finds your bug. From quickly scanning over your code I can only give you a general advice:

Try to structure your code better. Do not mix different levels of abstraction in a single function. Your top level functions should have only a few lines of code and should look more like this:

if(inventoryIsOpen())
{
   drawInventory()
}
if(mouseSelectionIsRequested())
{
   if(nothingIsSelected())
   {
        selectHoveredItem();
   }
   else
   {
        deselectItem();
   }
}

When you structure your code like that, bugs like the one you describe will often become obvious.