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 var display
= self.display
.as(not null)
50 game
= new Game(display
.width
.to_f
, display
.height
.to_f
)
53 redef fun frame_core
(display
)
58 game
.draw
(display
, assets
)
64 if paused
then return false
65 if ie
isa QuitEvent then
79 redef fun intercepts
(event
)
81 if event
isa ASensorAccelerometer then
82 acceleration
(event
.x
, event
.y
)
83 else if event
isa ASensorMagneticField then
84 #deal with Magnetic field sensor
85 #print "ASensorMagneticField : x = " + event.x.to_s + " y = " + event.y.to_s + " z = " + event.z.to_s
86 else if event
isa ASensorGyroscope then
87 #deal with Gyroscope sensor
88 #print "ASensorGyroscope : x = " + event.x.to_s + " y = " + event.y.to_s + " z = " + event.z.to_s
89 else if event
isa ASensorLight then
90 #deal with light sensor
91 #print "ASensorLight : light = " + event.light.to_s
92 else if event
isa ASensorProximity then
93 #deal with proximity sensor
94 #print "ASensorProximity : distance = " + event.distance.to_s
95 else if event
isa MotionEvent then
106 if ie
isa ASensorAccelerometer or ie
isa MotionEvent then