├── mobile ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_watch.png │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── colors.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ ├── grey_circle.xml │ │ │ │ ├── red_circle.xml │ │ │ │ ├── green_circle.xml │ │ │ │ └── wear_button_bg.xml │ │ │ ├── menu │ │ │ │ └── my.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_my.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── at │ │ │ └── maui │ │ │ └── flopsydroid │ │ │ └── MyActivity.java │ └── androidTest │ │ └── java │ │ └── at │ │ └── maui │ │ └── flopsydroid │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── README.md ├── wear ├── assets │ ├── flopsy.png │ ├── flappyfont.png │ ├── flopsy.sprites │ └── flappyfont.fnt ├── libs │ ├── x86 │ │ └── libgdx.so │ ├── armeabi │ │ └── libgdx.so │ └── armeabi-v7a │ │ └── libgdx.so ├── ic_launcher-web.png ├── res │ ├── drawable-xxhdpi │ │ ├── ic_won.png │ │ ├── ic_about.png │ │ ├── ic_game.png │ │ └── ic_launcher.png │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── menu │ │ └── main_menu.xml │ ├── layout │ │ ├── activity_menu.xml │ │ ├── activity_high_score.xml │ │ ├── round_activity_menu.xml │ │ ├── rect_activity_menu.xml │ │ ├── activity_about.xml │ │ ├── rect_activity_high_score.xml │ │ └── round_activity_high_score.xml │ └── drawable │ │ └── wear_button_bg.xml ├── src │ └── at │ │ └── maui │ │ └── flopsydroid │ │ └── android │ │ ├── activities │ │ ├── AboutActivity.java │ │ ├── HighScoreActivity.java │ │ ├── GameActivity.java │ │ └── MenuActivity.java │ │ ├── service │ │ └── DeviceDataListenerService.java │ │ ├── Utils.java │ │ ├── widgets │ │ └── WearButton.java │ │ └── adapter │ │ └── MenuGridViewPagerAdapter.java ├── project.properties ├── proguard-project.txt ├── AndroidManifest.xml └── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── core ├── src │ ├── at │ │ └── maui │ │ │ └── flopsydroid │ │ │ ├── game │ │ │ ├── OnScoreListener.java │ │ │ ├── OnDroidCollisionListener.java │ │ │ ├── OnGlobalListener.java │ │ │ ├── Utils.java │ │ │ ├── Ground.java │ │ │ ├── Pipe.java │ │ │ ├── Droid.java │ │ │ └── FlopsyScreen.java │ │ │ └── FlopsyDroidGame.java │ └── FlopsyDroidGame.gwt.xml └── build.gradle ├── desktop ├── src │ └── at │ │ └── maui │ │ └── flopsydroid │ │ └── desktop │ │ └── DesktopLauncher.java └── build.gradle ├── .gitignore ├── gradlew.bat ├── gradlew └── LICENSE /mobile/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'desktop', 'mobile', 'wear', 'core' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | flopsydroid 2 | =========== 3 | 4 | Flopsy Droid 5 | -------------------------------------------------------------------------------- /wear/assets/flopsy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/assets/flopsy.png -------------------------------------------------------------------------------- /wear/libs/x86/libgdx.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/libs/x86/libgdx.so -------------------------------------------------------------------------------- /wear/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/ic_launcher-web.png -------------------------------------------------------------------------------- /wear/assets/flappyfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/assets/flappyfont.png -------------------------------------------------------------------------------- /wear/libs/armeabi/libgdx.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/libs/armeabi/libgdx.so -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=true 2 | org.gradle.jvmargs=-Xms128m -Xmx256m 3 | org.gradle.configureondemand=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /wear/libs/armeabi-v7a/libgdx.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/libs/armeabi-v7a/libgdx.so -------------------------------------------------------------------------------- /wear/res/drawable-xxhdpi/ic_won.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-xxhdpi/ic_won.png -------------------------------------------------------------------------------- /wear/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/res/drawable-xxhdpi/ic_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-xxhdpi/ic_about.png -------------------------------------------------------------------------------- /wear/res/drawable-xxhdpi/ic_game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-xxhdpi/ic_game.png -------------------------------------------------------------------------------- /wear/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/wear/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-xxhdpi/ic_watch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/mobile/src/main/res/drawable-xxhdpi/ic_watch.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/mobile/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/mobile/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/mobile/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mauimauer/flopsydroid/HEAD/mobile/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/OnScoreListener.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | /** 4 | * Created by maui on 08.07.2014. 5 | */ 6 | public interface OnScoreListener { 7 | 8 | public void onScored(); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/OnDroidCollisionListener.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | /** 4 | * Created by maui on 08.07.2014. 5 | */ 6 | public interface OnDroidCollisionListener { 7 | public void onDroidCollision(); 8 | } 9 | -------------------------------------------------------------------------------- /wear/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #ff1ce520 5 | #ff07aa26 6 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/OnGlobalListener.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | /** 4 | * Created by maui on 08.07.2014. 5 | */ 6 | public interface OnGlobalListener extends OnScoreListener{ 7 | public void onGameOver(int score); 8 | } 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | sourceCompatibility = 1.6 4 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 5 | 6 | sourceSets.main.java.srcDirs = [ "src/" ] 7 | 8 | 9 | eclipse.project { 10 | name = appName + "-core" 11 | } 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 21 13:08:26 CEST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip 7 | -------------------------------------------------------------------------------- /core/src/FlopsyDroidGame.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/grey_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/red_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/green_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/Utils.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * Created by maui on 08.07.2014. 7 | */ 8 | public class Utils { 9 | 10 | public static int random(int min, int max) { 11 | Random random = new Random(); 12 | return random.nextInt((max - min) + 1) + min; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/menu/my.xml: -------------------------------------------------------------------------------- 1 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/androidTest/java/at/maui/flopsydroid/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /wear/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 100dp 4 | 10dp 5 | 50dp 6 | 10dp 7 | 5dp 8 | 40dp 9 | 40dp 10 | 11 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/activities/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.activities; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | import at.maui.flopsydroid.android.R; 7 | 8 | public class AboutActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_about); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #5287ff 5 | #374ef4 6 | #4099FF 7 | #ffffff 8 | #ff21c129 9 | #ffc10e05 10 | #ffc1c0c0 11 | -------------------------------------------------------------------------------- /wear/res/menu/main_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /desktop/src/at/maui/flopsydroid/desktop/DesktopLauncher.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.desktop; 2 | 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication; 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; 5 | import at.maui.flopsydroid.FlopsyDroidGame; 6 | 7 | public class DesktopLauncher { 8 | public static void main (String[] arg) { 9 | LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); 10 | new LwjglApplication(new FlopsyDroidGame(null), config); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /wear/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /wear/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | About 4 | Highscore 5 | Flopsy Droid 6 | Best Score 7 | Game 8 | Start Game 9 | Congrats, new Highscore! %d Pts. 10 | Floppsy Droid\n\nFlying Droids on your Android Wear device.\n\nHacked together by\nSebastian Mauer 11 | 12 | -------------------------------------------------------------------------------- /wear/res/layout/activity_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | -------------------------------------------------------------------------------- /wear/res/layout/activity_high_score.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | -------------------------------------------------------------------------------- /wear/res/layout/round_activity_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /mobile/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Program Files (x86)/Android/android-studio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /wear/res/layout/rect_activity_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /mobile/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "at.maui.flopsydroid" 9 | minSdkVersion 18 10 | targetSdkVersion 20 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | runProguard false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | wearApp project(':wear') 24 | compile 'com.google.android.gms:play-services-wearable:+' 25 | compile 'com.android.support:support-v4:+' 26 | compile 'com.android.support:cardview-v7:+' 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | } 29 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/service/DeviceDataListenerService.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.service; 2 | 3 | import android.content.Intent; 4 | 5 | import com.google.android.gms.wearable.MessageEvent; 6 | import com.google.android.gms.wearable.WearableListenerService; 7 | 8 | import at.maui.flopsydroid.android.activities.MenuActivity; 9 | 10 | /** 11 | * Created by maui on 08.07.2014. 12 | */ 13 | public class DeviceDataListenerService extends WearableListenerService { 14 | private static final String START_ACTIVITY_PATH = "/flopsydroid/wear"; 15 | 16 | @Override 17 | public void onMessageReceived(MessageEvent messageEvent) { 18 | if(messageEvent.getPath().equals(START_ACTIVITY_PATH)) { 19 | Intent watchIntent = new Intent(this, MenuActivity.class); 20 | watchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 21 | startActivity(watchIntent); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /wear/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /wear/res/drawable/wear_button_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/Utils.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android; 2 | 3 | import android.content.Context; 4 | import android.view.Menu; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * Created by maui on 07.07.14. 10 | */ 11 | public class Utils { 12 | private static Class menuBuilderClass; 13 | private static Constructor menuConstructor; 14 | 15 | public static Menu newMenuInstance(Context context) { 16 | try { 17 | 18 | if(menuConstructor == null) { 19 | menuBuilderClass = Class.forName("com.android.internal.view.menu.MenuBuilder"); 20 | menuConstructor = menuBuilderClass.getDeclaredConstructor(Context.class); 21 | } 22 | 23 | Menu m = (Menu) menuConstructor.newInstance(context); 24 | 25 | return m; 26 | 27 | } catch (Exception e) { 28 | 29 | } 30 | 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/widgets/WearButton.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.widgets; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.ImageButton; 6 | 7 | /** 8 | * Created by maui on 07.07.14. 9 | */ 10 | public class WearButton extends ImageButton { 11 | 12 | public WearButton(Context context, AttributeSet attrs) { 13 | super(context, attrs); 14 | } 15 | 16 | public WearButton(Context context) { 17 | super(context); 18 | } 19 | 20 | public WearButton(Context context, AttributeSet attrs, int defStyle) { 21 | super(context, attrs, defStyle); 22 | } 23 | 24 | @Override 25 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 26 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 27 | 28 | int width = getMeasuredWidth(); 29 | setMeasuredDimension(width, width); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/wear_button_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /wear/assets/flopsy.sprites: -------------------------------------------------------------------------------- 1 | 2 | flopsy.png 3 | size: 674,446 4 | format: RGBA8888 5 | filter: Nearest,Nearest 6 | repeat: none 7 | andy 8 | rotate: false 9 | xy: 2, 2 10 | size: 64, 64 11 | orig: 64, 64 12 | offset: 0, 0 13 | index: 1 14 | andy 15 | rotate: false 16 | xy: 432, 324 17 | size: 64, 64 18 | orig: 64, 64 19 | offset: 0, 0 20 | index: 2 21 | andy 22 | rotate: false 23 | xy: 68, 2 24 | size: 64, 64 25 | orig: 64, 64 26 | offset: 0, 0 27 | index: 3 28 | bg 29 | rotate: false 30 | xy: 2, 68 31 | size: 320, 320 32 | orig: 320, 320 33 | offset: 0, 0 34 | index: -1 35 | ground 36 | rotate: false 37 | xy: 2, 390 38 | size: 672, 56 39 | orig: 672, 56 40 | offset: 0, 0 41 | index: -1 42 | pipe 43 | rotate: false 44 | xy: 324, 68 45 | size: 52, 320 46 | orig: 52, 320 47 | offset: 0, 0 48 | index: 1 49 | pipe 50 | rotate: false 51 | xy: 378, 68 52 | size: 52, 320 53 | orig: 52, 320 54 | offset: 0, 0 55 | index: 2 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Java 2 | 3 | *.class 4 | *.war 5 | *.ear 6 | hs_err_pid* 7 | 8 | ## GWT 9 | war/ 10 | html/war/gwt_bree/ 11 | html/gwt-unitCache/ 12 | .apt_generated/ 13 | html/war/WEB-INF/deploy/ 14 | html/war/WEB-INF/classes/ 15 | .gwt/ 16 | gwt-unitCache/ 17 | www-test/ 18 | .gwt-tmp/ 19 | 20 | ## Android Studio and Intellij and Android in general 21 | android/libs/armeabi/ 22 | android/libs/armeabi-v7a/ 23 | android/libs/x86/ 24 | android/gen/ 25 | .idea/ 26 | *.ipr 27 | *.iws 28 | *.iml 29 | out/ 30 | com_crashlytics_export_strings.xml 31 | 32 | ## Eclipse 33 | .classpath 34 | .project 35 | .metadata 36 | **/bin/ 37 | tmp/ 38 | *.tmp 39 | *.bak 40 | *.swp 41 | *~.nib 42 | local.properties 43 | .settings/ 44 | .loadpath 45 | .externalToolBuilders/ 46 | *.launch 47 | 48 | ## NetBeans 49 | **/nbproject/private/ 50 | build/ 51 | nbbuild/ 52 | dist/ 53 | nbdist/ 54 | nbactions.xml 55 | nb-configuration.xml 56 | 57 | ## Gradle 58 | 59 | .gradle 60 | build/ 61 | 62 | ## OS Specific 63 | .DS_Store 64 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/FlopsyDroidGame.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid; 2 | 3 | import com.badlogic.gdx.Game; 4 | import com.badlogic.gdx.assets.AssetManager; 5 | import com.badlogic.gdx.math.Vector2; 6 | 7 | import at.maui.flopsydroid.game.FlopsyScreen; 8 | import at.maui.flopsydroid.game.OnGlobalListener; 9 | 10 | public class FlopsyDroidGame extends Game { 11 | 12 | private static final Vector2 VIEWPORT = new Vector2(320, 480); 13 | private AssetManager mAssetManager = new AssetManager(); 14 | 15 | private OnGlobalListener mListener; 16 | 17 | public FlopsyDroidGame(OnGlobalListener listener) { 18 | mListener = listener; 19 | } 20 | 21 | @Override 22 | public void create () { 23 | setScreen(new FlopsyScreen(this, mListener)); 24 | } 25 | 26 | @Override 27 | public void dispose() { 28 | mAssetManager.dispose(); 29 | super.dispose(); 30 | } 31 | 32 | public AssetManager getAssetManager() { 33 | return mAssetManager; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mobile/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /wear/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/activities/HighScoreActivity.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.activities; 2 | 3 | import android.app.Activity; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.support.wearable.view.WatchViewStub; 7 | import android.widget.TextView; 8 | 9 | import at.maui.flopsydroid.android.R; 10 | 11 | public class HighScoreActivity extends Activity { 12 | 13 | private TextView mHighScoreView; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_high_score); 19 | 20 | final SharedPreferences mPreferences = getSharedPreferences("floppsy_droid", MODE_PRIVATE); 21 | 22 | final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); 23 | stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { 24 | @Override 25 | public void onLayoutInflated(WatchViewStub stub) { 26 | mHighScoreView = (TextView) stub.findViewById(R.id.highscore); 27 | mHighScoreView.setText(""+mPreferences.getInt("highscore", 0)); 28 | } 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /wear/assets/flappyfont.fnt: -------------------------------------------------------------------------------- 1 | info face="font" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 2 | common lineHeight=36 base=26 scaleW=128 scaleH=128 pages=1 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0 3 | page id=0 file="flappyfont.png" 4 | chars count=12 5 | char id=48 x=25 y=37 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="0" 6 | char id=49 x=75 y=0 width=16 height=36 xoffset=0 yoffset=0 xadvance=19 page=0 chnl=0 letter="1" 7 | char id=50 x=50 y=37 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="2" 8 | char id=51 x=50 y=0 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="3" 9 | char id=52 x=25 y=74 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="4" 10 | char id=53 x=50 y=74 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="5" 11 | char id=54 x=25 y=0 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="6" 12 | char id=55 x=0 y=74 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="7" 13 | char id=56 x=0 y=37 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="8" 14 | char id=57 x=0 y=0 width=24 height=36 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="9" 15 | char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=0 letter=" " 16 | char id=9 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=128 page=0 chnl=0 letter=" " 17 | 18 | kernings count=0 19 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/Ground.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | 4 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 5 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 6 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 7 | 8 | /** 9 | * Created by maui on 08.07.2014. 10 | */ 11 | public class Ground extends Image implements OnDroidCollisionListener { 12 | 13 | public static final float GROUND_WIDTH = 336f; 14 | public static final float GROUND_HEIGHT = 36f; 15 | 16 | private Droid mAndy; 17 | private boolean mHit; 18 | 19 | public Ground(TextureRegion region, Droid andy) { 20 | super(region); 21 | 22 | mAndy = andy; 23 | addAction(Actions.forever(Actions.moveBy(-GROUND_WIDTH, 0f, 3f))); 24 | mHit = true; 25 | } 26 | 27 | @Override 28 | public void act(float delta) { 29 | super.act(delta); 30 | if (getX() <= -GROUND_WIDTH) { 31 | setX(0); 32 | } 33 | if (checkCollision()) { 34 | mAndy.hitGround(); 35 | /*if (mHit && Pipe.getPIPE_HIT() == 1) { 36 | mHit = false; 37 | // TODO: Vibrate 38 | }*/ 39 | } 40 | } 41 | 42 | public boolean checkCollision() { 43 | if (mAndy.getY() <= GROUND_HEIGHT) { 44 | return true; 45 | } else { 46 | return false; 47 | } 48 | } 49 | 50 | @Override 51 | public void onDroidCollision() { 52 | clearActions(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /desktop/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | sourceCompatibility = 1.6 4 | sourceSets.main.java.srcDirs = [ "src/" ] 5 | 6 | project.ext.mainClassName = "at.maui.flopsydroid.desktop.DesktopLauncher" 7 | project.ext.assetsDir = new File("../wear/assets"); 8 | 9 | task run(dependsOn: classes, type: JavaExec) { 10 | main = project.mainClassName 11 | classpath = sourceSets.main.runtimeClasspath 12 | standardInput = System.in 13 | workingDir = project.assetsDir 14 | ignoreExitValue = true 15 | } 16 | 17 | task dist(type: Jar) { 18 | from files(sourceSets.main.output.classesDir) 19 | from files(sourceSets.main.output.resourcesDir) 20 | from {configurations.compile.collect {zipTree(it)}} 21 | from files(project.ext.assetsDir); 22 | 23 | manifest { 24 | attributes 'Main-Class': project.mainClassName 25 | } 26 | } 27 | 28 | dist.dependsOn classes 29 | 30 | eclipse { 31 | project { 32 | name = appName + "-desktop" 33 | linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/wear/assets' 34 | } 35 | } 36 | 37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") { 38 | doLast { 39 | def classpath = new XmlParser().parse(file(".classpath")) 40 | new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]); 41 | def writer = new FileWriter(file(".classpath")) 42 | def printer = new XmlNodePrinter(new PrintWriter(writer)) 43 | printer.setPreserveWhitespace(true) 44 | printer.print(classpath) 45 | } 46 | } -------------------------------------------------------------------------------- /mobile/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flopsy Droid 5 | Flopsy Droid 6 | Hello world! 7 | Settings 8 | Welcome to Flopsy Droid! 9 | It\'s a little game inspired by Flappy Bird ported and fine-tuned to be played on an Android Wear Device. The Android Wear App should have silently installed Flopsy Droid on your Wearable when you\'ve installed this App on your Smartphone.\n\nYou can find the code of Flopsy Droid here:\nhttp://www.github.com/mauimauer/flopsydroid\n\nPro-Tip: Click the blue bubble on the left to start Flopsy Droid on your Wearable. Alternative use the \"OK Google, Start Flopsy Droid\" Voice Command on your Wearable.\n\nFind me on Google+:\nhttps://plus.google.com/+SebastianMauer 10 | Flopy Droid is an Experiment and made possible by Open Source.\nThis game and the sourcecode is made available on Github. Use it to learn and improve your Android Developer skills, don\'t be a douche and try to sell this work.\n\n\nResources and Idea:\nhttp://lanica.co/flappy-clone/\n\nBugdroid Asset:\nReplica Island\nhttps://code.google.com/p/replicaisland/\n\nLicensed under the Terms of\nthe Apache 2.0 License\nhttp://www.apache.org/licenses/LICENSE-2.0.html\n\nUsing libGDX by Bad Logic Games. Licensed under the Terms of\nthe Apache 2.0 License\nhttp://www.apache.org/licenses/LICENSE-2.0.html 11 | 12 | 13 | -------------------------------------------------------------------------------- /wear/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | 22 | -verbose 23 | 24 | -dontwarn android.support.** 25 | -dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication 26 | -dontwarn com.badlogic.gdx.utils.GdxBuild 27 | -dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild 28 | -dontwarn com.badlogic.gdx.jnigen.BuildTarget* 29 | 30 | -keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* { 31 | (com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration); 32 | } 33 | 34 | -keepclassmembers class com.badlogic.gdx.physics.box2d.World { 35 | boolean contactFilter(long, long); 36 | void beginContact(long); 37 | void endContact(long); 38 | void preSolve(long, long); 39 | void postSolve(long, long); 40 | boolean reportFixture(long); 41 | float reportRayFixture(long, float, float, float, float, float); 42 | } 43 | -------------------------------------------------------------------------------- /wear/res/layout/rect_activity_high_score.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 21 | 24 | 30 | 31 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /wear/res/layout/round_activity_high_score.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 21 | 24 | 30 | 31 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /wear/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 38 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/activities/GameActivity.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.activities; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.os.Vibrator; 8 | import android.widget.Toast; 9 | 10 | import com.badlogic.gdx.backends.android.AndroidApplication; 11 | import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; 12 | import at.maui.flopsydroid.FlopsyDroidGame; 13 | import at.maui.flopsydroid.android.R; 14 | import at.maui.flopsydroid.game.OnGlobalListener; 15 | 16 | public class GameActivity extends AndroidApplication { 17 | 18 | private SharedPreferences mPreferences; 19 | 20 | private Handler mHandler = new Handler(); 21 | 22 | @Override 23 | protected void onCreate (Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 26 | 27 | mPreferences = getSharedPreferences("floppsy_droid", MODE_PRIVATE); 28 | 29 | final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); 30 | 31 | initialize(new FlopsyDroidGame(new OnGlobalListener() { 32 | @Override 33 | public void onGameOver(final int score) { 34 | vibrator.vibrate(1000); 35 | 36 | int highScore = mPreferences.getInt("highscore", 0); 37 | if(score > highScore) { 38 | mPreferences.edit().putInt("highscore", score).commit(); 39 | mHandler.post(new Runnable() { 40 | @Override 41 | public void run() { 42 | Toast.makeText(GameActivity.this, getString(R.string.new_highscore, score), Toast.LENGTH_LONG).show(); 43 | } 44 | }); 45 | } 46 | } 47 | 48 | @Override 49 | public void onScored() { 50 | vibrator.vibrate(100); 51 | } 52 | }), config); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/activities/MenuActivity.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.activities; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.res.Resources; 6 | import android.os.Bundle; 7 | import android.support.wearable.view.GridViewPager; 8 | import android.support.wearable.view.WatchViewStub; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | import android.view.WindowInsets; 12 | 13 | import at.maui.flopsydroid.android.R; 14 | import at.maui.flopsydroid.android.adapter.MenuGridViewPagerAdapter; 15 | 16 | public class MenuActivity extends Activity { 17 | 18 | private GridViewPager pager; 19 | 20 | private MenuGridViewPagerAdapter mAdapter; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_menu); 26 | 27 | mAdapter = new MenuGridViewPagerAdapter(MenuActivity.this, R.menu.main_menu); 28 | mAdapter.setOnItemClickedListener(new MenuGridViewPagerAdapter.OnItemClickListener() { 29 | @Override 30 | public void onItemClicked(View v, MenuItem item) { 31 | switch(item.getItemId()) { 32 | case R.id.start_game: 33 | startActivity(new Intent(MenuActivity.this, GameActivity.class)); 34 | break; 35 | case R.id.highscore: 36 | startActivity(new Intent(MenuActivity.this, HighScoreActivity.class)); 37 | break; 38 | case R.id.about: 39 | startActivity(new Intent(MenuActivity.this, AboutActivity.class)); 40 | break; 41 | } 42 | } 43 | }); 44 | 45 | final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); 46 | stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { 47 | @Override 48 | public void onLayoutInflated(WatchViewStub stub) { 49 | pager = (GridViewPager) stub.findViewById(R.id.pager); 50 | 51 | final Resources res = getResources(); 52 | pager.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { 53 | @Override 54 | public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { 55 | // Adjust page margins: 56 | // A little extra horizontal spacing between pages looks a bit 57 | // less crowded on a round display. 58 | final boolean round = insets.isRound(); 59 | int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin); 60 | int colMargin = res.getDimensionPixelOffset(round ? 61 | R.dimen.page_column_margin_round : R.dimen.page_column_margin); 62 | pager.setPageMargins(rowMargin, colMargin); 63 | return insets; 64 | } 65 | }); 66 | 67 | pager.setAdapter(mAdapter); 68 | } 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/Pipe.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 4 | import com.badlogic.gdx.scenes.scene2d.Stage; 5 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 6 | import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; 7 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 8 | 9 | /** 10 | * Created by maui on 08.07.2014. 11 | */ 12 | public class Pipe extends Image { 13 | 14 | public static final float PIPE_HOLE = 102f; 15 | 16 | private Droid mAndy; 17 | 18 | private Stage mStage; 19 | private boolean mCountPipe = false; 20 | 21 | private OnScoreListener mListener; 22 | 23 | public Pipe(TextureRegion region, Stage stage, Droid droid) { 24 | this(region, stage, droid, false, null); 25 | } 26 | 27 | public Pipe(TextureRegion region, Stage stage, Droid droid, boolean countPipe, OnScoreListener listener) { 28 | super(region); 29 | 30 | mAndy = droid; 31 | mStage = stage; 32 | 33 | mCountPipe = countPipe; 34 | mListener = listener; 35 | 36 | MoveByAction moveLeft = new MoveByAction(); 37 | moveLeft.setDuration(FlopsyScreen.SPEED); 38 | moveLeft.setAmountX(-Ground.GROUND_WIDTH); 39 | addAction(Actions.forever(moveLeft)); 40 | } 41 | 42 | @Override 43 | public void act(float delta) { 44 | super.act(delta); 45 | 46 | if (mAndy.isDead()) { 47 | clearActions(); 48 | return; 49 | } 50 | 51 | if (getX() < -getWidth()) { 52 | remove(); 53 | } 54 | 55 | if (getX() <= mAndy.getX()) { 56 | if (mAndy.getY() >= mStage.getViewport().getViewportHeight()) { 57 | mAndy.gotHit(); 58 | } 59 | 60 | if (mCountPipe && mListener != null) { 61 | mCountPipe = false; 62 | mListener.onScored(); 63 | } 64 | } 65 | 66 | checkCollision(); 67 | } 68 | 69 | public void addScore() { 70 | if (getX() <= mAndy.getX()) { 71 | 72 | //Screenplay.land.clearActions(); 73 | //Flappybird.Sounds.get(config.SoundsHit).play(); 74 | 75 | /*if (getScore) { 76 | getScore = false; 77 | bird.updateScore(); 78 | Flappybird.Sounds.get(config.SoundsScore).play(); 79 | }*/ 80 | } 81 | } 82 | 83 | public void checkCollision() { 84 | if (isCollision()) { 85 | mAndy.gotHit(); 86 | //Screenplay.land.clearActions(); 87 | //Flappybird.Sounds.get(config.SoundsHit).play(); 88 | } 89 | } 90 | 91 | public boolean isCollision() { 92 | float d = 20; 93 | float maxx1 = getX() + getWidth(); 94 | float minx1 = getX() + d; 95 | float maxy1 = getY() + getHeight(); 96 | float miny1 = getY() + d; 97 | float maxx2 = mAndy.getX() + mAndy.getWidth(); 98 | float minx2 = mAndy.getX() + d; 99 | float maxy2 = mAndy.getY() + mAndy.getHeight(); 100 | float miny2 = mAndy.getY() + d; 101 | return !(maxx1 < minx2 || maxx2 < minx1 || maxy2 < miny1 || maxy1 < miny2); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/activity_my.xml: -------------------------------------------------------------------------------- 1 | 10 | 13 | 17 | 23 | 28 | 35 | 36 | 41 | 46 | 47 | 55 | 56 | 57 | 58 | 65 | 70 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /wear/src/at/maui/flopsydroid/android/adapter/MenuGridViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.android.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.support.wearable.view.GridPagerAdapter; 6 | import android.support.wearable.view.ImageReference; 7 | import android.view.Gravity; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.LinearLayout; 13 | import android.widget.TextView; 14 | 15 | import at.maui.flopsydroid.android.Utils; 16 | import at.maui.flopsydroid.android.widgets.WearButton; 17 | 18 | 19 | /** 20 | * Created by maui on 04.07.2014. 21 | */ 22 | public class MenuGridViewPagerAdapter extends GridPagerAdapter { 23 | 24 | private Context mContext; 25 | private Menu mMenu; 26 | 27 | private int mBackroundRes; 28 | 29 | private OnItemClickListener mListener; 30 | 31 | public MenuGridViewPagerAdapter(Context ctx, Menu menu) { 32 | mMenu = menu; 33 | mContext = ctx; 34 | } 35 | 36 | public MenuGridViewPagerAdapter(Activity activity, int menuResource) { 37 | mMenu = Utils.newMenuInstance(activity); 38 | activity.getMenuInflater().inflate(menuResource, mMenu); 39 | mContext = activity; 40 | } 41 | 42 | @Override 43 | public ImageReference getBackground(int row, int column) { 44 | return mBackroundRes == 0 ? ImageReference.NONE : ImageReference.forDrawable(mBackroundRes); 45 | } 46 | 47 | @Override 48 | public int getRowCount() { 49 | return 1; 50 | } 51 | 52 | @Override 53 | public int getColumnCount(int i) { 54 | return mMenu.size(); 55 | } 56 | 57 | @Override 58 | protected Object instantiateItem(ViewGroup viewGroup, int row, int col) { 59 | final MenuItem item = mMenu.getItem(col); 60 | 61 | LinearLayout ll = new LinearLayout(mContext); 62 | ll.setOrientation(LinearLayout.VERTICAL); 63 | ll.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); 64 | ll.setPadding(40, 40, 40, 40); 65 | 66 | if(item.getIcon() != null) { 67 | WearButton button = new WearButton(mContext); 68 | button.setImageDrawable(item.getIcon()); 69 | 70 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 0); 71 | lp.weight = 1; 72 | lp.setMargins(45,0,45,45); 73 | 74 | ll.addView(button, lp); 75 | 76 | button.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | if(mListener != null) { 80 | mListener.onItemClicked(v, item); 81 | } 82 | } 83 | }); 84 | } 85 | 86 | TextView tv = new TextView(mContext); 87 | tv.setText(item.getTitle()); 88 | tv.setTextAppearance(mContext, android.R.style.TextAppearance_Medium); 89 | tv.setGravity(Gravity.CENTER); 90 | ll.addView(tv); 91 | 92 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 93 | ll.setTag(item.getItemId()); 94 | 95 | viewGroup.addView(ll, lp); 96 | 97 | return item; 98 | } 99 | 100 | @Override 101 | protected void destroyItem(ViewGroup viewGroup, int i, int i2, Object o) { 102 | 103 | } 104 | 105 | @Override 106 | public boolean isViewFromObject(View view, Object o) { 107 | MenuItem item = (MenuItem) o; 108 | 109 | int tag = (Integer)view.getTag(); 110 | return item.getItemId() == tag; 111 | } 112 | 113 | public int getBackroundRes() { 114 | return mBackroundRes; 115 | } 116 | 117 | public void setBackroundRes(int backroundRes) { 118 | this.mBackroundRes = backroundRes; 119 | } 120 | 121 | 122 | public OnItemClickListener getOnItemClickedListener() { 123 | return mListener; 124 | } 125 | 126 | public void setOnItemClickedListener(OnItemClickListener mListener) { 127 | this.mListener = mListener; 128 | } 129 | 130 | public interface OnItemClickListener { 131 | public void onItemClicked(View v, MenuItem item); 132 | } 133 | } -------------------------------------------------------------------------------- /wear/build.gradle: -------------------------------------------------------------------------------- 1 | android { 2 | buildToolsVersion "19.1.0" 3 | compileSdkVersion 20 4 | sourceSets { 5 | main { 6 | manifest.srcFile 'AndroidManifest.xml' 7 | java.srcDirs = ['src'] 8 | aidl.srcDirs = ['src'] 9 | renderscript.srcDirs = ['src'] 10 | res.srcDirs = ['res'] 11 | assets.srcDirs = ['assets'] 12 | } 13 | 14 | instrumentTest.setRoot('tests') 15 | } 16 | 17 | defaultConfig { 18 | applicationId "at.maui.flopsydroid" 19 | minSdkVersion 20 20 | targetSdkVersion 20 21 | versionCode 1 22 | versionName "1.0" 23 | } 24 | } 25 | 26 | // needed to add JNI shared libraries to APK when compiling on CLI 27 | tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> 28 | pkgTask.jniFolders = new HashSet() 29 | pkgTask.jniFolders.add(new File(projectDir, 'libs')) 30 | } 31 | 32 | // called every time gradle gets executed, takes the native dependencies of 33 | // the natives configuration, and extracts them to the proper libs/ folders 34 | // so they get packed with the APK. 35 | task copyAndroidNatives() { 36 | file("libs/armeabi/").mkdirs(); 37 | file("libs/armeabi-v7a/").mkdirs(); 38 | file("libs/x86/").mkdirs(); 39 | 40 | configurations.natives.files.each { jar -> 41 | def outputDir = null 42 | if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") 43 | if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") 44 | if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 45 | if(outputDir != null) { 46 | copy { 47 | from zipTree(jar) 48 | into outputDir 49 | include "*.so" 50 | } 51 | } 52 | } 53 | } 54 | 55 | task run(type: Exec) { 56 | def path 57 | def localProperties = project.file("../local.properties") 58 | if (localProperties.exists()) { 59 | Properties properties = new Properties() 60 | localProperties.withInputStream { instr -> 61 | properties.load(instr) 62 | } 63 | def sdkDir = properties.getProperty('sdk.dir') 64 | if (sdkDir) { 65 | path = sdkDir 66 | } else { 67 | path = "$System.env.ANDROID_HOME" 68 | } 69 | } else { 70 | path = "$System.env.ANDROID_HOME" 71 | } 72 | 73 | def adb = path + "/platform-tools/adb" 74 | commandLine "$adb", 'shell', 'am', 'start', '-n', 'at.maui.flopsydroid.android/at.maui.flopsydroid.android.activities.GameActivity' 75 | } 76 | 77 | // sets up the Android Eclipse project, using the old Ant based build. 78 | eclipse { 79 | // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin 80 | // ignores any nodes added in classpath.file.withXml 81 | sourceSets { 82 | main { 83 | java.srcDirs "src", 'gen' 84 | } 85 | } 86 | 87 | jdt { 88 | sourceCompatibility = 1.6 89 | targetCompatibility = 1.6 90 | } 91 | 92 | classpath { 93 | plusConfigurations += project.configurations.compile 94 | containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES' 95 | } 96 | 97 | project { 98 | name = appName + "-wear" 99 | natures 'com.android.ide.eclipse.adt.AndroidNature' 100 | buildCommands.clear(); 101 | buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder" 102 | buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder" 103 | buildCommand "org.eclipse.jdt.core.javabuilder" 104 | buildCommand "com.android.ide.eclipse.adt.ApkBuilder" 105 | } 106 | } 107 | 108 | // sets up the Android Idea project, using the old Ant based build. 109 | idea { 110 | module { 111 | sourceDirs += file("src"); 112 | scopes = [ COMPILE: [plus:[project.configurations.compile]]] 113 | 114 | iml { 115 | withXml { 116 | def node = it.asNode() 117 | def builder = NodeBuilder.newInstance(); 118 | builder.current = node; 119 | builder.component(name: "FacetManager") { 120 | facet(type: "android", name: "Android") { 121 | configuration { 122 | option(name: "UPDATE_PROPERTY_FILES", value:"true") 123 | } 124 | } 125 | } 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /mobile/src/main/java/at/maui/flopsydroid/MyActivity.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | 10 | import com.google.android.gms.common.ConnectionResult; 11 | import com.google.android.gms.common.api.GoogleApiClient; 12 | import com.google.android.gms.common.api.ResultCallback; 13 | import com.google.android.gms.wearable.MessageApi; 14 | import com.google.android.gms.wearable.Node; 15 | import com.google.android.gms.wearable.NodeApi; 16 | import com.google.android.gms.wearable.Wearable; 17 | 18 | import java.util.ArrayList; 19 | 20 | import at.maui.flopsydroid.R; 21 | 22 | public class MyActivity extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { 23 | 24 | private GoogleApiClient mGoogleAppiClient; 25 | 26 | ImageView mBtnOnWearable; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_my); 32 | 33 | mBtnOnWearable = (ImageView) findViewById(R.id.startWearable); 34 | mBtnOnWearable.setOnClickListener(new View.OnClickListener() { 35 | @Override 36 | public void onClick(View view) { 37 | getNodes(new OnGotNodesListener() { 38 | @Override 39 | public void onGotNodes(ArrayList nodes) { 40 | if(nodes.size() > 0) { 41 | Wearable.MessageApi.sendMessage( 42 | getGoogleApiClient(), nodes.get(0), "/flopsydroid/wear", null).setResultCallback(new ResultCallback() { 43 | @Override 44 | public void onResult(MessageApi.SendMessageResult result) { 45 | if (!result.getStatus().isSuccess()) { 46 | } 47 | } 48 | }); 49 | } 50 | } 51 | }); 52 | } 53 | }); 54 | 55 | mGoogleAppiClient = new GoogleApiClient.Builder(this) 56 | .addConnectionCallbacks(this) 57 | .addOnConnectionFailedListener(this) 58 | .addApi(Wearable.API) 59 | .build(); 60 | } 61 | 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | // Inflate the menu; this adds items to the action bar if it is present. 66 | getMenuInflater().inflate(R.menu.my, menu); 67 | return true; 68 | } 69 | 70 | @Override 71 | public boolean onOptionsItemSelected(MenuItem item) { 72 | // Handle action bar item clicks here. The action bar will 73 | // automatically handle clicks on the Home/Up button, so long 74 | // as you specify a parent activity in AndroidManifest.xml. 75 | int id = item.getItemId(); 76 | if (id == R.id.action_settings) { 77 | return true; 78 | } 79 | return super.onOptionsItemSelected(item); 80 | } 81 | 82 | protected GoogleApiClient getGoogleApiClient() { 83 | return mGoogleAppiClient; 84 | } 85 | 86 | 87 | @Override 88 | protected void onStart() { 89 | super.onStart(); 90 | 91 | mGoogleAppiClient.connect(); 92 | } 93 | 94 | @Override 95 | protected void onStop() { 96 | super.onStop(); 97 | 98 | if(mGoogleAppiClient.isConnected()) { 99 | mGoogleAppiClient.disconnect(); 100 | } 101 | } 102 | 103 | @Override 104 | public void onConnected(Bundle bundle) { 105 | 106 | } 107 | 108 | @Override 109 | public void onConnectionSuspended(int i) { 110 | 111 | } 112 | 113 | @Override 114 | public void onConnectionFailed(ConnectionResult connectionResult) { 115 | 116 | } 117 | 118 | private void getNodes(final OnGotNodesListener cb) { 119 | Wearable.NodeApi.getConnectedNodes(getGoogleApiClient()).setResultCallback(new ResultCallback() { 120 | @Override 121 | public void onResult(NodeApi.GetConnectedNodesResult nodes) { 122 | ArrayList results= new ArrayList(); 123 | 124 | for (Node node : nodes.getNodes()) { 125 | if(!results.contains(node.getId())) results.add(node.getId()); 126 | } 127 | 128 | cb.onGotNodes(results); 129 | } 130 | }); 131 | } 132 | 133 | public interface OnGotNodesListener { 134 | public void onGotNodes(ArrayList nodes); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/Droid.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | import com.badlogic.gdx.graphics.g2d.Animation; 4 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 5 | import com.badlogic.gdx.math.Interpolation; 6 | import com.badlogic.gdx.scenes.scene2d.Action; 7 | import com.badlogic.gdx.scenes.scene2d.Event; 8 | import com.badlogic.gdx.scenes.scene2d.Stage; 9 | import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction; 10 | import com.badlogic.gdx.scenes.scene2d.actions.ParallelAction; 11 | import com.badlogic.gdx.scenes.scene2d.actions.RotateToAction; 12 | import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; 13 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 14 | import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; 15 | 16 | /** 17 | * Created by maui on 08.07.2014. 18 | */ 19 | public class Droid extends Image { 20 | 21 | public static final int JUMP_HEIGHT = 30; 22 | public static final float JUMP_DURATION = 0.2f; 23 | public static final float ANIMATION_DURATION = 0.6f; 24 | 25 | private Action mCurrentAction; 26 | private Animation mAnimation; 27 | private TextureRegion mCurrentFrame; 28 | 29 | private float mDuration; 30 | private boolean mDead; 31 | private OnDroidCollisionListener mListener; 32 | 33 | public Droid(TextureRegion[] regions, OnDroidCollisionListener listener) { 34 | super(regions[0]); 35 | setOrigin(getWidth() / 2, getHeight() / 2); 36 | mAnimation = new Animation(ANIMATION_DURATION, regions); 37 | mDuration = 0; 38 | mDead = false; 39 | mListener = listener; 40 | } 41 | 42 | @Override 43 | public void act(float delta) { 44 | super.act(delta); 45 | 46 | if (mDead) { 47 | return; 48 | } 49 | 50 | // Update Andy's animation frame 51 | mDuration += delta; 52 | mCurrentFrame = mAnimation.getKeyFrame(mDuration, true); 53 | setDrawable(new TextureRegionDrawable(mCurrentFrame)); 54 | } 55 | 56 | public boolean isDead() { 57 | return mDead; 58 | } 59 | 60 | public void gotHit() { 61 | mDead = true; 62 | 63 | removeAction(mCurrentAction); 64 | RotateToAction faceDown = new RotateToAction(); 65 | faceDown.setDuration(JUMP_DURATION); 66 | faceDown.setRotation(-90); 67 | 68 | MoveToAction moveDown = new MoveToAction(); 69 | moveDown.setDuration(getDownwardDuration(getX(), Ground.GROUND_HEIGHT)); 70 | moveDown.setPosition(getX(), Ground.GROUND_HEIGHT); 71 | moveDown.setInterpolation(Interpolation.sineIn); 72 | 73 | mCurrentAction = new SequenceAction(faceDown, moveDown); 74 | addAction(mCurrentAction); 75 | 76 | if(mListener != null) { 77 | mListener.onDroidCollision(); 78 | mListener = null; 79 | } 80 | } 81 | 82 | public void hitGround() { 83 | mDead = true; 84 | 85 | removeAction(mCurrentAction); 86 | MoveToAction moveDown = new MoveToAction(); 87 | moveDown.setDuration(getDownwardDuration(getX(), Ground.GROUND_HEIGHT)); 88 | moveDown.setPosition(getX(), Ground.GROUND_HEIGHT); 89 | moveDown.setInterpolation(Interpolation.sineIn); 90 | mCurrentAction = new SequenceAction(moveDown); 91 | addAction(mCurrentAction); 92 | 93 | if(mListener != null) { 94 | mListener.onDroidCollision(); 95 | mListener = null; 96 | } 97 | } 98 | 99 | public void tapped() { 100 | removeAction(mCurrentAction); 101 | 102 | float y = getY() + JUMP_HEIGHT; 103 | 104 | RotateToAction faceup = new RotateToAction(); 105 | faceup.setDuration(JUMP_DURATION); 106 | faceup.setRotation(30); 107 | MoveToAction moveup = new MoveToAction(); 108 | moveup.setDuration(JUMP_DURATION); 109 | moveup.setPosition(getX(), y); 110 | moveup.setInterpolation(Interpolation.sineIn); 111 | Action fly = new ParallelAction(faceup, moveup); 112 | RotateToAction faceDown = new RotateToAction(); 113 | 114 | float duration = getDownwardDuration(y, Ground.GROUND_HEIGHT); 115 | faceDown.setDuration(duration); 116 | faceDown.setRotation(-90); 117 | MoveToAction moveDown = new MoveToAction(); 118 | moveDown.setDuration(duration); 119 | moveDown.setPosition(getX(), Ground.GROUND_HEIGHT); 120 | moveDown.setInterpolation(Interpolation.sineIn); 121 | Action fall = new ParallelAction(faceDown, moveDown); 122 | 123 | mCurrentAction = new SequenceAction(fly, fall); 124 | addAction(mCurrentAction); 125 | } 126 | 127 | private float getDownwardDuration(float up, float down) { 128 | float dy = up - down; 129 | float duration; 130 | 131 | if (dy <= JUMP_HEIGHT) { 132 | duration = JUMP_DURATION; 133 | } else { 134 | duration = 0.8f; 135 | } 136 | return duration; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /core/src/at/maui/flopsydroid/game/FlopsyScreen.java: -------------------------------------------------------------------------------- 1 | package at.maui.flopsydroid.game; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Screen; 5 | import com.badlogic.gdx.graphics.GL20; 6 | import com.badlogic.gdx.graphics.g2d.BitmapFont; 7 | import com.badlogic.gdx.graphics.g2d.TextureAtlas; 8 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 9 | import com.badlogic.gdx.scenes.scene2d.Event; 10 | import com.badlogic.gdx.scenes.scene2d.EventListener; 11 | import com.badlogic.gdx.scenes.scene2d.Stage; 12 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 13 | import com.badlogic.gdx.scenes.scene2d.ui.Label; 14 | 15 | import at.maui.flopsydroid.FlopsyDroidGame; 16 | 17 | /** 18 | * Created by maui on 07.07.2014. 19 | */ 20 | public class FlopsyScreen implements Screen { 21 | 22 | public final static float SPEED = 3f; 23 | public final static float PIPE_INTERVAL = 1.4f; 24 | 25 | private TextureAtlas mTextureAtlas; 26 | private Stage mStage; 27 | 28 | private Ground mGround; 29 | private Droid mAndy; 30 | 31 | private float mTimeSinceLastPipe; 32 | 33 | private boolean mInitialTap = false; 34 | 35 | private Label mScoreLabel; 36 | private int mScore = 0; 37 | private Label.LabelStyle mLabelStyle; 38 | 39 | private OnGlobalListener mGlobalListener; 40 | 41 | public FlopsyScreen(FlopsyDroidGame game, OnGlobalListener listener) { 42 | mStage = new Stage(); 43 | 44 | mGlobalListener = listener; 45 | 46 | game.getAssetManager().load("flopsy.sprites", TextureAtlas.class); 47 | game.getAssetManager().finishLoading(); 48 | mTextureAtlas = game.getAssetManager().get("flopsy.sprites", TextureAtlas.class); 49 | 50 | mLabelStyle = new Label.LabelStyle(); 51 | mLabelStyle.font = new BitmapFont(Gdx.files.internal("flappyfont.fnt"), 52 | Gdx.files.internal("flappyfont.png"), false); 53 | 54 | mStage.addListener(new EventListener() { 55 | @Override 56 | public boolean handle(Event event) { 57 | 58 | if(event.getTarget().equals(mAndy)) { 59 | mGround.onDroidCollision(); 60 | return true; 61 | } 62 | 63 | return false; 64 | } 65 | }); 66 | } 67 | 68 | public void addScoreLabel() { 69 | mScoreLabel = new Label("0", mLabelStyle); 70 | mScoreLabel.setPosition( 71 | mStage.getViewport().getViewportWidth() / 2 - mScoreLabel.getWidth() / 2, 72 | mStage.getViewport().getViewportHeight() - mScoreLabel.getHeight()); 73 | mStage.addActor(mScoreLabel); 74 | } 75 | 76 | @Override 77 | public void render(float delta) { 78 | 79 | // Clear frame 80 | Gdx.gl.glClearColor(0, 0, 0, 1); 81 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 82 | 83 | // Handle touches 84 | if(Gdx.input.justTouched()) { 85 | if(!mInitialTap) 86 | mInitialTap = true; 87 | 88 | if(mAndy.isDead()) { 89 | reset(); 90 | } else { 91 | mAndy.tapped(); 92 | } 93 | } 94 | 95 | mTimeSinceLastPipe += delta; 96 | if (mTimeSinceLastPipe > PIPE_INTERVAL && !mAndy.isDead() && mInitialTap) { 97 | mTimeSinceLastPipe = 0; 98 | addPipe(); 99 | } 100 | 101 | mStage.act(); 102 | mStage.draw(); 103 | } 104 | 105 | public void addPipe() { 106 | int r = Utils.random(0, 7); 107 | float dy = r * 10; 108 | r = Utils.random(0, 1); 109 | if (r == 0) { 110 | dy = -dy; 111 | } 112 | Pipe pipe1 = new Pipe(mTextureAtlas.findRegion("pipe", 1), mStage, mAndy, true, new OnScoreListener() { 113 | @Override 114 | public void onScored() { 115 | mScore++; 116 | mScoreLabel.setText(""+mScore); 117 | 118 | if(mGlobalListener != null) 119 | mGlobalListener.onScored(); 120 | } 121 | }); 122 | pipe1.setZIndex(1); 123 | float x = mStage.getViewport().getViewportWidth(); 124 | float y = (mStage.getViewport().getViewportHeight() - Ground.GROUND_HEIGHT) / 2 125 | + Ground.GROUND_HEIGHT + Pipe.PIPE_HOLE / 2; 126 | pipe1.setPosition(x, y + dy); 127 | Pipe pipe2 = new Pipe(mTextureAtlas.findRegion("pipe", 2), mStage, mAndy); 128 | pipe2.setZIndex(1); 129 | y = (mStage.getViewport().getViewportHeight() - Ground.GROUND_HEIGHT) / 2 130 | + Ground.GROUND_HEIGHT - pipe2.getHeight() 131 | - Pipe.PIPE_HOLE / 2; 132 | pipe2.setPosition(x, y + dy); 133 | mStage.addActor(pipe1); 134 | mStage.addActor(pipe2); 135 | 136 | mScoreLabel.setZIndex(pipe1.getZIndex()); 137 | mGround.setZIndex(pipe2.getZIndex()); 138 | mAndy.setZIndex(pipe2.getZIndex()); 139 | } 140 | 141 | @Override 142 | public void resize(int width, int height) { 143 | 144 | } 145 | 146 | @Override 147 | public void show() { 148 | reset(); 149 | } 150 | 151 | @Override 152 | public void hide() { 153 | 154 | } 155 | 156 | @Override 157 | public void pause() { 158 | 159 | } 160 | 161 | @Override 162 | public void resume() { 163 | 164 | } 165 | 166 | @Override 167 | public void dispose() { 168 | 169 | } 170 | 171 | public void reset() { 172 | mStage.clear(); 173 | mInitialTap = false; 174 | addBackground(); 175 | mScore = 0; 176 | addAndy(); 177 | addScoreLabel(); 178 | addGround(); 179 | } 180 | 181 | public void addAndy() { 182 | 183 | TextureRegion[] droidRegions = new TextureRegion[] { 184 | mTextureAtlas.findRegion("andy", 1), mTextureAtlas.findRegion("andy", 2), 185 | mTextureAtlas.findRegion("andy", 3) }; 186 | mAndy = new Droid(droidRegions, new OnDroidCollisionListener() { 187 | @Override 188 | public void onDroidCollision() { 189 | mGround.onDroidCollision(); 190 | 191 | if(mGlobalListener != null) 192 | mGlobalListener.onGameOver(mScore); 193 | } 194 | }); 195 | mAndy.setPosition(mStage.getViewport().getViewportHeight() / 2 - mAndy.getWidth(), 196 | mStage.getViewport().getViewportWidth() / 2); 197 | mStage.addActor(mAndy); 198 | } 199 | 200 | public void addGround() { 201 | mGround = new Ground(mTextureAtlas.findRegion("ground"), mAndy); 202 | mStage.addActor(mGround); 203 | } 204 | 205 | public void addBackground() { 206 | Image bg = new Image(mTextureAtlas.findRegion("bg")); 207 | mStage.addActor(bg); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. --------------------------------------------------------------------------------