Roguelike AoC – part 16
In the sixteenth lesson of a roguelike game tutorial a new element of the screen showed up – the HUB.
Ehm, so what do I do?
To be completely honest there was not much to actually do in this lesson. I’ve just followed it, added new properties to structs, rewritten HUB printing code and that was almost it. I had to increase Y value for HUB starting position. Also, in order to avoid cursor staying in the lower-right corner of the screen after rendering the HUB, I’ve added additional player rendering. Below is my main function.
int main()
{
srand(time(NULL));
screenSetup();
Level *level = createLevel(DEFAULT_LEVEL_NUMBER, NUMBER_OF_ROOMS, NUMBER_OF_MONSTERS);
// Initial drawing when we enter the game
printGameHub(level);
playerDraw(level->user);
/* Main game loop */
char keyPressed;
while((keyPressed = getch()) != 'q') {
handleInput(keyPressed, level);
moveMonsters(level);
printGameHub(level);
playerDraw(level->user); // We redraw the player position after redrawing everything else
}
endwin();
return 0;
}
Code
Here is the direct link to the GitHub repo.
Leave a Reply
You must be logged in to post a comment.