When I started playing squash, my only opponent was an ex-league player. The two of us kept a mental log of my highest score against him, which steadily increased as I got better, and he showed me where I was going wrong. Over the next year I didn’t beat him once, but occasionally would best my previous high score, which was always exhilarating, until about a year an a half later were we’re on equal footing, and I could start playing, mentally, for the win.
That said, not all games can support this mental model. Chess for instance I always find disheartening to play against much better players. A 600 ELO point difference in chess basically means you will never win, and it becomes futile, and crushing.