Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. void zoom(float delta, float mouse_x, float mouse_y)
  2. {
  3. zoom += delta;
  4. view.w = window.w/zoom;
  5. view.h = window.h/zoom;
  6. // view.x = ???
  7. // view.y = ???
  8. }
  9.  
  10. view.x = mouse_x - view.w/2;
  11. view.y = mouse_y - view.h/2;
  12.  
  13. Vect2f mouse_true(mouse_position.x/zoom + view.x, mouse_position.y/zoom + view.y);
  14. Vect2f mouse_relative(window_size.x/mouse_pos.x, window_size.y/mouse_pos.y);
  15. view.x = mouse_true.x - view.w/mouse_relative.x;
  16. view.y = mouse_true.y - view.h/mouse_relative.y;
  17.  
  18. var a = (mouse.x + camera.x) / zoom;
  19.  
  20. // now increase the zoom e.g.: like that:
  21. zoom = zoom + 1;
  22.  
  23. var newPosition = a * zoom - mouse.x;
  24.  
  25. camera.setX(newPosition);
  26. screen.setWidth(originalWidth * zoom);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement