├── .classpath ├── .gitignore ├── .gitmodules ├── .idea ├── .name ├── OpenFlappyBird.iml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── LICENSE ├── OpenFlappyBird.iml ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── openflappybird ├── .gitignore ├── build.gradle ├── openflappybird.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── uk │ │ └── co │ │ └── deanwild │ │ └── openflappybird │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── flappy.ttf │ ├── img │ │ ├── background480.png │ │ ├── birdmap.png │ │ ├── instructions.png │ │ ├── pipelower.png │ │ ├── pipesectionlower.png │ │ ├── pipesectionupper.png │ │ └── pipeupper.png │ └── sound │ │ ├── gameover.ogg │ │ ├── jump.ogg │ │ ├── score.ogg │ │ └── song.ogg │ ├── ic_launcher-web.png │ ├── java │ └── uk │ │ └── co │ │ └── deanwild │ │ └── openflappybird │ │ └── game │ │ ├── Bird.java │ │ ├── MainActivity.java │ │ ├── PipePair.java │ │ ├── ResourceManager.java │ │ ├── SceneManager.java │ │ ├── ScoreManager.java │ │ └── ScreenSizeHelper.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ ├── flappy.png │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── proguard-project.txt ├── project.properties └── settings.gradle /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | gen 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "andengine"] 2 | path = andengine 3 | url = /Users/art.beatte/Projects/OpenFlappyBird/andengine 4 | [submodule "andenginePhysicsBox2dExtension"] 5 | path = andenginePhysicsBox2dExtension 6 | url = /Users/art.beatte/Projects/OpenFlappyBird/andenginePhysicsBox2dExtension 7 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | OpenFlappyBird -------------------------------------------------------------------------------- /.idea/OpenFlappyBird.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 31 | 32 | 33 | 44 | 45 | 46 | 64 | 71 | 72 | 85 | 86 | 87 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 109 | 110 | localhost 111 | 5050 112 | 113 | 114 | 115 | 116 | 117 | 118 | Android API 4 Platform 119 | 120 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenFlappyBird 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2014 Dean Wild 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /OpenFlappyBird.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OpenFlappyBird 2 | ============== 3 | 4 | An open source clone of a famous flappy bird game for Android using the amazing [AndEngine][1] 5 | 6 | ![Logo](http://i.imgur.com/UO84Emn.png) 7 | 8 | History 9 | ------- 10 | 11 | When the original Flappy Bird game was removed from Google Play (and other well known app marketplaces), I, along with [thousands][2] of other unimaginative developers rushed to fill that void with our own crappy rip off clones. I must point out though that I merely saw this as an ideal excuse to learn how to use [AndEngine][1] rather than flood Google Play with [malware][3]. Incidently my clone (along with almost every other) was [removed][4] by Google rather swiftly! 12 | 13 | Anyway, in my pursuit of creating the perfect Flappy Bird clone I could find numerous fragmented tutorials, snippets and documentation on AndEngine but I found it frustratingly difficult to find actual examples of real, finished games that were open source - working code is after all the very best form of documentation. 14 | 15 | So, here is my slightly-rough-around-the-edges attempt to reproduce one of the most annoying yet popular games ever to hit mobile devices - I hope it can help some others to get to grips with game development on Android. 16 | 17 | Instructions 18 | -------- 19 | First check out the source of [AndEngine][5], add it to your Eclipse workspace as an Android library project. Check out the source for OpenFlappyBird and add it to your workspace - hopefully the reference to AndEngine should be ok if you have them both in the same directory. If not just remove the broken reference and add it again. 20 | 21 | TODO 22 | -------- 23 | - Never did manage to finish the scoreboard stuff 24 | - Gradle-a-fy all teh things! 25 | - Maybe tidy things up, this was slapped together in 2 about evenings! 26 | 27 | 28 | 29 | [1]: http://www.andengine.org/ 30 | [2]: https://play.google.com/store/search?q=flappy%20bird 31 | [3]: http://uk.pcmag.com/news/33567/nearly-80-percent-of-flappy-bird-clones-contained 32 | [4]: http://i.imgur.com/bJSoYYI.png 33 | [5]: https://github.com/nicolasgramlich/AndEngine 34 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.12.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 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.12-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /openflappybird/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /openflappybird/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 17 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "uk.co.deanwild.openflappybird" 9 | minSdkVersion 8 10 | targetSdkVersion 17 11 | versionCode 137 12 | versionName "1.3.7" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | runProguard false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | compile 'com.android.support:appcompat-v7:20.0.0' 26 | // compile 'com.squareup.picasso:picasso:2.3.2' 27 | compile project(':andengine') 28 | } 29 | -------------------------------------------------------------------------------- /openflappybird/openflappybird.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /openflappybird/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 /Applications/adt-bundle-mac-x86_64/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 | -------------------------------------------------------------------------------- /openflappybird/src/androidTest/java/uk/co/deanwild/openflappybird/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.deanwild.openflappybird; 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 | } -------------------------------------------------------------------------------- /openflappybird/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 17 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /openflappybird/src/main/assets/flappy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/flappy.ttf -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/background480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/background480.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/birdmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/birdmap.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/instructions.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/pipelower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/pipelower.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/pipesectionlower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/pipesectionlower.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/pipesectionupper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/pipesectionupper.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/img/pipeupper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/img/pipeupper.png -------------------------------------------------------------------------------- /openflappybird/src/main/assets/sound/gameover.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/sound/gameover.ogg -------------------------------------------------------------------------------- /openflappybird/src/main/assets/sound/jump.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/sound/jump.ogg -------------------------------------------------------------------------------- /openflappybird/src/main/assets/sound/score.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/sound/score.ogg -------------------------------------------------------------------------------- /openflappybird/src/main/assets/sound/song.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/assets/sound/song.ogg -------------------------------------------------------------------------------- /openflappybird/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /openflappybird/src/main/java/uk/co/deanwild/openflappybird/game/Bird.java: -------------------------------------------------------------------------------- 1 | package uk.co.deanwild.openflappybird.game; 2 | 3 | import java.io.IOException; 4 | 5 | import org.andengine.audio.sound.Sound; 6 | import org.andengine.audio.sound.SoundFactory; 7 | import org.andengine.entity.scene.Scene; 8 | import org.andengine.entity.sprite.AnimatedSprite; 9 | import org.andengine.opengl.texture.TextureOptions; 10 | import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; 11 | import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; 12 | import org.andengine.opengl.texture.atlas.bitmap.BuildableBitmapTextureAtlas; 13 | import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; 14 | import org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder; 15 | import org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder.TextureAtlasBuilderException; 16 | import org.andengine.opengl.texture.region.TiledTextureRegion; 17 | import org.andengine.opengl.vbo.VertexBufferObjectManager; 18 | import org.andengine.ui.activity.SimpleBaseGameActivity; 19 | import org.andengine.util.debug.Debug; 20 | 21 | import android.app.Activity; 22 | 23 | 24 | public class Bird { 25 | 26 | public static final float BITMAP_WIDTH = 1047f; 27 | public static final float BITMAP_HEIGHT = 903f; 28 | 29 | public static final float BIRD_WIDTH = 55.8f; 30 | public static final float BIRD_HEIGHT = 40f; 31 | 32 | protected static final float MAX_DROP_SPEED = 12.0f; 33 | protected static final float GRAVITY = 0.04f; 34 | protected static final float FLAP_POWER = 6f; 35 | 36 | protected static final float BIRD_MAX_FLAP_ANGLE = -20; 37 | protected static final float BIRD_MAX_DROP_ANGLE = 90; 38 | protected static final float FLAP_ANGLE_DRAG = 4.0f; 39 | protected static final float BIRD_FLAP_ANGLE_POWER = 15.0f; 40 | 41 | private AnimatedSprite mSprite; 42 | 43 | protected float mAcceleration = GRAVITY; 44 | protected float mVerticalSpeed; 45 | protected float mCurrentBirdAngle = BIRD_MAX_FLAP_ANGLE; 46 | 47 | 48 | //bird 49 | private static BuildableBitmapTextureAtlas mBirdBitmapTextureAtlas; 50 | private static TiledTextureRegion mBirdTextureRegion; 51 | 52 | // sounds 53 | private static Sound mJumpSound; 54 | 55 | public static void onCreateResources(SimpleBaseGameActivity activity){ 56 | // bird 57 | mBirdBitmapTextureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(), (int)BITMAP_WIDTH, (int)BITMAP_HEIGHT, TextureOptions.NEAREST); 58 | mBirdTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mBirdBitmapTextureAtlas, activity, "birdmap.png", 3, 3); 59 | try { 60 | mBirdBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder(0, 0, 0)); 61 | mBirdBitmapTextureAtlas.load(); 62 | } catch (TextureAtlasBuilderException e) { 63 | e.printStackTrace(); 64 | } 65 | 66 | try { 67 | mJumpSound = SoundFactory.createSoundFromAsset(activity.getSoundManager(), activity, "jump.ogg"); 68 | } catch (final IOException e) { 69 | Debug.e(e); 70 | } 71 | 72 | } 73 | 74 | 75 | private float mBirdYOffset, mBirdXOffset; 76 | 77 | public Bird(float birdXOffset, float birdYOffset, VertexBufferObjectManager mVertexBufferObjectManager, Scene mScene) { 78 | 79 | this.mBirdXOffset = birdXOffset; 80 | this.mBirdYOffset = birdYOffset; 81 | 82 | mSprite = new AnimatedSprite(mBirdXOffset, mBirdYOffset, 55.8f, 40, mBirdTextureRegion, mVertexBufferObjectManager); 83 | mSprite.animate(25); 84 | mSprite.setZIndex(2); 85 | mScene.attachChild(mSprite); 86 | 87 | } 88 | 89 | public void restart(){ 90 | mSprite.animate(25); 91 | mSprite.setY(mBirdYOffset); 92 | mSprite.setX(mBirdXOffset); 93 | mCurrentBirdAngle = 0; 94 | mSprite.setRotation(mCurrentBirdAngle); 95 | } 96 | 97 | public float move(){ 98 | 99 | float newY = mSprite.getY() + mVerticalSpeed; // calculate the birds new height based on the current vertical speed 100 | newY = Math.max(newY, 0); // don't allow through the ceiling 101 | newY = Math.min(newY, MainActivity.FLOOR_BOUND); // don't allow through the floor 102 | mSprite.setY(newY); //apply the new position 103 | 104 | // now calculate the new speed 105 | mAcceleration += GRAVITY; // always applying gravity to current acceleration 106 | mVerticalSpeed += mAcceleration; // always applying the current acceleration tp the current speed 107 | mVerticalSpeed = Math.min(mVerticalSpeed, MAX_DROP_SPEED); // but capping it to a terminal velocity (science bitch) 108 | 109 | if(mVerticalSpeed <= (FLAP_POWER)){ 110 | mCurrentBirdAngle -= BIRD_FLAP_ANGLE_POWER; 111 | }else{ 112 | mCurrentBirdAngle += FLAP_ANGLE_DRAG; 113 | } 114 | 115 | mCurrentBirdAngle = Math.max(mCurrentBirdAngle, BIRD_MAX_FLAP_ANGLE); 116 | mCurrentBirdAngle = Math.min(mCurrentBirdAngle, BIRD_MAX_DROP_ANGLE); 117 | 118 | // now apply bird angle based on current speed 119 | mSprite.setRotation(mCurrentBirdAngle); 120 | 121 | return newY; 122 | } 123 | 124 | public void flap(){ 125 | mVerticalSpeed = (-FLAP_POWER); 126 | mAcceleration = 0; 127 | mJumpSound.play(); 128 | } 129 | 130 | // hover stuff 131 | private static float WRAPAROUND_POINT = (float) (2 * Math.PI); 132 | 133 | private float mHoverStep = 0; 134 | 135 | public void hover(){ 136 | mHoverStep+=0.13f; 137 | if(mHoverStep > WRAPAROUND_POINT) mHoverStep = 0; 138 | 139 | float newY = mBirdYOffset + ((float) (7 * Math.sin(mHoverStep))); 140 | mSprite.setY(newY); 141 | 142 | } 143 | 144 | public AnimatedSprite getSprite() { 145 | return mSprite; 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /openflappybird/src/main/java/uk/co/deanwild/openflappybird/game/MainActivity.java: -------------------------------------------------------------------------------- 1 | package uk.co.deanwild.openflappybird.game; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.andengine.engine.camera.Camera; 6 | import org.andengine.engine.handler.timer.ITimerCallback; 7 | import org.andengine.engine.handler.timer.TimerHandler; 8 | import org.andengine.engine.options.EngineOptions; 9 | import org.andengine.engine.options.ScreenOrientation; 10 | import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; 11 | import org.andengine.entity.scene.IOnSceneTouchListener; 12 | import org.andengine.entity.scene.Scene; 13 | import org.andengine.entity.scene.background.ParallaxBackground; 14 | import org.andengine.input.touch.TouchEvent; 15 | import org.andengine.ui.activity.SimpleBaseGameActivity; 16 | 17 | public class MainActivity extends SimpleBaseGameActivity { 18 | 19 | public static float CAMERA_WIDTH = 485; // this is not final because we dynamically set it at runtime based on the device aspect ratio 20 | public static final float CAMERA_HEIGHT = 800; 21 | private static final float SCROLL_SPEED = 4.5f; // game speed 22 | public static final float FLOOR_BOUND = 601; // 23 | protected static final int PIPE_SPAWN_INTERVAL = 100; // distance between pipe obstacles 24 | 25 | // game states 26 | protected static final int STATE_START = 0; 27 | protected static final int STATE_READY = 1; 28 | protected static final int STATE_PLAYING = 2; 29 | protected static final int STATE_DYING = 3; 30 | protected static final int STATE_DEAD = 4; 31 | 32 | private int GAME_STATE = STATE_READY; 33 | 34 | // objects 35 | private TimerHandler mTimer; 36 | private SceneManager mSceneManager; 37 | private ResourceManager mResourceManager; 38 | private Scene mScene; 39 | private Camera mCamera; 40 | 41 | // sprites 42 | private ParallaxBackground mBackground; 43 | private ArrayList pipes = new ArrayList(); 44 | 45 | // game variables 46 | private int mScore = 0; 47 | protected float mCurrentWorldPosition; 48 | private float mBirdXOffset; 49 | 50 | @Override 51 | public EngineOptions onCreateEngineOptions() { 52 | 53 | CAMERA_WIDTH = ScreenSizeHelper.calculateScreenWidth(this, CAMERA_HEIGHT); 54 | 55 | mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT){ 56 | 57 | private int mPipeSpawnCounter; 58 | 59 | @Override 60 | public void onUpdate(float pSecondsElapsed) { 61 | 62 | switch(GAME_STATE){ 63 | 64 | case STATE_READY: 65 | ready(); 66 | break; 67 | 68 | case STATE_PLAYING: 69 | play(); 70 | break; 71 | 72 | case STATE_DYING: 73 | die(); 74 | break; 75 | } 76 | 77 | super.onUpdate(pSecondsElapsed); 78 | } 79 | 80 | private void ready(){ 81 | 82 | mCurrentWorldPosition -= SCROLL_SPEED; 83 | mSceneManager.mBird.hover(); 84 | 85 | if(!mResourceManager.mMusic.isPlaying()){ 86 | mResourceManager.mMusic.play(); 87 | } 88 | } 89 | 90 | private void die(){ 91 | float newY = mSceneManager.mBird.move(); // get the bird to update itself 92 | if(newY >= FLOOR_BOUND) dead(); 93 | } 94 | 95 | private void play(){ 96 | 97 | mCurrentWorldPosition -= SCROLL_SPEED; 98 | float newY = mSceneManager.mBird.move(); // get the bird to update itself 99 | if(newY >= FLOOR_BOUND) gameOver(); // check if it game over from twatting the floor 100 | 101 | // now create pipes 102 | mPipeSpawnCounter++; 103 | 104 | if(mPipeSpawnCounter > PIPE_SPAWN_INTERVAL){ 105 | mPipeSpawnCounter = 0; 106 | spawnNewPipe(); 107 | } 108 | 109 | // now render the pipes 110 | for (int i = 0; i GetBestScore(context)){ 19 | 20 | SharedPreferences prefs = context.getSharedPreferences( 21 | context.getPackageName() + ".score", Context.MODE_PRIVATE); 22 | 23 | Editor editor = prefs.edit(); 24 | editor.putInt("bestscore", newScore); 25 | editor.commit(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /openflappybird/src/main/java/uk/co/deanwild/openflappybird/game/ScreenSizeHelper.java: -------------------------------------------------------------------------------- 1 | package uk.co.deanwild.openflappybird.game; 2 | 3 | import android.app.Activity; 4 | import android.util.DisplayMetrics; 5 | 6 | public class ScreenSizeHelper { 7 | 8 | public static float calculateScreenWidth(Activity context, float windowHeight){ 9 | DisplayMetrics dm = new DisplayMetrics(); 10 | context.getWindowManager().getDefaultDisplay().getMetrics(dm); 11 | final int realHeight = dm.heightPixels; 12 | final int realWidth = dm.widthPixels; 13 | float ratio = (float)realWidth / (float)realHeight; 14 | return windowHeight * ratio; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-xxhdpi/flappy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-xxhdpi/flappy.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deano2390/OpenFlappyBird/749b6ce8ef6d7e8e19f8937db4d5484b63678ae1/openflappybird/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /openflappybird/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #D451B5 4 | 5 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Open Flappy Bird 5 | 1021847987218 6 | 7 | 8 | -------------------------------------------------------------------------------- /openflappybird/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /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 | 23 | -keep class * extends java.util.ListResourceBundle { 24 | protected Object[][] getContents(); 25 | } 26 | 27 | -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { 28 | public static final *** NULL; 29 | } 30 | 31 | -keepnames @com.google.android.gms.common.annotation.KeepName class * 32 | -keepclassmembernames class * { 33 | @com.google.android.gms.common.annotation.KeepName *; 34 | } 35 | 36 | -keepnames class * implements android.os.Parcelable { 37 | public static final ** CREATOR; 38 | } -------------------------------------------------------------------------------- /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-20 15 | android.library.reference.1=..\\AndEngine 16 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':openflappybird', ':andengine', ':andenginePhysicsBox2dExtension' 2 | --------------------------------------------------------------------------------