I know how to build it. I just need to know how to keep the top bunk stable and not fall off when carrying a 170lb person.
This is what I have put together so far.
If I missed something please advise.
Since you are cantilevering off the wall, the verticals must be exemplary. This is a very significant structural side load. I would consider Unistrut, and it must be tied to studs proper, never to drywall itself.
If the stays (diagonal cables) came the whole width of the bed, they would carry up to 100% of the occupancy load if the person is rolled out against the edge / sitting on the edge at the top of the ladder.
If they are less than the full width, then divide by the fraction of the width. For instance if they come out 30% of the ways, then 185 lb / 0.30 = 616 lbs. That's static load; dynamic forces could be much more.
As a practice you should engineer for many times the weight.
Keep in mind this same force will also bear on the wood, so you're talking about a tremendous force at the attach point. One way to handle this is a steel plate along the outside, screwed into the wood at close intervals. Steel is very strong but is a wiggly worm. The wood keeps the steel straight, greatly increasing its strength.
Also, you may want to provide a means of adjustment to the cables.
All in all, you may be better simply installing high beds that do not move, and creating desk, storage or living space below the bed.
Many designs have legs at both exterior corners, but your design uses stays, the stays should reach more than half way across the platform, else they and the hinge will be seeing magnified loads. the top end of the stay should be as high as possible on the frame. perhaps consider folding stays instead of telescopic.
The ladder should rest on the floor when deployed.
The front wall of both platforms should be continuous as it gives rigidity.