Handmade Hero » Forums » Game » Unable to position an entity - Week 11, Day 52
N Setobol
15 posts / 1 project
Warehouse worker/Programmer
#10192 Unable to position an entity - Week 11, Day 52
2 years, 9 months ago Edited by N Setobol on Jan. 2, 2017, 11:56 p.m.

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)


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!

github: https://github.com/nsetobol

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes. That way I wouldn't have to have any useless conversations with anybody" -J.D Sailnger
Mārtiņš Možeiko
1974 posts / 1 project
#10201 Unable to position an entity - Week 11, Day 52
2 years, 9 months ago

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.