Handmade Hero»Forums»Code
19 posts
Day 053 - Camera Centers Player, Throwing off Walls of Rooms
Edited by echu on
I got to 49:34 where Casey implements moving the camera tile by tile. Although I solved my previous issues regarding alpha blending and actually displaying the walls, my camera code is now busted. It seems to insist on centering the player, which throws off how the walls of rooms are drawn. As before, I've linked by code and an image of the problem. It's probably something simple I've overlooked, probably either to do with SetCamera(), RectangleCenterDimension(), or how camera positions are getting passed around.

It's very strange, because there's a quick movement from left to right, almost as if the camera position starts out right but then is wrong almost immediately once the space bar is pressed.

As before, all .exes can be run from the /build/ directories. I think the build.bat should work, but it'll create some directories on your Desktop which mirror my environment.

Could use a fresh set of eyes, I appreciate the help!

My Code: [removed]
Imgur: The player starts off centered, throwing off the walls of the room.
Simon Anciaux
1341 posts
Day 053 - Camera Centers Player, Throwing off Walls of Rooms
I don't know about others but I'm not comfortable with giving my e-mail address to a random site to download a file. Could you use any other way to share your code ?

As you manage to fix your previous issue yourself, I would suggest you to take a break and come back with a fresh mind. It helps me approach the issue in a different way and the solution generally comes quick.

Otherwise, the usual advice is to step in the code with a debugger and inspect all value and make sure they are what you expect. Don't assume they are unless you see them.
19 posts
Day 053 - Camera Centers Player, Throwing off Walls of Rooms
Edited by echu on
Thanks for your response. I've changed the hosting service to Google Drive, so it shouldn't ask for your email. Sorry about that.
19 posts
Day 053 - Camera Centers Player, Throwing off Walls of Rooms
The issue has somehow been solved, I’m still not exactly sure! Did a reverse trace with variables involving the camera and must have changed something. The code has been removed, but I’ll leave the image up.