--- a/rocks-and-diamonds.cpp +++ b/rocks-and-diamonds.cpp @@ -286,6 +286,10 @@ } void new_game(uint32_t level) { + // fredygames: after the last level, start again from the first (it used to read past the end of levels[]) + level %= sizeof(levels) / sizeof(levels[0]); + player.level = level; + // Get a pointer to the map header TMX *tmx = (TMX *)levels[level];