I'm not sure if this is the place for this, but I am struggling with doing the math for a game I am making.
I am making code to fill the screen(Stretch the tiles to it fits into the game screen)
Here's my code:
|
setScale(_gameBorder.width / (_tileSize.x*_width), _gameBorder.height / (_tileSize.y*_height) );
|
which is:
width of the game screen / (amount in pixels of each tile*the amount of tiles)
to stretch the width and the same thing for the height.
The result I'm trying to get out of this equation is the size of the game screen divided by the size of all of the tile map, so I can put this in the setScale(Which sets the scale, 1 - same size, 10 - 10 times bigger ect)
the result I get is this:
http://imgur.com/Nd5sR3K
the green and blue picture should take up the yellow bit, which should not be visible.
I'd be happy to give more code(Or all of the code if necessary, but I don't want to embarrass myself :P) in order to give more detail.
Side note: My suspicion is that is may be a rounding error somewhere