OverkillManatee / beginning-android-games

Automatically exported from code.google.com/p/beginning-android-games
0 stars 0 forks source link

[Chapter 8] p 406 Converting object's texture width/height from world(meters) to screen(pixels) #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Caculations shown in book:

pixelsPerUnitX = screenWidth / worldWidth = 480 / 9.6 = 50 pixels / meter
pixelsPerUnitY = screenHeight / worldHeight = 320 / 6.4 = 50 pixels / meter

Issue: If you divide the pixels by the meters smaller number of meters becomes 
a larger number of pixels

ex: 

480/9.6 = 50 or 320/6.4 = 50
50/1.0 = 50
50/0.5 = 100

Should be:

pixelsPerUnitX = screenWidth / worldWidth = 480 / 9.6 = 50 pixels * meter
pixelsPerUnitY = screenHeight / worldHeight = 320 / 6.4 = 50 pixels * meter

ex:

480/9.6 = 50 or 320/6.4 = 50
50*1.0 = 50
50*0.5 = 25

Original issue reported on code.google.com by imse...@gmail.com on 12 Oct 2011 at 10:24

GoogleCodeExporter commented 9 years ago
In the text "meter" is not a variable.  It is a unit of measure (like 
meters/sec).  In this instance, when you read 50 pixels/meter, you should read 
it as "fifty pixels per meter".

Original comment by stanley....@gmail.com on 15 Mar 2012 at 4:34