Hello! I would like to make those two example Xlib games for you. They will be written in Python. They will use events, the code will have a lot of comments and they will have a win and lose condition, just like you requested. In case that is not enough, I can also answer any of your questions afterwards.
I'm looking forward to hearing from you.