Hi.
I can see how that could really make things awkward. The good news is that this awkwardness is likely to fade over time.
If you haven't talked with him about this, you might try that. Addressing what happened, instead of avoiding the subject, may actually make the awkwardness go away more quickly. No need to linger on what he was doing, just apologize and tell him you'll be more careful next time--that you'll knock first.
Since you two have been hanging out since you were kids, walking into your friend's room without announcing yourself or asking permission may have, in the past, felt like a perfectly natural thing to do. However, you're both getting older and you're bound to need more privacy.
In order to avoid this kind of awkwardness, it might help for both of you to acknowledge that you will have to be more careful in the future.
Take care.