Closed smcameron closed 2 years ago
The reason the movement isn't working correctly is because selection isn't working properly. What's happening is I think, as follows:
What's really going wrong is that somehow, wrong objects are being selected. I don't yet know why this is the case, but suspect something to do with entity's sx, sy fields, or object id / user data fields.
I think I found a big clue. in add_entity(), sx, sy, and onscreen fields are not initialized. In show_demon_3d(), where object selection happens, it's checking these fields. These fields are set by render_entities(). But render_entities is only called after checking the entity's sx, sy vs. mouse position. So it's using old sx, sy from the previous rendered frame, and it only happens to sometimes work because the allocation of entities mostly happens the same way from one frame to the next.
The fix should be, I think, to move the rendering before the mouse checks, and initialize sx, sy, and onscreen fields in add_entity.
Fixed by:
Sometimes when you select say, the player's ship, and try to move it someplace else, it's as if there's some large offset added to the position.