e0dec754157df54941e6535a94097f184c5a5d89
[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 on_create
22 do
23 super
24 var h = screen_height
25 display.set_viewport(0,0,h*display.width/display.height,h)
26
27 zoom = display.height.to_f / h.to_f
28 default_mediaplayer.looping = true
29 end
30
31 redef fun input(input_event)
32 do
33 if input_event isa KeyEvent then
34 return false
35 else
36 return super
37 end
38 end
39 end
40
41 redef class AndroidPointerEvent
42 redef fun is_motion do return is_move
43
44 redef fun x do return super / app.zoom
45 redef fun y do return super / app.zoom
46 end