Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .idea/artifacts/app.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Through the maze
25 changes: 21 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,43 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.danil.throughthemaze"
applicationId "ru.hse.throughthemaze"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 2
versionName "0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
signingConfig signingConfigs.debug
}
}
signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('/home/danil/.android/debug.keystore')
storePassword 'android'
}
}
}

dependencies {
api group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-identity:16.0.0'
implementation 'com.google.android.gms:play-services-games:17.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'org.jetbrains:annotations-java5:15.0'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.danil.throughthemaze;
package ru.hse.throughthemaze;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
Expand All @@ -21,6 +21,6 @@ public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.example.danil.throughthemaze", appContext.getPackageName());
assertEquals("ru.hse.throughthemaze", appContext.getPackageName());
}
}
13 changes: 11 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.danil.throughthemaze">
package="ru.hse.throughthemaze">

<application
android:allowBackup="true"
Expand All @@ -9,13 +9,22 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:name="ru.hse.throughthemaze.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="ru.hse.throughthemaze.AccelerometerService">
</service>
<service android:name="ru.hse.throughthemaze.gameplay.PhysicsEngine">
</service>
</application>

</manifest>
Binary file added app/src/main/assets/databases/maps.sqlite3
Binary file not shown.

This file was deleted.

74 changes: 74 additions & 0 deletions app/src/main/java/ru/hse/throughthemaze/AccelerometerService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package ru.hse.throughthemaze;

import android.app.Service;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.IBinder;
import android.support.annotation.Nullable;
import ru.hse.throughthemaze.gameplay.Ball;

import java.util.Timer;
import java.util.TimerTask;

public class AccelerometerService extends Service {

private SensorManager sensorManager;
private Sensor sensorAcceleration;
private SensorEventListener listener;
private Timer timer;
private Ball ball;

private double ax;
private double ay;

@Override
public int onStartCommand(final Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
ball = intent.getParcelableExtra(Ball.class.getName());
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sensorAcceleration = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
listener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
ax = -event.values[0] * 20;
ay = event.values[1] * 20;
}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};
sensorManager.registerListener(listener, sensorAcceleration, SensorManager.SENSOR_DELAY_GAME);

timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
ball.ax = ax;
ball.ay = ay;
Intent intent = new Intent(Service.SENSOR_SERVICE);
intent.putExtra(Ball.class.getName(), ball);
sendBroadcast(intent);
}
};
timer.schedule(task, 0, MainActivity.UPDATE_FREQUENCY);
return START_STICKY;
}

@Override
public void onDestroy() {
super.onDestroy();
sensorManager.unregisterListener(listener);
timer.cancel();
}

@org.jetbrains.annotations.Nullable
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}

}
Loading