I’m seeing what I consider an odd difference when it comes to coordinates on android vs my pc. I’m mostly an SDL noob, so I’m hoping this is something simple. I’m doing some very basic collision detection in the Y direction. I have two rect’s falling (dillo1 & dillo2), and I stop updating their position when they ‘collide’ with the static rect (ground1). Here’s the basic code:
if((dillo1.dstRect.y + dillo1.getHeight()) < ground1.rect.y) {
dillo1.dstRect.y += 3;
}
if((dillo2.dstRect.y + dillo2.getHeight()) < ground1.rect.y) {
dillo2.dstRect.y += 5;
}
When I compile and run this on my PC, it works fine (the moving rect’s stop when the bottom of them hit the top of the static rect). I’d show you, but I only can embed one media item in my post since I’m a new user. I’ll embed the android one that isn’t working as I’d expect.
So when I run the same code on my Samsung Galaxy S9, this happens:
As you can see, there’s 2 ‘dillo’ lengths between the bottom of them and the top of the ground. When I change the code to this (just switching + to -):
if((dillo1.dstRect.y - dillo1.getHeight()) < ground1.rect.y) {
dillo1.dstRect.y += 3;
}
if((dillo2.dstRect.y - dillo2.getHeight()) < ground1.rect.y) {
dillo2.dstRect.y += 5;
}
It works as I’d expect on Android, but not on PC. Other than the cpp code, I’m using the out of the box android project that comes with the SDL source code. I’m sure I’m missing something simple here, but can’t seem to figure it out when googling around. Any thoughts or pointers would be appreciated.