1 # this file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 # Android part of mnit_ballz
17 module ballz_android
is
18 app_version
(0, 2, git_revision
)
20 app_namespace
"org.nitlanguage.ballz"
24 import android
::portrait
25 import android
::sensors
32 var game
: nullable Game is noautoinit
35 accelerometer
.enabled
= true
36 accelerometer
.event_rate
= 10000
37 magnetic_field
.enabled
= true
38 gyroscope
.enabled
= true
40 proximity
.enabled
= true
42 sensors_support_enabled
= true
49 game
= new Game(display
.width
.to_f
, display
.height
.to_f
)
52 redef fun frame_core
(display
)
57 game
.draw
(display
, assets
)
63 if paused
then return false
64 if ie
isa QuitEvent then
78 redef fun intercepts
(event
)
80 if event
isa ASensorAccelerometer then
81 acceleration
(event
.x
, event
.y
)
82 else if event
isa ASensorMagneticField then
83 #deal with Magnetic field sensor
84 #print "ASensorMagneticField : x = " + event.x.to_s + " y = " + event.y.to_s + " z = " + event.z.to_s
85 else if event
isa ASensorGyroscope then
86 #deal with Gyroscope sensor
87 #print "ASensorGyroscope : x = " + event.x.to_s + " y = " + event.y.to_s + " z = " + event.z.to_s
88 else if event
isa ASensorLight then
89 #deal with light sensor
90 #print "ASensorLight : light = " + event.light.to_s
91 else if event
isa ASensorProximity then
92 #deal with proximity sensor
93 #print "ASensorProximity : distance = " + event.distance.to_s
94 else if event
isa MotionEvent then
105 if ie
isa ASensorAccelerometer or ie
isa MotionEvent then