tags:

views:

53

answers:

1

Given 2 functions Translate(x,y) and Scale(x), I want the camera's position to always be the center of the screen. There is also a scalefactor variable and by modifying it it either zooms in or out from the center of the screen. Given that I know the dimensions of the screen in pixels, how could I achieve this? Thanks

A: 

Something like this:

screen_coords = (world_coords - camera_world_coords) * camera_zoom + 0.5 * screen_dimension
tdammers
How does this work in terms of Translate() and Scale()?
Milo
@Milo: You're not going to get perfectly working code here. SO is not a "Send me code that does X" site. Read the equation tdammers posted and implement it in terms of Translate and Scale.
Billy ONeal
Hint: the * operator in my example is a scale, the + and - operators are translates. If you can't figure it out with this information, go back to the grindstone.
tdammers