• + 1 comment

    You don't even need the boolean. In your uphill block, before you increment level, just check if your level is -1. If it is, increment valleys.

    Since he always starts and ends at sea level, he will never go from -1 to 0 unless he is leaving a valley.