contrib/friendz: manage zoom at the application level
[nit.git] / contrib / friendz / src / friendz_android.nit
1 # Monsterz - Chains of Friends
2 #
3 # 2010-2014 (c) Jean Privat <jean@pryen.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the Do What The Fuck You Want To
7 # Public License, Version 2, as published by Sam Hocevar. See
8 # http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9
10 # android version of the game
11 module friendz_android
12
13 import friendz
14 import mnit_android
15 import android::landscape
16
17 redef class App
18 # Zoom applied for the device display from the game logic coordinates
19 var zoom = 1.0
20
21 redef fun window_created
22 do
23 super
24
25 var h = screen_height
26 display.set_viewport(0,0,h*display.width/display.height,h)
27
28 zoom = display.height.to_f / h.to_f
29 end
30 end
31
32 redef class AndroidPointerEvent
33 redef fun is_motion do return not just_went_down
34
35 redef fun x do return super / app.zoom
36 redef fun y do return super / app.zoom
37 end