Unable to position an entity - Week 11, Day 52

This bug has been "bug"gging me for weeks now. I am unable to set the position of an entity. I changed the coordinates in AddPlayer but the player is still stuck in the left bottom corner. Shown here:



I tried adding the player when the game starts and I also try other things and I just can't put my finger on it but I'm doing something wrong.

the code for my project is here (note: The 70-80% code I wrote is not a direct copy from the actual source and I didn't include the art resources. The other 20% of the code are written by the SDL platform for linux by David(?) Sorry, I forgot)

https://github.com/nsetobol/Handm...ice/tree/master/Handmade_Hero_SDL

I not sure if the cause of the bug is in handmade.cpp or handmade_tile.cpp....what do you guys think? It's been weeks since I have done handmade hero and I really want to continue!


Edited by N Setobol on
I recommend using debugger in following way to determine where is the problem:

1) put a breakpoint in DrawBitmap function, examine realX/realY variables - do they contain reasonable values? If yes, then the problem is DrawBitmap function because it draws bitmap in wrong place, if not move one step up in call stack, and go to point (2)

2) do playerGroundPointX, playerGroundPointY and z variables contain reasonable values (what you expect)?

3) then move step above - look at variables how playerGroundPointX/Y was calculated. Do they have reasonable/expected values.

And continue in similar manner until you'll pinpoint the issue. Using debugger this way make you find problem in no time. Programming is science, so apply Scientific Method when using debugger. It really works.