Wednesday, October 15, 2014

Screen resolution woes and frog size

Fixed a problem with the screen width being calculated wrongly for devices with more than 576 in height. This led to some funny looking fishes. The weird thing was that Steven did not have the problem, even when he tried 1920x1080 resolution which is what my Galaxy S4 has.
Changing 


      float gameWidth = screenWidth / (gameHeight / screenHeight);


to

      float gameWidth = screenWidth / (screenHeight / gameHeight);

fixed the problem for me. But logically it should be the other way around. We want gameWidth to scale with screenHeight, which is the height of the device screen, and gameHeight, which is 576 pixels, our designated game height. This change also seems to break things when running the game in an iPad’s  4:3 aspect ratio. We’re not sure what is wrong with this yet.

I also changed the frog’s and flies size slightly. The frog was being scaled in perspective to the wrong origin, it was more to the right than what we wanted and therefore the middle of the frog was not where we expected it to be when calculating the fish’s max y value.
The fly was a bit too big, almost as big as the frog, which does not make sense from a real life perspective.
I also cleaned up some old hitbox detection code that was mostly not used anymore. Before we switched to polygon hit detection we had 2 bounding rectangles for the fish and one rectangle and one circle for the frog. The fish rectangles we’re not being used at all anymore and the frog’s rectangle was being used to make the frog land on the ground. Now we use the frog’s polygon to detect ground collision as well.