├── Content ├── 0.png ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── 9.png ├── logo.png ├── pipe.png ├── bushes.png ├── ground.png ├── player.png ├── score.png ├── buildings.png ├── clouds1.png ├── clouds2.png ├── gameFont.xnb ├── gameOver.png ├── highScore.png ├── pipeTopCap.png ├── bottomGround.png ├── pipeBottomCap.png └── scoreBackground.png ├── Libs ├── iOS │ ├── Lidgren.Network.dll │ ├── MonoGame.Framework.dll │ ├── Lidgren.Network.dll.mdb │ └── MonoGame.Framework.dll.mdb ├── FIRE-o │ ├── Lidgren.Network.dll │ └── MonoGame.Framework.dll ├── Ouya │ ├── Lidgren.Network.dll │ ├── Ouya.Console.Api.dll │ ├── Lidgren.Network.dll.mdb │ ├── MonoGame.Framework.dll │ └── MonoGame.Framework.dll.mdb └── Android │ ├── Lidgren.Network.dll │ ├── Lidgren.Network.dll.mdb │ ├── MonoGame.Framework.dll │ └── MonoGame.Framework.dll.mdb ├── FlappyMonkey.iOS ├── Default@2x.png ├── Default-568h@2x.png ├── GameThumbnail.png ├── Entitlements.plist ├── Main.cs ├── Info.plist ├── Properties │ └── AssemblyInfo.cs └── FlappyMonkey.iOS.csproj ├── Shared ├── Resources │ └── Default-568h@2x.png ├── Fire │ ├── Resources │ │ ├── values │ │ │ └── Strings.xml │ │ └── AboutResources.txt │ └── Fire.csproj ├── GamePhysics.cs ├── FlappyMonkeyLib.shproj ├── FlappyMonkey.Shared.shproj ├── FlappyMonkeyLib.projitems ├── FlappyMonkey.Shared.projitems ├── TopScore.cs ├── Number.cs ├── ParallaxingBackground.cs ├── Wall.cs ├── FlappyMonkeyLib.Fire.csproj ├── Player.cs └── Game1.cs ├── FlappyMonkey.Droid ├── FireContent │ └── tapToFly.png ├── Resources │ ├── drawable │ │ ├── Icon.png │ │ └── Splash.png │ ├── values │ │ └── Styles.xml │ └── AboutResources.txt ├── Properties │ ├── AndroidManifest.xml │ └── AssemblyInfo.cs ├── Assets │ └── AboutAssets.txt ├── Activity1.cs ├── FlappyMonkey.Ouya.csproj ├── FlappyMonkey.Droid.csproj └── FlappyMonkey.Fire.csproj ├── README.md ├── .gitignore ├── FlappyMonkey.sln └── LICENSE /Content/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/0.png -------------------------------------------------------------------------------- /Content/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/1.png -------------------------------------------------------------------------------- /Content/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/2.png -------------------------------------------------------------------------------- /Content/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/3.png -------------------------------------------------------------------------------- /Content/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/4.png -------------------------------------------------------------------------------- /Content/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/5.png -------------------------------------------------------------------------------- /Content/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/6.png -------------------------------------------------------------------------------- /Content/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/7.png -------------------------------------------------------------------------------- /Content/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/8.png -------------------------------------------------------------------------------- /Content/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/9.png -------------------------------------------------------------------------------- /Content/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/logo.png -------------------------------------------------------------------------------- /Content/pipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/pipe.png -------------------------------------------------------------------------------- /Content/bushes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/bushes.png -------------------------------------------------------------------------------- /Content/ground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/ground.png -------------------------------------------------------------------------------- /Content/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/player.png -------------------------------------------------------------------------------- /Content/score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/score.png -------------------------------------------------------------------------------- /Content/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/buildings.png -------------------------------------------------------------------------------- /Content/clouds1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/clouds1.png -------------------------------------------------------------------------------- /Content/clouds2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/clouds2.png -------------------------------------------------------------------------------- /Content/gameFont.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/gameFont.xnb -------------------------------------------------------------------------------- /Content/gameOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/gameOver.png -------------------------------------------------------------------------------- /Content/highScore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/highScore.png -------------------------------------------------------------------------------- /Content/pipeTopCap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/pipeTopCap.png -------------------------------------------------------------------------------- /Content/bottomGround.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/bottomGround.png -------------------------------------------------------------------------------- /Content/pipeBottomCap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/pipeBottomCap.png -------------------------------------------------------------------------------- /Content/scoreBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Content/scoreBackground.png -------------------------------------------------------------------------------- /Libs/iOS/Lidgren.Network.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/iOS/Lidgren.Network.dll -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.iOS/Default@2x.png -------------------------------------------------------------------------------- /Libs/FIRE-o/Lidgren.Network.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/FIRE-o/Lidgren.Network.dll -------------------------------------------------------------------------------- /Libs/Ouya/Lidgren.Network.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Ouya/Lidgren.Network.dll -------------------------------------------------------------------------------- /Libs/Ouya/Ouya.Console.Api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Ouya/Ouya.Console.Api.dll -------------------------------------------------------------------------------- /Libs/iOS/MonoGame.Framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/iOS/MonoGame.Framework.dll -------------------------------------------------------------------------------- /Libs/Android/Lidgren.Network.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Android/Lidgren.Network.dll -------------------------------------------------------------------------------- /Libs/Ouya/Lidgren.Network.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Ouya/Lidgren.Network.dll.mdb -------------------------------------------------------------------------------- /Libs/Ouya/MonoGame.Framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Ouya/MonoGame.Framework.dll -------------------------------------------------------------------------------- /Libs/iOS/Lidgren.Network.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/iOS/Lidgren.Network.dll.mdb -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.iOS/Default-568h@2x.png -------------------------------------------------------------------------------- /FlappyMonkey.iOS/GameThumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.iOS/GameThumbnail.png -------------------------------------------------------------------------------- /Libs/Android/Lidgren.Network.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Android/Lidgren.Network.dll.mdb -------------------------------------------------------------------------------- /Libs/Android/MonoGame.Framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Android/MonoGame.Framework.dll -------------------------------------------------------------------------------- /Libs/FIRE-o/MonoGame.Framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/FIRE-o/MonoGame.Framework.dll -------------------------------------------------------------------------------- /Libs/Ouya/MonoGame.Framework.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Ouya/MonoGame.Framework.dll.mdb -------------------------------------------------------------------------------- /Libs/iOS/MonoGame.Framework.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/iOS/MonoGame.Framework.dll.mdb -------------------------------------------------------------------------------- /Shared/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Shared/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /Libs/Android/MonoGame.Framework.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/Libs/Android/MonoGame.Framework.dll.mdb -------------------------------------------------------------------------------- /FlappyMonkey.Droid/FireContent/tapToFly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.Droid/FireContent/tapToFly.png -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Resources/drawable/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.Droid/Resources/drawable/Icon.png -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Resources/drawable/Splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Clancey/FlappyMonkey/HEAD/FlappyMonkey.Droid/Resources/drawable/Splash.png -------------------------------------------------------------------------------- /Shared/Fire/Resources/values/Strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Fire 4 | 5 | -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Resources/values/Styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FlappyMonkey 2 | ============ 3 | 4 | 5 | With all the "Flappy" Craze, I decided to build one as well. The intial version took about a day. It runs on iOS/Android with only one line of code difference for Ouya. Enjoy! 6 | 7 | 8 | Artwork 9 | =========== 10 | All of the artwork aside from the monkey and the clouds was hand drawn by me. 11 | The monkey is a vectorized version of a Xamarin monkey, photographed by Craig Dunn 12 | The clouds, and the font came from http://www.kenney.nl/ 13 | -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using MonoTouch.Foundation; 5 | using MonoTouch.UIKit; 6 | 7 | namespace FlappyMonkey.iOS 8 | { 9 | [Register ("AppDelegate")] 10 | class Program : UIApplicationDelegate 11 | { 12 | Game1 game; 13 | 14 | public override void FinishedLaunching (UIApplication app) 15 | { 16 | // Fun begins.. 17 | game = new Game1 (); 18 | game.Run (); 19 | } 20 | 21 | /// 22 | /// The main entry point for the application. 23 | /// 24 | static void Main (string[] args) 25 | { 26 | UIApplication.Main (args, null, "AppDelegate"); 27 | } 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); -------------------------------------------------------------------------------- /Shared/GamePhysics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FlappyMonkey 7 | { 8 | static class GamePhysics 9 | { 10 | public const double PlayerJumpLength = 500; 11 | public const double PlayerJumpHeight = -10; 12 | public const double PlayerFallSpeed = .6; 13 | 14 | //Milliseconds 15 | public const double MinimumWallSpawnRate = 2000; 16 | //Used to gradually make it more dificult 17 | public const double StartWallSpawnRate = 2000; 18 | 19 | public const float WallSpeed = 2.5f; 20 | 21 | //Pixels 22 | #if __TV__ 23 | public const int MinimumGapSize = 350; 24 | public const int MaximumGapSize = 400; 25 | #else 26 | public const int MinimumGapSize = 214; 27 | public const int MaximumGapSize = 300; 28 | #endif 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Flappy Monkey 7 | CFBundleIconFiles 8 | 9 | GameThumbnail.png 10 | 11 | CFBundleIdentifier 12 | project.MonoGame.FlappyMonkey.iOS 13 | MinimumOSVersion 14 | 7.0 15 | UISupportedInterfaceOrientations 16 | 17 | UIInterfaceOrientationPortrait 18 | UIInterfaceOrientationPortraitUpsideDown 19 | 20 | UIDeviceFamily 21 | 22 | 1 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Shared/FlappyMonkeyLib.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {59795F1B-9A2B-4959-8893-0D57B20F5A0A} 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Shared/FlappyMonkey.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {42FE0C01-5BE7-4818-93E1-A36BDCD962C8} 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Shared/FlappyMonkeyLib.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | {59795F1B-9A2B-4959-8893-0D57B20F5A0A} 7 | 8 | 9 | FlappyMonkeyLib 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Shared/FlappyMonkey.Shared.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | {42FE0C01-5BE7-4818-93E1-A36BDCD962C8} 7 | 8 | 9 | FlappyMonkey.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FlappyMonkey.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | [assembly: AssemblyTitle ("FlappyMonkey.iOS")] 7 | [assembly: AssemblyDescription ("")] 8 | [assembly: AssemblyConfiguration ("")] 9 | [assembly: AssemblyCompany ("")] 10 | [assembly: AssemblyProduct ("")] 11 | [assembly: AssemblyCopyright ("Clancey")] 12 | [assembly: AssemblyTrademark ("")] 13 | [assembly: AssemblyCulture ("")] 14 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 15 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 16 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 17 | [assembly: AssemblyVersion ("1.0.0")] 18 | // The following attributes are used to specify the signing key for the assembly, 19 | // if desired. See the Mono documentation for more information about signing. 20 | //[assembly: AssemblyDelaySign(false)] 21 | //[assembly: AssemblyKeyFile("")] 22 | 23 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using Android.App; 4 | 5 | // Information about this assembly is defined by the following attributes. 6 | // Change them to the values specific to your project. 7 | [assembly: AssemblyTitle ("FlappyMonkey.Droid")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright ("Clancey")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 16 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 17 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 18 | [assembly: AssemblyVersion ("1.0.0")] 19 | // The following attributes are used to specify the signing key for the assembly, 20 | // if desired. See the Mono documentation for more information about signing. 21 | //[assembly: AssemblyDelaySign(false)] 22 | //[assembly: AssemblyKeyFile("")] 23 | 24 | -------------------------------------------------------------------------------- /Shared/TopScore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO.IsolatedStorage; 3 | using System.IO; 4 | 5 | namespace FlappyMonkey 6 | { 7 | public static class TopScore 8 | { 9 | static TopScore () 10 | { 11 | isoStore = IsolatedStorageFile.GetStore (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null); 12 | current = getScore (); 13 | } 14 | 15 | static int current; 16 | 17 | public static int Current { 18 | get { 19 | return current; 20 | } 21 | set { 22 | if (value <= current) 23 | return; 24 | current = value; 25 | saveScore (current); 26 | } 27 | } 28 | 29 | static IsolatedStorageFile isoStore; 30 | static string fileName = "data"; 31 | 32 | static void saveScore (int score) 33 | { 34 | using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream (fileName, FileMode.Create, isoStore)) { 35 | using (StreamWriter writer = new StreamWriter (isoStream)) { 36 | writer.WriteLine (score); 37 | } 38 | } 39 | 40 | } 41 | 42 | static int getScore () 43 | { 44 | try { 45 | if (isoStore.FileExists (fileName)) { 46 | using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream (fileName, FileMode.Open, isoStore)) { 47 | using (StreamReader reader = new StreamReader (isoStream)) { 48 | int score; 49 | int.TryParse (reader.ReadToEnd (), out score); 50 | return score; 51 | } 52 | } 53 | } 54 | } catch (Exception ex) { 55 | Console.WriteLine (ex); 56 | } 57 | return 0; 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Activity1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Android.App; 3 | using Android.Content; 4 | using Android.Runtime; 5 | using Android.Views; 6 | using Android.Widget; 7 | using Android.OS; 8 | using Microsoft.Xna.Framework; 9 | using Amazon.Device.Notification; 10 | using Android; 11 | 12 | namespace FlappyMonkey 13 | { 14 | [Activity (Label = "FlappyMonkey.Droid", 15 | MainLauncher = true, 16 | Icon = "@drawable/icon", 17 | Theme = "@style/Theme.Splash", 18 | AlwaysRetainTaskState = true, 19 | LaunchMode = Android.Content.PM.LaunchMode.SingleInstance, 20 | ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | 21 | Android.Content.PM.ConfigChanges.KeyboardHidden | 22 | Android.Content.PM.ConfigChanges.Keyboard)] 23 | public class Activity1 : AndroidGameActivity 24 | { 25 | protected override void OnCreate (Bundle bundle) 26 | { 27 | base.OnCreate (bundle); 28 | 29 | // Create our OpenGL view, and display it 30 | Game1.Activity = this; 31 | var g = new Game1 (); 32 | 33 | g.NotifyScore = (s) => { 34 | var builder = new AmazonNotification.Builder (ApplicationContext); 35 | builder.SetSmallIcon (Resource.Drawable.IcPopupReminder); 36 | builder.SetContentTitle ("New High Score!!!"); 37 | builder.SetContentText (string.Format("{0}",s)); 38 | builder.SetType (BuilderType.Info); 39 | 40 | var notificationManager = GetSystemService (Context.NotificationService) 41 | .JavaCast (); 42 | 43 | notificationManager.Notify (1, builder.Build ()); 44 | }; 45 | 46 | SetContentView (g.Window); 47 | g.Run (); 48 | } 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /Shared/Fire/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.axml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable/ 12 | icon.png 13 | 14 | layout/ 15 | main.axml 16 | 17 | values/ 18 | strings.xml 19 | 20 | In order to get the build system to recognize Android resources, set the build action to 21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 22 | instead operate on resource IDs. When you compile an Android application that uses resources, 23 | the build system will package the resources for distribution and generate a class called "R" 24 | (this is an Android convention) that contains the tokens for each one of the resources 25 | included. For example, for the above Resources layout, this is what the R class would expose: 26 | 27 | public class R { 28 | public class drawable { 29 | public const int icon = 0x123; 30 | } 31 | 32 | public class layout { 33 | public const int main = 0x456; 34 | } 35 | 36 | public class strings { 37 | public const int first_string = 0xabc; 38 | public const int second_string = 0xbcd; 39 | } 40 | } 41 | 42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first 44 | string in the dictionary file values/strings.xml. 45 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.axml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable/ 12 | icon.png 13 | 14 | layout/ 15 | main.axml 16 | 17 | values/ 18 | strings.xml 19 | 20 | In order to get the build system to recognize Android resources, set the build action to 21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 22 | instead operate on resource IDs. When you compile an Android application that uses resources, 23 | the build system will package the resources for distribution and generate a class called "R" 24 | (this is an Android convention) that contains the tokens for each one of the resources 25 | included. For example, for the above Resources layout, this is what the R class would expose: 26 | 27 | public class R { 28 | public class drawable { 29 | public const int icon = 0x123; 30 | } 31 | 32 | public class layout { 33 | public const int main = 0x456; 34 | } 35 | 36 | public class strings { 37 | public const int first_string = 0xabc; 38 | public const int second_string = 0xbcd; 39 | } 40 | } 41 | 42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first 44 | string in the dictionary file values/strings.xml. 45 | -------------------------------------------------------------------------------- /Shared/Number.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using Microsoft.Xna.Framework; 4 | using System.Collections.Generic; 5 | using Microsoft.Xna.Framework.Content; 6 | using System.Linq; 7 | 8 | namespace FlappyMonkey 9 | { 10 | public static class Number 11 | { 12 | public enum Alignment 13 | { 14 | Left, 15 | Center, 16 | Right 17 | } 18 | 19 | public static int Height { 20 | get{ return textures ["0"].Height;} 21 | } 22 | 23 | static Dictionary textures; 24 | 25 | public static void Initialize (ContentManager content) 26 | { 27 | if (textures != null) 28 | return; 29 | textures = new Dictionary (); 30 | Enumerable.Range (0, 10).Select (x => x.ToString ()).ToList ().ForEach (x => textures.Add (x, content.Load (x))); 31 | 32 | } 33 | const int padding = 5; 34 | public static void Draw (SpriteBatch spriteBatch,int number, Alignment aligment ,Rectangle rect, int scale = 1) 35 | { 36 | var numbers = number.ToString ().ToCharArray ().Select (n => n.ToString ()); 37 | var images = numbers.Select (n => textures [n]).ToList (); 38 | var width = images.Sum (n => n.Width* scale) + ((images.Count - 1) * padding*scale); 39 | 40 | int x = rect.Left; 41 | if (aligment == Alignment.Right) 42 | x = rect.Right - width; 43 | else if (aligment == Alignment.Center) 44 | x = (rect.Right / 2) - (width / 2); 45 | int y = rect.Top; 46 | var drawRect = new Rectangle (x, y, 0, 0); 47 | 48 | images.ForEach (i => { 49 | drawRect.X =x; 50 | drawRect.Width = i.Width*scale; 51 | drawRect.Height = i.Height*scale; 52 | spriteBatch.Draw ( 53 | i, 54 | null, 55 | drawRect, 56 | null, 57 | null, 58 | 0, 59 | new Vector2(scale), 60 | Color.White, 61 | SpriteEffects.None, 62 | 0.0f); 63 | 64 | 65 | spriteBatch.Draw(i,drawRect,Color.White); 66 | x += i.Width * scale + padding*scale; 67 | }); 68 | } 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | *.Designer.cs 5 | [Cc]omponents 6 | designer.cs 7 | 8 | # mstest test results 9 | TestResults 10 | 11 | ## Ignore Visual Studio temporary files, build results, and 12 | ## files generated by popular Visual Studio add-ons. 13 | 14 | # User-specific files 15 | *.suo 16 | *.user 17 | *.sln.docstates 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Rr]elease/ 22 | x64/ 23 | *_i.c 24 | *_p.c 25 | *.ilk 26 | *.meta 27 | *.obj 28 | *.pch 29 | *.pdb 30 | *.pgc 31 | *.pgd 32 | *.rsp 33 | *.sbr 34 | *.tlb 35 | *.tli 36 | *.tlh 37 | *.tmp 38 | *.log 39 | *.vspscc 40 | *.vssscc 41 | .builds 42 | 43 | # Visual C++ cache files 44 | ipch/ 45 | *.aps 46 | *.ncb 47 | *.opensdf 48 | *.sdf 49 | 50 | # Visual Studio profiler 51 | *.psess 52 | *.vsp 53 | *.vspx 54 | 55 | # Guidance Automation Toolkit 56 | *.gpState 57 | 58 | # ReSharper is a .NET coding add-in 59 | _ReSharper* 60 | 61 | # NCrunch 62 | *.ncrunch* 63 | .*crunch*.local.xml 64 | 65 | # Installshield output folder 66 | [Ee]xpress 67 | 68 | # DocProject is a documentation generator add-in 69 | DocProject/buildhelp/ 70 | DocProject/Help/*.HxT 71 | DocProject/Help/*.HxC 72 | DocProject/Help/*.hhc 73 | DocProject/Help/*.hhk 74 | DocProject/Help/*.hhp 75 | DocProject/Help/Html2 76 | DocProject/Help/html 77 | 78 | # Click-Once directory 79 | publish 80 | 81 | # Publish Web Output 82 | *.Publish.xml 83 | 84 | # NuGet Packages Directory 85 | packages 86 | 87 | # Windows Azure Build Output 88 | csx 89 | *.build.csdef 90 | 91 | # Windows Store app package directory 92 | AppPackages/ 93 | 94 | # Others 95 | [Bb]in 96 | [Oo]bj 97 | sql 98 | TestResults 99 | [Tt]est[Rr]esult* 100 | *.Cache 101 | ClientBin 102 | [Ss]tyle[Cc]op.* 103 | ~$* 104 | *.dbmdl 105 | Generated_Code #added for RIA/Silverlight projects 106 | 107 | # Backup & report files from converting an old project file to a newer 108 | # Visual Studio version. Backup files are not needed, because we have git ;-) 109 | _UpgradeReport_Files/ 110 | Backup*/ 111 | UpgradeLog*.XML 112 | 113 | *.userprefs 114 | 115 | Shared/FlappyMonkeyLib.Droid.csproj 116 | 117 | Shared/FlappyMonkeyLib.iOS.csproj 118 | 119 | Shared/FlappyMonkeyLib.Ouya.csproj 120 | -------------------------------------------------------------------------------- /Shared/Fire/Fire.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {45068DA2-8FD3-4223-BD41-D726BA1D8017} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | Fire 10 | Assets 11 | Resources 12 | Resource 13 | Resources\Resource.designer.cs 14 | True 15 | Fire 16 | v4.4 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug 23 | DEBUG; 24 | prompt 25 | 4 26 | None 27 | false 28 | 29 | 30 | full 31 | true 32 | bin\Release 33 | prompt 34 | 4 35 | false 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Shared/ParallaxingBackground.cs: -------------------------------------------------------------------------------- 1 | // ParallaxingBackground.cs 2 | using System; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Content; 5 | using Microsoft.Xna.Framework.Graphics; 6 | 7 | namespace FlappyMonkey 8 | { 9 | class ParallaxingBackground 10 | { 11 | // The image representing the parallaxing background 12 | Texture2D texture; 13 | // An array of positions of the parallaxing background 14 | Vector2[] positions; 15 | // The speed which the background is moving 16 | float speed; 17 | Vector2 scale = new Vector2 (1, 1); 18 | 19 | public void Initialize (ContentManager content, String texturePath, int y, int screenWidth, int screenHeight, float speed, bool shouldFill = true, bool subtractTextureHeight = false) 20 | { 21 | // Load the background texture we will be using 22 | texture = content.Load (texturePath); 23 | if (subtractTextureHeight) 24 | y -= texture.Height; 25 | var s = shouldFill ? (float)screenHeight / ((float)texture.Height - y) : 1f; 26 | scale = new Vector2 (s, s); 27 | // Set the speed of the background 28 | this.speed = speed; 29 | 30 | // If we divide the screen with the texture width then we can determine the number of tiles need. 31 | // We add 1 to it so that we won't have a gap in the tiling 32 | positions = new Vector2[(int)((screenWidth * s) / texture.Width + 2)]; 33 | 34 | // Set the initial positions of the parallaxing background 35 | for (int i = 0; i < positions.Length; i++) { 36 | // We need the tiles to be side by side to create a tiling effect 37 | positions [i] = new Vector2 (i * texture.Width * s, y); 38 | } 39 | } 40 | 41 | public void Update () 42 | { 43 | // Update the positions of the background 44 | for (int i = 0; i < positions.Length; i++) { 45 | // Update the position of the screen by adding the speed 46 | positions [i].X += speed; 47 | // If the speed has the background moving to the left 48 | if (speed <= 0) { 49 | // Check the texture is out of view then put that texture at the end of the screen 50 | if (positions [i].X <= -texture.Width * scale.X) { 51 | positions [i].X = texture.Width * scale.X * (positions.Length - 1); 52 | } 53 | } 54 | 55 | // If the speed has the background moving to the right 56 | else { 57 | // Check if the texture is out of view then position it to the start of the screen 58 | if (positions [i].X >= texture.Width * scale.X * (positions.Length - 1)) { 59 | positions [i].X = -texture.Width * scale.X; 60 | } 61 | } 62 | } 63 | } 64 | 65 | public void Draw (SpriteBatch spriteBatch) 66 | { 67 | for (int i = 0; i < positions.Length; i++) { 68 | //spriteBatch.Draw(texture, positions[i], Color.White); 69 | 70 | spriteBatch.Draw ( 71 | texture, 72 | positions [i], 73 | null, 74 | null, 75 | null, 76 | 0, 77 | scale, 78 | Color.White, 79 | SpriteEffects.None, 80 | 0.0f); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Shared/Wall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace FlappyMonkey 6 | { 7 | public class Wall 8 | { 9 | // The position of the Wall relative to the top left corner of thescreen 10 | public Vector2 Position; 11 | // The state of the Wall 12 | public bool Active; 13 | // Get the width of the Wall 14 | public int Width { 15 | get{ return Texture.Width; } 16 | } 17 | // Get the height of the Wall 18 | public int Height { get; set; } 19 | // The speed at which the Wall moves 20 | float wallMoveSpeed; 21 | Texture2D Texture, TopCapTexture, BottomCapTexture; 22 | Rectangle Gap; 23 | Rectangle topRect; 24 | Rectangle BottomRect; 25 | Rectangle topCapRect; 26 | Rectangle BottomRectCap; 27 | int topCapOffset, bottomCapOffset; 28 | 29 | public void Initialize (Texture2D texture, Texture2D topCapTexture, Texture2D bottomCapTexture, Rectangle gap, int height, float screenHeight) 30 | { 31 | Position = new Vector2 (gap.X, 0); 32 | Height = height; 33 | 34 | Gap = gap; 35 | 36 | Texture = texture; 37 | TopCapTexture = topCapTexture; 38 | BottomCapTexture = bottomCapTexture; 39 | 40 | topRect = new Rectangle ((int)Position.X, (int)Position.Y, Width, Gap.Top); 41 | BottomRect = new Rectangle ((int)Position.X, Gap.Bottom, Width, height - Gap.Bottom); 42 | //We need to center the caps 43 | if (TopCapTexture != null) { 44 | topCapOffset = (TopCapTexture.Width - texture.Width) / 2; 45 | topCapRect = new Rectangle (0, topRect.Height - topCapTexture.Height, topCapTexture.Width, topCapTexture.Height); 46 | } 47 | if (BottomCapTexture != null) { 48 | bottomCapOffset = (BottomCapTexture.Width - texture.Width) / 2; 49 | BottomRectCap = new Rectangle (0, BottomRect.Y, BottomCapTexture.Width, BottomCapTexture.Height); 50 | } 51 | 52 | 53 | // We initialize the Wall to be active so it will be update in the game 54 | Active = true; 55 | 56 | // Set how fast the Wall moves 57 | wallMoveSpeed = GamePhysics.WallSpeed; 58 | 59 | 60 | } 61 | 62 | public void Update (GameTime gameTime) 63 | { 64 | // The Wall always moves to the left so decrement it's xposition 65 | Position.X -= wallMoveSpeed; 66 | topRect.X = BottomRect.X = Gap.X = (int)Position.X; 67 | 68 | BottomRectCap.X = BottomRect.X - bottomCapOffset; 69 | topCapRect.X = topRect.X - topCapOffset; 70 | 71 | 72 | } 73 | 74 | public void Draw (SpriteBatch spriteBatch) 75 | { 76 | if (Active) { 77 | // Draw the top part of the wall 78 | spriteBatch.Draw ( 79 | Texture, 80 | topRect, 81 | Color.White); 82 | if (TopCapTexture != null) { 83 | spriteBatch.Draw ( 84 | TopCapTexture, 85 | topCapRect, 86 | Color.White); 87 | } 88 | 89 | //Draw the bottom 90 | spriteBatch.Draw ( 91 | Texture, 92 | BottomRect, 93 | Color.White); 94 | if (BottomCapTexture != null) { 95 | spriteBatch.Draw ( 96 | BottomCapTexture, 97 | BottomRectCap, 98 | Color.White); 99 | } 100 | } 101 | } 102 | 103 | int points { get; set; } 104 | 105 | bool PointCollected { get; set; } 106 | 107 | public bool Collides (Rectangle rect) 108 | { 109 | points = (!PointCollected && Gap.Intersects (rect)) ? 1 : 0; 110 | 111 | return rect.Intersects (topRect) || rect.Intersects (BottomRect); 112 | } 113 | 114 | public int CollectPoints () 115 | { 116 | if (points > 0) 117 | PointCollected = true; 118 | return points; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Shared/FlappyMonkeyLib.Fire.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {58B3F31E-EE12-48B8-987F-D5CBB02BA4C7} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | FlappyMonkey 10 | Assets 11 | Resources 12 | Resource 13 | Resources\Resource.designer.cs 14 | True 15 | FlappyMonkeyLib.Ouya 16 | v4.5 17 | OnLoadAutoInsert 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Ouya\Debug 24 | DEBUG;__MOBILE__;__ANDROID__;__FIRE__;__TV__; 25 | prompt 26 | 4 27 | None 28 | false 29 | 30 | 31 | true 32 | bin\Ouya\Release 33 | __MOBILE__;__ANDROID__;__OUYA__;__FIRE__;__TV__; 34 | prompt 35 | 4 36 | false 37 | false 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ..\Components\amazonfiretv-1.0\lib\android\Amazon.FireTV.GameController.dll 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | False 62 | 63 | 64 | 65 | 66 | 1.0 67 | False 68 | 69 | 70 | 71 | 72 | {565129E0-4EE5-4F6F-B403-C3484C9740BE} 73 | Lidgren.Network.Android 74 | 75 | 76 | -------------------------------------------------------------------------------- /Shared/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace FlappyMonkey 6 | { 7 | class Player 8 | { 9 | public Vector2 StartLocation { get; set; } 10 | // Animation representing the player 11 | public Texture2D PlayerTexture; 12 | // Position of the Player relative to the upper left side of the screen 13 | public Vector2 Position; 14 | // State of the player 15 | public bool Active; 16 | // Amount of hit points that player has 17 | public int Health; 18 | // Get the width of the player ship 19 | public int Width {get;set;} 20 | // Get the height of the player ship 21 | public int Height {get;set;} 22 | // Animation representing the player 23 | public Texture2D Texture; 24 | Vector2 DrawOffset; 25 | Vector2 Origin; 26 | float Scale = 1f; 27 | //The height we want the player to always be 28 | const int DesiredHeight = 72; 29 | // Initialize the player 30 | public void Initialize (Texture2D animation, Vector2 position) 31 | { 32 | Texture = animation; 33 | Scale = DesiredHeight / Texture.Height; 34 | Width = (int)(Texture.Width * Scale); 35 | Height = (int)(Texture.Height * Scale); 36 | // Set the starting position of the player around the middle of the screen and to the back 37 | StartLocation = Position = position; 38 | 39 | // Set the player to be active 40 | Active = true; 41 | 42 | // Set the player health 43 | Health = 1; 44 | Origin = new Vector2 (Texture.Width / 2, Texture.Height / 2); 45 | DrawOffset = new Vector2 (Width / 2 , Height / 2); 46 | } 47 | 48 | public Rectangle Rectangle 49 | { 50 | //Make it a tad bit skinnier for a better hitbox 51 | get{ return new Rectangle ((int)Position.X, (int)Position.Y, (int)(Width *.9), Height); } 52 | } 53 | 54 | double jumpTimer = GamePhysics.PlayerJumpLength; 55 | double fallTimer = 0; 56 | bool isJumping = false; 57 | // Update the player animation 58 | public void Update (GameTime gameTime, bool shouldJump, float maxHeight, bool autoFly) 59 | { 60 | jumpTimer += gameTime.ElapsedGameTime.TotalMilliseconds; 61 | 62 | if (Position.X < -Width || Health <= 0) { 63 | // active game list 64 | Active = false; 65 | } 66 | 67 | if (shouldJump && !autoFly) { 68 | isJumping = true; 69 | jumpTimer = 0; 70 | } 71 | 72 | if (Active && isJumping) { 73 | var sin = Math.Sin (jumpTimer * .5 * Math.PI / GamePhysics.PlayerJumpLength); 74 | //Console.WriteLine("sin {0}", sin); 75 | var height = (int)(GamePhysics.PlayerJumpHeight - GamePhysics.PlayerJumpHeight * sin); 76 | Position.Y += height; 77 | fallTimer = 0; 78 | } else { 79 | Position.Y += Convert.ToInt32 (GamePhysics.PlayerFallSpeed * gameTime.ElapsedGameTime.TotalMilliseconds); 80 | fallTimer += gameTime.ElapsedGameTime.TotalMilliseconds; 81 | } 82 | rotation = autoFly ? 0 : TurnToFace (rotation, Rotation (), TurnSpeed); 83 | Position.Y = MathHelper.Clamp (Position.Y, 0, maxHeight - Height); 84 | 85 | if (jumpTimer > GamePhysics.PlayerJumpLength) { 86 | isJumping = false; 87 | } 88 | if (autoFly && Position.Y >= StartLocation.Y) { 89 | isJumping = true; 90 | jumpTimer = 0; 91 | } 92 | } 93 | 94 | private static float TurnToFace (float currentAngle, float targetRotation, float turnSpeed) 95 | { 96 | 97 | // so now we know where we WANT to be facing, and where we ARE facing... 98 | // if we weren't constrained by turnSpeed, this would be easy: we'd just 99 | // return desiredAngle. 100 | // instead, we have to calculate how much we WANT to turn, and then make 101 | // sure that's not more than turnSpeed. 102 | 103 | // first, figure out how much we want to turn, using WrapAngle to get our 104 | // result from -Pi to Pi ( -180 degrees to 180 degrees ) 105 | float difference = WrapAngle (targetRotation - currentAngle); 106 | 107 | // clamp that between -turnSpeed and turnSpeed. 108 | difference = MathHelper.Clamp (difference, -turnSpeed, turnSpeed); 109 | 110 | // so, the closest we can get to our target is currentAngle + difference. 111 | // return that, using WrapAngle again. 112 | return WrapAngle (currentAngle + difference); 113 | } 114 | 115 | /// 116 | /// Returns the angle expressed in radians between -Pi and Pi. 117 | /// the angle to wrap, in radians. 118 | /// the input value expressed in radians from -Pi to Pi. 119 | /// 120 | private static float WrapAngle (float radians) 121 | { 122 | while (radians < -MathHelper.Pi) { 123 | radians += MathHelper.TwoPi; 124 | } 125 | while (radians > MathHelper.Pi) { 126 | radians -= MathHelper.TwoPi; 127 | } 128 | return radians; 129 | } 130 | // Draw the player 131 | public void Draw (SpriteBatch spriteBatch) 132 | { 133 | //spriteBatch.Draw(Texture, Position, Color.White); 134 | spriteBatch.Draw (Texture, Position + DrawOffset, null, Color.White, rotation, Origin, Scale, SpriteEffects.None, 0); 135 | } 136 | 137 | const float TurnSpeed = 0.50f; 138 | float rotation = 0f; 139 | 140 | public float Rotation () 141 | { 142 | const float topAngle = -30; 143 | const float bottomAngle = 90; 144 | if (isJumping) 145 | return MathHelper.ToRadians (topAngle); 146 | 147 | if (!Active || fallTimer > GamePhysics.PlayerJumpLength) 148 | return MathHelper.ToRadians (bottomAngle); 149 | 150 | if (fallTimer < GamePhysics.PlayerJumpLength) { 151 | var sin = (float)Math.Sin (fallTimer * .5 * Math.PI / GamePhysics.PlayerJumpLength); 152 | return MathHelper.ToRadians (sin * bottomAngle); 153 | } 154 | return 0; 155 | } 156 | } 157 | } -------------------------------------------------------------------------------- /FlappyMonkey.iOS/FlappyMonkey.iOS.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | iPhoneSimulator 6 | {9815036A-CCAD-4297-A747-E2ECC5659BB8} 7 | {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Exe 9 | FlappyMonkey.iOS 10 | Resources 11 | FlappyMonkeyiOS 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\iPhoneSimulator\Debug 18 | DEBUG;__MOBILE__;__IOS__; 19 | prompt 20 | 4 21 | false 22 | None 23 | Entitlements.plist 24 | true 25 | 26 | 27 | full 28 | true 29 | bin\iPhoneSimulator\Release 30 | __MOBILE__;__IOS__; 31 | prompt 32 | 4 33 | None 34 | false 35 | Entitlements.plist 36 | 37 | 38 | true 39 | full 40 | false 41 | bin\iPhone\Debug 42 | DEBUG;__MOBILE__;__IOS__; 43 | prompt 44 | 4 45 | false 46 | true 47 | iPhone Distribution 48 | 49 | 50 | 51 | 52 | ARMv7 53 | 6B25DC76-E75A-4012-B066-B71F57CB7D4A 54 | Entitlements.plist 55 | 56 | 57 | full 58 | true 59 | bin\iPhone\Release 60 | __MOBILE__;__IOS__; 61 | prompt 62 | 4 63 | Entitlements.plist 64 | false 65 | iPhone Developer 66 | 67 | 68 | full 69 | true 70 | bin\iPhone\Ad-Hoc 71 | __MOBILE__;__IOS__; 72 | prompt 73 | 4 74 | false 75 | Entitlements.plist 76 | true 77 | 6B25DC76-E75A-4012-B066-B71F57CB7D4A 78 | iPhone Distribution 79 | 80 | 81 | 82 | 83 | ARMv7 84 | 85 | 86 | full 87 | true 88 | bin\iPhone\AppStore 89 | __MOBILE__;__IOS__; 90 | prompt 91 | 4 92 | false 93 | Entitlements.plist 94 | Automatic:AppStore 95 | iPhone Distribution 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | ..\Libs\iOS\Lidgren.Network.dll 105 | 106 | 107 | ..\Libs\iOS\MonoGame.Framework.dll 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/FlappyMonkey.Ouya.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | FlappyMonkey.Ouya 10 | Assets 11 | Resources 12 | Resource 13 | Resources\Resource.designer.cs 14 | True 15 | True 16 | FlappyMonkey.Ouya 17 | v4.5 18 | Properties\AndroidManifest.xml 19 | OnLoadAutoInsert 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Ouya\Debug 26 | DEBUG;__MOBILE__;__ANDROID__;__OUYA__;__TV__; 27 | prompt 28 | 4 29 | None 30 | false 31 | 32 | 33 | true 34 | bin\Ouya\Release 35 | __MOBILE__;__ANDROID__;__OUYA__;__TV__; 36 | prompt 37 | 4 38 | false 39 | false 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ..\Libs\Ouya\Ouya.Console.Api.dll 49 | 50 | 51 | ..\Libs\Ouya\Lidgren.Network.dll 52 | 53 | 54 | ..\Libs\Ouya\MonoGame.Framework.dll 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 | Assets\Content\gameFont.xnb 81 | 82 | 83 | Assets\Content\pipe.png 84 | 85 | 86 | Assets\Content\pipeBottomCap.png 87 | 88 | 89 | Assets\Content\pipeTopCap.png 90 | 91 | 92 | Assets\Content\logo.png 93 | 94 | 95 | Assets\Content\bottomGround.png 96 | 97 | 98 | Assets\Content\buildings.png 99 | 100 | 101 | Assets\Content\bushes.png 102 | 103 | 104 | Assets\Content\clouds1.png 105 | 106 | 107 | Assets\Content\clouds2.png 108 | 109 | 110 | Assets\Content\ground.png 111 | 112 | 113 | Assets\Content\0.png 114 | 115 | 116 | Assets\Content\1.png 117 | 118 | 119 | Assets\Content\2.png 120 | 121 | 122 | Assets\Content\3.png 123 | 124 | 125 | Assets\Content\4.png 126 | 127 | 128 | Assets\Content\5.png 129 | 130 | 131 | Assets\Content\6.png 132 | 133 | 134 | Assets\Content\7.png 135 | 136 | 137 | Assets\Content\8.png 138 | 139 | 140 | Assets\Content\9.png 141 | 142 | 143 | Assets\Content\gameOver.png 144 | 145 | 146 | Assets\Content\player.png 147 | 148 | 149 | Assets\Content\highScore.png 150 | 151 | 152 | Assets\Content\score.png 153 | 154 | 155 | Assets\Content\scoreBackground.png 156 | 157 | 158 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/FlappyMonkey.Droid.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | FlappyMonkey.Droid 10 | Assets 11 | Resources 12 | Resource 13 | Resources\Resource.designer.cs 14 | True 15 | False 16 | FlappyMonkey.Droid 17 | Properties\AndroidManifest.xml 18 | v4.0 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug 25 | DEBUG;__MOBILE__;__ANDROID__;__FIRE__; 26 | prompt 27 | 4 28 | None 29 | false 30 | True 31 | 32 | 33 | full 34 | true 35 | bin\Release 36 | __MOBILE__;__ANDROID__; 37 | prompt 38 | 4 39 | false 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ..\Libs\Android\Lidgren.Network.dll 50 | 51 | 52 | ..\Libs\Android\MonoGame.Framework.dll 53 | 54 | 55 | ..\Components\amazonfiretv-1.0\lib\android\Amazon.FireTV.GameController.dll 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 | Assets\Content\gameFont.xnb 81 | 82 | 83 | Assets\Content\pipe.png 84 | 85 | 86 | Assets\Content\pipeBottomCap.png 87 | 88 | 89 | Assets\Content\pipeTopCap.png 90 | 91 | 92 | Assets\Content\logo.png 93 | 94 | 95 | Assets\Content\bottomGround.png 96 | 97 | 98 | Assets\Content\buildings.png 99 | 100 | 101 | Assets\Content\bushes.png 102 | 103 | 104 | Assets\Content\clouds1.png 105 | 106 | 107 | Assets\Content\clouds2.png 108 | 109 | 110 | Assets\Content\ground.png 111 | 112 | 113 | Assets\Content\0.png 114 | 115 | 116 | Assets\Content\1.png 117 | 118 | 119 | Assets\Content\2.png 120 | 121 | 122 | Assets\Content\3.png 123 | 124 | 125 | Assets\Content\4.png 126 | 127 | 128 | Assets\Content\5.png 129 | 130 | 131 | Assets\Content\6.png 132 | 133 | 134 | Assets\Content\7.png 135 | 136 | 137 | Assets\Content\8.png 138 | 139 | 140 | Assets\Content\9.png 141 | 142 | 143 | Assets\Content\gameOver.png 144 | 145 | 146 | Assets\Content\player.png 147 | 148 | 149 | Assets\Content\highScore.png 150 | 151 | 152 | Assets\Content\score.png 153 | 154 | 155 | Assets\Content\scoreBackground.png 156 | 157 | 158 | 159 | 160 | 1.0 161 | False 162 | 163 | 164 | -------------------------------------------------------------------------------- /FlappyMonkey.Droid/FlappyMonkey.Fire.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {87430AED-367A-431F-8860-0381C91D9DF1} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | FlappyMonkey.Ouya 10 | Assets 11 | Resources 12 | Resource 13 | Resources\Resource.designer.cs 14 | True 15 | True 16 | FlappyMonkey.Ouya 17 | v4.5 18 | Properties\AndroidManifest.xml 19 | OnLoadAutoInsert 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Ouya\Debug 26 | DEBUG;__MOBILE__;__ANDROID__;__FIRE__;__TV__; 27 | prompt 28 | 4 29 | None 30 | false 31 | 32 | 33 | true 34 | bin\Ouya\Release 35 | __MOBILE__;__ANDROID__;__FIRE__;__TV__; 36 | prompt 37 | 4 38 | false 39 | false 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ..\Components\amazonfiretv-1.0\lib\android\Amazon.FireTV.GameController.dll 49 | 50 | 51 | ..\Libs\FIRE-o\Lidgren.Network.dll 52 | 53 | 54 | ..\Libs\FIRE-o\MonoGame.Framework.dll 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 | Assets\Content\gameFont.xnb 81 | 82 | 83 | Assets\Content\pipe.png 84 | 85 | 86 | Assets\Content\pipeBottomCap.png 87 | 88 | 89 | Assets\Content\pipeTopCap.png 90 | 91 | 92 | Assets\Content\logo.png 93 | 94 | 95 | Assets\Content\bottomGround.png 96 | 97 | 98 | Assets\Content\buildings.png 99 | 100 | 101 | Assets\Content\bushes.png 102 | 103 | 104 | Assets\Content\clouds1.png 105 | 106 | 107 | Assets\Content\clouds2.png 108 | 109 | 110 | Assets\Content\ground.png 111 | 112 | 113 | Assets\Content\0.png 114 | 115 | 116 | Assets\Content\1.png 117 | 118 | 119 | Assets\Content\2.png 120 | 121 | 122 | Assets\Content\3.png 123 | 124 | 125 | Assets\Content\4.png 126 | 127 | 128 | Assets\Content\5.png 129 | 130 | 131 | Assets\Content\6.png 132 | 133 | 134 | Assets\Content\7.png 135 | 136 | 137 | Assets\Content\8.png 138 | 139 | 140 | Assets\Content\9.png 141 | 142 | 143 | Assets\Content\gameOver.png 144 | 145 | 146 | Assets\Content\player.png 147 | 148 | 149 | Assets\Content\highScore.png 150 | 151 | 152 | Assets\Content\score.png 153 | 154 | 155 | Assets\Content\scoreBackground.png 156 | 157 | 158 | Assets\Content\tapToFly.png 159 | 160 | 161 | 162 | 163 | 1.0 164 | False 165 | 166 | 167 | -------------------------------------------------------------------------------- /FlappyMonkey.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{8F4F3D89-4A94-4F06-ACB1-28F88D0E826C}" 5 | ======= 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{8F4F3D89-4A94-4F06-ACB1-28F88D0E826C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlappyMonkey.Droid", "FlappyMonkey.Droid\FlappyMonkey.Droid.csproj", "{8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlappyMonkey.iOS", "FlappyMonkey.iOS\FlappyMonkey.iOS.csproj", "{9815036A-CCAD-4297-A747-E2ECC5659BB8}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlappyMonkey.Ouya", "FlappyMonkey.Droid\FlappyMonkey.Ouya.csproj", "{BC661CE3-71B2-4F37-8720-9C64936E5ED1}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlappyMonkey.Fire", "FlappyMonkey.Droid\FlappyMonkey.Fire.csproj", "{87430AED-367A-431F-8860-0381C91D9DF1}" 15 | EndProject 16 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FlappyMonkey.Shared", "Shared\FlappyMonkey.Shared.shproj", "{42FE0C01-5BE7-4818-93E1-A36BDCD962C8}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 23 | Release|iPhoneSimulator = Release|iPhoneSimulator 24 | Debug|iPhone = Debug|iPhone 25 | Release|iPhone = Release|iPhone 26 | Ad-Hoc|iPhone = Ad-Hoc|iPhone 27 | AppStore|iPhone = AppStore|iPhone 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {87430AED-367A-431F-8860-0381C91D9DF1}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU 31 | {87430AED-367A-431F-8860-0381C91D9DF1}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU 32 | {87430AED-367A-431F-8860-0381C91D9DF1}.AppStore|iPhone.ActiveCfg = Release|Any CPU 33 | {87430AED-367A-431F-8860-0381C91D9DF1}.AppStore|iPhone.Build.0 = Release|Any CPU 34 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|iPhone.ActiveCfg = Debug|Any CPU 37 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|iPhone.Build.0 = Debug|Any CPU 38 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 39 | {87430AED-367A-431F-8860-0381C91D9DF1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 40 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|iPhone.ActiveCfg = Release|Any CPU 43 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|iPhone.Build.0 = Release|Any CPU 44 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 45 | {87430AED-367A-431F-8860-0381C91D9DF1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 46 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU 47 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU 48 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.AppStore|iPhone.ActiveCfg = Debug|Any CPU 49 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.AppStore|iPhone.Build.0 = Debug|Any CPU 50 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|iPhone.ActiveCfg = Debug|Any CPU 53 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|iPhone.Build.0 = Debug|Any CPU 54 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 55 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 56 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|iPhone.ActiveCfg = Release|Any CPU 59 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|iPhone.Build.0 = Release|Any CPU 60 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 61 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 62 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone 63 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone 64 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.AppStore|iPhone.ActiveCfg = AppStore|iPhone 65 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.AppStore|iPhone.Build.0 = AppStore|iPhone 66 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator 67 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator 68 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|iPhone.ActiveCfg = Debug|iPhone 69 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|iPhone.Build.0 = Debug|iPhone 70 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator 71 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator 72 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator 73 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|Any CPU.Build.0 = Release|iPhoneSimulator 74 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|iPhone.ActiveCfg = Release|iPhone 75 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|iPhone.Build.0 = Release|iPhone 76 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator 77 | {9815036A-CCAD-4297-A747-E2ECC5659BB8}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator 78 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU 79 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU 80 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.AppStore|iPhone.ActiveCfg = Release|Any CPU 81 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.AppStore|iPhone.Build.0 = Release|Any CPU 82 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|iPhone.ActiveCfg = Debug|Any CPU 85 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|iPhone.Build.0 = Debug|Any CPU 86 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 87 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 88 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|Any CPU.ActiveCfg = Release|Any CPU 89 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|Any CPU.Build.0 = Release|Any CPU 90 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|iPhone.ActiveCfg = Release|Any CPU 91 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|iPhone.Build.0 = Release|Any CPU 92 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 93 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 94 | EndGlobalSection 95 | GlobalSection(NestedProjects) = preSolution 96 | {8E1C5FA7-712F-464A-BFA0-0F9897F8E8C6} = {8F4F3D89-4A94-4F06-ACB1-28F88D0E826C} 97 | {9815036A-CCAD-4297-A747-E2ECC5659BB8} = {8F4F3D89-4A94-4F06-ACB1-28F88D0E826C} 98 | {BC661CE3-71B2-4F37-8720-9C64936E5ED1} = {8F4F3D89-4A94-4F06-ACB1-28F88D0E826C} 99 | {87430AED-367A-431F-8860-0381C91D9DF1} = {8F4F3D89-4A94-4F06-ACB1-28F88D0E826C} 100 | EndGlobalSection 101 | GlobalSection(MonoDevelopProperties) = preSolution 102 | StartupItem = FlappyMonkey.iOS\FlappyMonkey.iOS.csproj 103 | EndGlobalSection 104 | EndGlobal 105 | -------------------------------------------------------------------------------- /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. 202 | 203 | -------------------------------------------------------------------------------- /Shared/Game1.cs: -------------------------------------------------------------------------------- 1 | #region File Description 2 | //----------------------------------------------------------------------------- 3 | // FlappyMonkey.iOSGame.cs 4 | // 5 | // Microsoft XNA Community Game Platform 6 | // Copyright (C) Microsoft Corporation. All rights reserved. 7 | //----------------------------------------------------------------------------- 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | 11 | #endregion 12 | #region Using Statements 13 | using System; 14 | using Microsoft.Xna.Framework; 15 | using Microsoft.Xna.Framework.Audio; 16 | using Microsoft.Xna.Framework.Graphics; 17 | using Microsoft.Xna.Framework.Input; 18 | using Microsoft.Xna.Framework.Input.Touch; 19 | using Microsoft.Xna.Framework.Storage; 20 | using Microsoft.Xna.Framework.Content; 21 | using Microsoft.Xna.Framework.Media; 22 | 23 | #endregion 24 | namespace FlappyMonkey 25 | { 26 | 27 | public enum GameState{ 28 | Menu, 29 | Playing, 30 | Score 31 | } 32 | /// 33 | /// Default Project Template 34 | /// 35 | public class Game1 : Game 36 | { 37 | public Action NotifyScore = (i) => {}; 38 | #region Fields 39 | public static GameState State { get; set; } 40 | GraphicsDeviceManager graphics; 41 | SpriteBatch spriteBatch; 42 | // Represents the player 43 | Player player; 44 | // Keyboard states used to determine key presses 45 | KeyboardState currentKeyboardState; 46 | KeyboardState previousKeyboardState; 47 | // Gamepad states used to determine button presses 48 | GamePadState currentGamePadState; 49 | GamePadState previousGamePadState; 50 | TouchCollection previousTouches; 51 | TouchCollection currentTouches; 52 | ParallaxingBackground ground; 53 | ParallaxingBackground buildings; 54 | ParallaxingBackground bushes; 55 | ParallaxingBackground clouds1; 56 | ParallaxingBackground clouds2; 57 | Texture2D wallTexture, topWallCapTexture, bottomWallCapTexture, 58 | playerTexture, groundBottom, gameOverTexture, scoreBoardTexture,scoreTexture, highScoreTexture; 59 | public List walls = new List (); 60 | // The rate at which the walls appear 61 | double wallSpanTime, previousWallSpawnTime; 62 | // A random number generator 63 | Random random = new Random (); 64 | //Number that holds the player score 65 | int score; 66 | // The font used to display UI elements 67 | SpriteFont font; 68 | bool accelActive; 69 | int wallHeight; 70 | Rectangle bottomGroundRect; 71 | int scoreBoardPadding = 0; 72 | 73 | #endregion 74 | 75 | #region Initialization 76 | 77 | public Game1 () 78 | { 79 | graphics = new GraphicsDeviceManager (this) { 80 | #if __TV__ 81 | SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight, 82 | #else 83 | SupportedOrientations = DisplayOrientation.Portrait, 84 | #endif 85 | IsFullScreen = true, 86 | }; 87 | 88 | Content.RootDirectory = "Content"; 89 | 90 | } 91 | 92 | /// 93 | /// Overridden from the base Game.Initialize. Once the GraphicsDevice is setup, 94 | /// we'll use the viewport to initialize some values. 95 | /// 96 | protected override void Initialize () 97 | { 98 | State = GameState.Menu; 99 | wallHeight = Math.Min (GraphicsDevice.Viewport.Height, MaxWallheight); 100 | bottomGroundRect = new Rectangle (0, wallHeight + 1, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height - MaxWallheight); 101 | player = new Player (); 102 | ground = new ParallaxingBackground (); 103 | buildings = new ParallaxingBackground (); 104 | bushes = new ParallaxingBackground (); 105 | clouds1 = new ParallaxingBackground (); 106 | clouds2 = new ParallaxingBackground (); 107 | base.Initialize (); 108 | } 109 | int scoreScale = 3; 110 | /// 111 | /// Load your graphics content. 112 | /// 113 | protected override void LoadContent () 114 | { 115 | // Create a new SpriteBatch, which can be use to draw textures. 116 | spriteBatch = new SpriteBatch (graphics.GraphicsDevice); 117 | 118 | // TODO: use this.Content to load your game content here eg. 119 | playerTexture = Content.Load ("player"); 120 | 121 | player.Initialize (playerTexture, new Vector2 (graphics.GraphicsDevice.Viewport.Width / 3, graphics.GraphicsDevice.Viewport.Height / 2)); 122 | wallTexture = Content.Load ("pipe"); 123 | topWallCapTexture = Content.Load ("pipeTopCap"); 124 | bottomWallCapTexture = Content.Load ("pipeBottomCap"); 125 | 126 | font = Content.Load ("gameFont"); 127 | 128 | groundBottom = Content.Load ("bottomGround"); 129 | ground.Initialize (Content, "ground", wallHeight, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -GamePhysics.WallSpeed, false); 130 | clouds1.Initialize (Content, "clouds1", 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -.25f, true); 131 | clouds2.Initialize (Content, "clouds2", 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -(GamePhysics.WallSpeed + .5f), true); 132 | bushes.Initialize (Content, "bushes", wallHeight, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -1, false, true); 133 | buildings.Initialize (Content, "buildings", wallHeight, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -.5f, false, true); 134 | 135 | Number.Initialize (Content); 136 | gameOverTexture = Content.Load ("gameOver"); 137 | scoreBoardTexture = Content.Load ("scoreBackground"); 138 | highScoreTexture = Content.Load ("highScore"); 139 | scoreTexture = Content.Load ("score"); 140 | gameOverPosition.X = (GraphicsDevice.Viewport.Width - (gameOverTexture.Width * 8)) / 2; 141 | scoreBoardRect.X = (int)gameOverPosition.X; 142 | scoreBoardRect.Width = gameOverTexture.Width * 8; 143 | scoreBoardPadding = gameOverTexture.Height; 144 | scoreBoardRect.Height = (scoreBoardPadding * 6) + highScoreTexture.Height + scoreTexture.Height + (int)(Number.Height * scoreScale * 2); 145 | Reset (); 146 | } 147 | 148 | public void Reset () 149 | { 150 | State = GameState.Menu; 151 | wallSpanTime = GamePhysics.StartWallSpawnRate; 152 | player.Active = true; 153 | player.Health = 1; 154 | maxGap = GamePhysics.MaximumGapSize; 155 | score = 0; 156 | walls.Clear (); 157 | 158 | var playerPosition = new Vector2 (graphics.GraphicsDevice.Viewport.Width / 3, graphics.GraphicsDevice.Viewport.Height / 2); 159 | player.Position = playerPosition; 160 | } 161 | 162 | #endregion 163 | 164 | #region Update and Draw 165 | 166 | /// 167 | /// Allows the game to run logic such as updating the world, 168 | /// checking for collisions, gathering input, and playing audio. 169 | /// 170 | /// Provides a snapshot of timing values. 171 | protected override void Update (GameTime gameTime) 172 | { 173 | base.Update (gameTime); 174 | 175 | // Save the previous state of the keyboard and game pad so we can determinesingle key/button presses 176 | previousGamePadState = currentGamePadState; 177 | previousKeyboardState = currentKeyboardState; 178 | previousTouches = currentTouches; 179 | 180 | // Read the current state of the keyboard and gamepad and store it 181 | currentKeyboardState = Keyboard.GetState (); 182 | currentGamePadState = GamePad.GetState (PlayerIndex.One); 183 | currentTouches = TouchPanel.GetState (); 184 | 185 | 186 | //Update the player 187 | var shouldFly = Toggled (); //currentTouches.Any() || currentKeyboardState.IsKeyDown (Keys.Space) || currentGamePadState.IsButtonDown(Buttons.A) ; 188 | if (shouldFly && State == GameState.Menu) 189 | State = GameState.Playing; 190 | else if (shouldFly && State == GameState.Score) 191 | shouldFly = false; 192 | player.Update (gameTime, shouldFly, wallHeight + 1, State == GameState.Menu); 193 | 194 | 195 | 196 | if (State != GameState.Score){ 197 | ground.Update (); 198 | buildings.Update (); 199 | bushes.Update (); 200 | clouds1.Update (); 201 | clouds2.Update (); 202 | } 203 | 204 | if (State == GameState.Playing) { 205 | UpdateWalls (gameTime); 206 | // Update the collision 207 | UpdateCollision (); 208 | } else if (State == GameState.Score) { 209 | UpdateGameOver (gameTime); 210 | if (gameOverAnimationDuration <= gameOverTimer && Toggled ()) 211 | Reset (); 212 | 213 | } 214 | 215 | } 216 | 217 | bool Toggled (Buttons button) 218 | { 219 | return previousGamePadState.IsButtonUp (button) && currentGamePadState.IsButtonDown (button); 220 | } 221 | 222 | bool ToggledTappped () 223 | { 224 | return !previousTouches.Any () && currentTouches.Any (); 225 | } 226 | 227 | bool Toggled (Keys key) 228 | { 229 | return previousKeyboardState.IsKeyUp (key) && currentKeyboardState.IsKeyDown (key); 230 | } 231 | 232 | bool Toggled () 233 | { 234 | return ToggledTappped () || Toggled (Buttons.A) || Toggled (Keys.Space)|| Toggled (Keys.Enter); 235 | } 236 | 237 | int maxGap; 238 | const int MaxWallheight = 920; 239 | 240 | private void AddWall () 241 | { 242 | maxGap = MathHelper.Clamp (maxGap - 10, GamePhysics.MinimumGapSize, GamePhysics.MaximumGapSize); 243 | int gapSize = random.Next ( GamePhysics.MinimumGapSize, maxGap); 244 | var gapY = random.Next (100, wallHeight - (gapSize + 100)); 245 | var wall = new Wall (); 246 | 247 | var position = new Vector2 (GraphicsDevice.Viewport.Width + wallTexture.Width / 2, 0); 248 | // Initialize the animation with the correct animation information 249 | wall.Initialize (wallTexture, topWallCapTexture, bottomWallCapTexture, new Rectangle ((int)position.X, gapY, wallTexture.Width, gapSize), GraphicsDevice.Viewport.Height, GraphicsDevice.Viewport.Height); 250 | 251 | walls.Add (wall); 252 | } 253 | 254 | private void UpdateWalls (GameTime gameTime) 255 | { 256 | // Spawn a new enemy enemy every 1.5 seconds 257 | previousWallSpawnTime += gameTime.ElapsedGameTime.TotalMilliseconds; 258 | if (previousWallSpawnTime > wallSpanTime) { 259 | previousWallSpawnTime = 0; 260 | wallSpanTime -= 200; 261 | wallSpanTime = Math.Max (wallSpanTime, GamePhysics.MinimumWallSpawnRate); 262 | // Add an Enemy 263 | AddWall (); 264 | } 265 | var deadWalls = new List (); 266 | foreach (var wall in walls) { 267 | wall.Update (gameTime); 268 | if (wall.Position.X < -wall.Width) 269 | deadWalls.Add (wall); 270 | } 271 | 272 | foreach (var wall in deadWalls) 273 | walls.Remove (wall); 274 | 275 | } 276 | 277 | private void UpdateCollision () 278 | { 279 | // Use the Rectangle's built-in intersect function to 280 | // determine if two objects are overlapping 281 | var rectangle1 = player.Rectangle; 282 | //If it collides with a wall, you die 283 | foreach (var wall in walls.Where(x=> x.Collides(rectangle1))) { 284 | gameOver (); 285 | } 286 | 287 | var points = walls.Sum (x => x.CollectPoints ()); 288 | score += points; 289 | 290 | if (rectangle1.Bottom >= wallHeight) { 291 | gameOver (); 292 | } 293 | } 294 | double gameOverTimer = 0; 295 | Vector2 gameOverPosition = Vector2.Zero; 296 | Rectangle scoreBoardRect = Rectangle.Empty; 297 | double gameOverAnimationDuration = 500; 298 | void gameOver() 299 | { 300 | TopScore.Current = score; 301 | NotifyScore (TopScore.Current); 302 | gameOverTimer = 0; 303 | player.Health = 0; 304 | player.Active = false; 305 | State = GameState.Score; 306 | } 307 | 308 | void UpdateGameOver(GameTime gameTime) 309 | { 310 | gameOverTimer += gameTime.ElapsedGameTime.TotalMilliseconds; 311 | if (gameOverTimer > gameOverAnimationDuration + 10) 312 | return; 313 | var sin = (float)Math.Sin (gameOverTimer * .7 * Math.PI / gameOverAnimationDuration); 314 | var y = (int)((GraphicsDevice.Viewport.Height/3) * sin); 315 | gameOverPosition.Y = y; 316 | scoreBoardRect.Y = GraphicsDevice.Viewport.Height - y - scoreBoardRect.Height; 317 | } 318 | 319 | /// 320 | /// This is called when the game should draw itself. 321 | /// 322 | /// Provides a snapshot of timing values. 323 | 324 | protected override void Draw (GameTime gameTime) 325 | { 326 | GraphicsDevice.Clear (Color.CornflowerBlue); 327 | // Start drawing 328 | spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, 329 | SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); 330 | 331 | buildings.Draw (spriteBatch); 332 | bushes.Draw (spriteBatch); 333 | 334 | clouds1.Draw (spriteBatch); 335 | 336 | walls.ForEach (x => x.Draw (spriteBatch)); 337 | 338 | 339 | // Draw the Player 340 | //uncomment to draw the hitbox. 341 | //spriteBatch.Draw (groundBottom, player.Rectangle, Color.Red); 342 | player.Draw (spriteBatch); 343 | 344 | clouds2.Draw (spriteBatch); 345 | 346 | spriteBatch.Draw (groundBottom, bottomGroundRect, Color.White); 347 | ground.Draw (spriteBatch); 348 | 349 | 350 | // // Draw the score 351 | if (State == GameState.Playing) 352 | Number.Draw (spriteBatch, score, Number.Alignment.Center, new Rectangle (0, GraphicsDevice.Viewport.TitleSafeArea.Height / 4, GraphicsDevice.Viewport.TitleSafeArea.Width, 0), scoreScale); 353 | 354 | if (State == GameState.Score) { 355 | spriteBatch.Draw (gameOverTexture, gameOverPosition,null,null,null,0,new Vector2(8,8), Color.White); 356 | 357 | spriteBatch.Draw (scoreBoardTexture, null,scoreBoardRect,null,null,0,new Vector2(1,1), Color.White); 358 | 359 | var y = scoreBoardRect.Top + scoreBoardPadding; 360 | var x = (GraphicsDevice.Viewport.TitleSafeArea.Width - scoreTexture.Width) / 2; 361 | spriteBatch.Draw (scoreTexture, new Vector2(x,y), Color.White); 362 | 363 | y += scoreTexture.Height + scoreBoardPadding; 364 | Number.Draw (spriteBatch, score, Number.Alignment.Center, new Rectangle (0, y, GraphicsDevice.Viewport.TitleSafeArea.Width, 0), scoreScale); 365 | 366 | y += (Number.Height * scoreScale) + scoreBoardPadding; 367 | x = (GraphicsDevice.Viewport.TitleSafeArea.Width - highScoreTexture.Width) / 2; 368 | spriteBatch.Draw (highScoreTexture, new Vector2(x,y), Color.White); 369 | 370 | y += highScoreTexture.Height + scoreBoardPadding; 371 | Number.Draw (spriteBatch, TopScore.Current, Number.Alignment.Center, new Rectangle (0, y, GraphicsDevice.Viewport.TitleSafeArea.Width, 0), scoreScale); 372 | 373 | 374 | } 375 | // // Draw the player health 376 | // spriteBatch.DrawString (font, "health: " + player.Health, new Vector2 (GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + 30), Color.White); 377 | 378 | // Stop drawing 379 | spriteBatch.End (); 380 | // TODO: Add your drawing code here 381 | 382 | base.Draw (gameTime); 383 | } 384 | 385 | #endregion 386 | } 387 | } 388 | --------------------------------------------------------------------------------