In shipping there are standard international rules about which way boats should dodge each other.
Are there similar rules in aviation?
Why yes, there are - in fact they're basically similar to the maritime rules!
They're described in ICAO Annex 2 (or for US pilots, FAR 91.113).
Basically, for aircraft of the same type (e.g. two airplanes) in the air the rules are:
- Approaching head-on: Both aircraft alter their heading to the right.
- Converging: Give way to the aircraft on your right.
- Overtaking: Pass "well clear" to the right of the aircraft being overtaken.
(The aircraft being overtaken has the right of way. The overtaking plane maneuvers to remain clear.)
The rules for converging aircraft are more complex when the aircraft are not the same type - basically the more maneuverable aircraft gives way to the less maneuverable aircraft (because something like a balloon can't really maneuver to avoid a collision) - you can read the details in either of the links above.
Also while it's not explicitly spelled out in ICAO Annex 2 (or at least I didn't see it) aircraft in distress generally trump the "right of way" rules. (This is really common sense: if an aircraft is recognizably in distress you do everything in your power to stay out of their way and help ensure a safe outcome to whatever their situation is.)