Better way to move the map according to player position?

Hello,

I’m developing a 2D game with tiled-based maps. So, when my player moves any point after/before screenWidth / 2 or screenHeight / 2, it’ll .glTranslate the map and everything drawn on it. To calculate when it should translate or not, untranslate or not, and how much translate, I’m not using anything like matrixes: I’m just using pure math code.

My question is: is there a way to do it better? This way, right now, isn’t affecting performance or anything related, but I’m just wondering if I could get the same result using transformation or projection matrixes? (Since I don’t know how those works.)

Thanks.