diff --git a/WalkingGameMG/Android/Activity1.cs b/WalkingGameMG/Android/Activity1.cs new file mode 100644 index 000000000..0060e2015 --- /dev/null +++ b/WalkingGameMG/Android/Activity1.cs @@ -0,0 +1,38 @@ +using System; + +using Android.App; +using Android.Content; +using Android.Runtime; +using Android.Content.PM; +using Android.Views; +using Android.Widget; +using Android.OS; + +using Microsoft.Xna.Framework; + +namespace WalkingGame.Droid +{ + [Activity (Label = "WalkingGame.Droid", + MainLauncher = true, + Icon = "@drawable/icon", + Theme = "@style/Theme.Splash", + AlwaysRetainTaskState = true, + LaunchMode = LaunchMode.SingleInstance, + ConfigurationChanges = ConfigChanges.Orientation | + ConfigChanges.KeyboardHidden | + ConfigChanges.Keyboard)] + public class Activity1 : AndroidGameActivity + { + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + var g = new Game1(); + SetContentView((View)g.Services.GetService(typeof(View))); + g.Run(); + } + + } +} + + diff --git a/WalkingGameMG/Android/Assets/AboutAssets.txt b/WalkingGameMG/Android/Assets/AboutAssets.txt new file mode 100644 index 000000000..ee3988629 --- /dev/null +++ b/WalkingGameMG/Android/Assets/AboutAssets.txt @@ -0,0 +1,19 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories) and given a Build Action of "AndroidAsset". + +These files will be deployed with you package and will be accessible using Android's +AssetManager, like this: + +public class ReadAsset : Activity +{ + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + InputStream input = Assets.Open ("my_asset.txt"); + } +} + +Additionally, some Android functions will automatically load asset files: + +Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); \ No newline at end of file diff --git a/WalkingGameMG/Android/Assets/Content/Content.mgcb b/WalkingGameMG/Android/Assets/Content/Content.mgcb new file mode 100644 index 000000000..802d8a9ff --- /dev/null +++ b/WalkingGameMG/Android/Assets/Content/Content.mgcb @@ -0,0 +1,13 @@ +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:Windows +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# diff --git a/WalkingGameMG/Android/Properties/AndroidManifest.xml b/WalkingGameMG/Android/Properties/AndroidManifest.xml new file mode 100644 index 000000000..98c4cc403 --- /dev/null +++ b/WalkingGameMG/Android/Properties/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/WalkingGameMG/Android/Properties/AssemblyInfo.cs b/WalkingGameMG/Android/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..589828f0b --- /dev/null +++ b/WalkingGameMG/Android/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +#if __ANDROID__ +using Android.App; +#endif + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("WalkingGame.Droid")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("vchelaru")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.0")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/WalkingGameMG/Android/Resources/AboutResources.txt b/WalkingGameMG/Android/Resources/AboutResources.txt new file mode 100644 index 000000000..10f52d460 --- /dev/null +++ b/WalkingGameMG/Android/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml. diff --git a/WalkingGameMG/Android/Resources/drawable/Icon.png b/WalkingGameMG/Android/Resources/drawable/Icon.png new file mode 100644 index 000000000..ce7f8c4a2 Binary files /dev/null and b/WalkingGameMG/Android/Resources/drawable/Icon.png differ diff --git a/WalkingGameMG/Android/Resources/drawable/Splash.png b/WalkingGameMG/Android/Resources/drawable/Splash.png new file mode 100644 index 000000000..2f8610744 Binary files /dev/null and b/WalkingGameMG/Android/Resources/drawable/Splash.png differ diff --git a/WalkingGameMG/Android/Resources/values/Styles.xml b/WalkingGameMG/Android/Resources/values/Styles.xml new file mode 100644 index 000000000..510213401 --- /dev/null +++ b/WalkingGameMG/Android/Resources/values/Styles.xml @@ -0,0 +1,7 @@ + + + + diff --git a/WalkingGameMG/Android/WalkingGame.Droid.csproj b/WalkingGameMG/Android/WalkingGame.Droid.csproj new file mode 100644 index 000000000..b3c3a802e --- /dev/null +++ b/WalkingGameMG/Android/WalkingGame.Droid.csproj @@ -0,0 +1,74 @@ + + + + Debug + AnyCPU + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {0A2B68ED-3550-4894-958D-8643609E3085} + Library + WalkingGame.Droid + Assets + Resources + Properties\AndroidManifest.xml + Resource + Resources\Resource.designer.cs + True + True + WalkingGame.Droid + v4.4.87 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + None + false + + + full + true + bin\Release + prompt + 4 + false + false + + + + + + + + + ..\packages\MonoGame.Framework.Android.3.3.0.0\lib\MonoAndroid\MonoGame.Framework.dll + + + + + + + + + + + + + + + + + + + + + + Assets\Content\charactersheet.png + + + + + \ No newline at end of file diff --git a/WalkingGameMG/Android/packages.config b/WalkingGameMG/Android/packages.config new file mode 100644 index 000000000..fd2b3f803 --- /dev/null +++ b/WalkingGameMG/Android/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/WalkingGameMG/Metadata.xml b/WalkingGameMG/Metadata.xml new file mode 100644 index 000000000..5476953b3 --- /dev/null +++ b/WalkingGameMG/Metadata.xml @@ -0,0 +1,9 @@ + + + 29cc8613-fdb7-4fe2-82b4-9921eafd4e58 + false + Beginning + Indie + Getting Started, Games + true + diff --git a/WalkingGameMG/README.md b/WalkingGameMG/README.md new file mode 100644 index 000000000..808375675 --- /dev/null +++ b/WalkingGameMG/README.md @@ -0,0 +1,13 @@ +MonoGame WalkingGame Project for iOS and Android +==================================== + +This is a small demo game using MonoGame for iOS and Android, using a shared code project. It is the result of working through the the entire Introduction to Monogame walkthrough. + +The demo can be played by touching the screen to move the character around the screen. + +It is built against MonoGame 3.3. + +Author +------ + +Victor Chelaru \ No newline at end of file diff --git a/WalkingGameMG/Screenshots/Screenshot1.gif b/WalkingGameMG/Screenshots/Screenshot1.gif new file mode 100644 index 000000000..cdc5368bb Binary files /dev/null and b/WalkingGameMG/Screenshots/Screenshot1.gif differ diff --git a/WalkingGameMG/WalkingGame.sln b/WalkingGameMG/WalkingGame.sln new file mode 100644 index 000000000..3c5cdab03 --- /dev/null +++ b/WalkingGameMG/WalkingGame.sln @@ -0,0 +1,45 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WalkingGame", "WalkingGame\WalkingGame.shproj", "{DC1CF201-F64E-420F-BEEA-849CFF7F9122}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingGame.iOS", "iOS\WalkingGame.iOS.csproj", "{A91BC717-9CD2-4CC8-BF12-3AA87256F81A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingGame.Droid", "Android\WalkingGame.Droid.csproj", "{0A2B68ED-3550-4894-958D-8643609E3085}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|iPhone = Release|iPhone + Release|iPhoneSimulator = Release|iPhoneSimulator + Debug|iPhone = Debug|iPhone + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|iPhone.Build.0 = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|Any CPU.Build.0 = Release|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|iPhone.ActiveCfg = Release|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|iPhone.Build.0 = Release|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {0A2B68ED-3550-4894-958D-8643609E3085}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|iPhone.ActiveCfg = Debug|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|iPhone.Build.0 = Debug|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|Any CPU.ActiveCfg = Release|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|Any CPU.Build.0 = Release|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|iPhone.ActiveCfg = Release|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|iPhone.Build.0 = Release|iPhone + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + EndGlobalSection +EndGlobal diff --git a/WalkingGameMG/WalkingGame/Animation.cs b/WalkingGameMG/WalkingGame/Animation.cs new file mode 100644 index 000000000..e8d5d72dd --- /dev/null +++ b/WalkingGameMG/WalkingGame/Animation.cs @@ -0,0 +1,98 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using Microsoft.Xna.Framework; + +namespace WalkingGame +{ + public class Animation + { + // The frames in this animation + List frames = new List(); + + // The amount of time into the animation + TimeSpan timeIntoAnimation; + + // The length of the entire animation + TimeSpan Duration + { + get + { + double totalSeconds = 0; + foreach (var frame in frames) + { + totalSeconds += frame.Duration.TotalSeconds; + } + + return TimeSpan.FromSeconds (totalSeconds); + } + } + + public Rectangle CurrentRectangle + { + get + { + AnimationFrame currentFrame = null; + + // See if we can find the frame + TimeSpan accumulatedTime = new TimeSpan(0); + foreach(var frame in frames) + { + if (accumulatedTime + frame.Duration >= timeIntoAnimation) + { + currentFrame = frame; + break; + } + else + { + accumulatedTime += frame.Duration; + } + } + + // If no frame was found, then try the last frame, + // just in case timeIntoAnimation somehow exceeds Duration + if (currentFrame == null) + { + currentFrame = frames.LastOrDefault (); + } + + // If we found a frame, return its rectangle, otherwise + // return an empty rectangle (one with no width or height) + if (currentFrame != null) + { + return currentFrame.SourceRectangle; + } + else + { + return Rectangle.Empty; + } + } + } + + // Adds a single frame to this animation. + public void AddFrame(Rectangle rectangle, TimeSpan duration) + { + AnimationFrame newFrame = new AnimationFrame() + { + SourceRectangle = rectangle, + Duration = duration + }; + + frames.Add(newFrame); + } + + // Increases the timeIntoAnimation value according to the + // frame time as obtained from gameTime + public void Update(GameTime gameTime) + { + double secondsIntoAnimation = + timeIntoAnimation.TotalSeconds + gameTime.ElapsedGameTime.TotalSeconds; + + + double remainder = secondsIntoAnimation % Duration.TotalSeconds; + + timeIntoAnimation = TimeSpan.FromSeconds (remainder); + } + } +} + diff --git a/WalkingGameMG/WalkingGame/AnimationFrame.cs b/WalkingGameMG/WalkingGame/AnimationFrame.cs new file mode 100644 index 000000000..7fb0eb804 --- /dev/null +++ b/WalkingGameMG/WalkingGame/AnimationFrame.cs @@ -0,0 +1,12 @@ +using System; +using Microsoft.Xna.Framework; + +namespace WalkingGame +{ + public class AnimationFrame + { + public Rectangle SourceRectangle { get; set; } + public TimeSpan Duration { get; set; } + } +} + diff --git a/WalkingGameMG/WalkingGame/CharacterEntity.cs b/WalkingGameMG/WalkingGame/CharacterEntity.cs new file mode 100644 index 000000000..6253f6513 --- /dev/null +++ b/WalkingGameMG/WalkingGame/CharacterEntity.cs @@ -0,0 +1,201 @@ +using System; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; + +namespace WalkingGame +{ + public class CharacterEntity + { + static Texture2D characterSheetTexture; + + Animation walkDown; + Animation walkUp; + Animation walkLeft; + Animation walkRight; + + Animation standDown; + Animation standUp; + Animation standLeft; + Animation standRight; + + Animation currentAnimation; + + public float X + { + get; + set; + } + + public float Y + { + get; + set; + } + + public CharacterEntity (GraphicsDevice graphicsDevice) + { + if (characterSheetTexture == null) + { + using (var stream = TitleContainer.OpenStream ("Content/charactersheet.png")) + { + characterSheetTexture = Texture2D.FromStream (graphicsDevice, stream); + } + } + + walkDown = new Animation (); + walkDown.AddFrame (new Rectangle (0, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkDown.AddFrame (new Rectangle (16, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkDown.AddFrame (new Rectangle (0, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkDown.AddFrame (new Rectangle (32, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + walkUp = new Animation (); + walkUp.AddFrame (new Rectangle (144, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkUp.AddFrame (new Rectangle (160, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkUp.AddFrame (new Rectangle (144, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkUp.AddFrame (new Rectangle (176, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + walkLeft = new Animation (); + walkLeft.AddFrame (new Rectangle (48, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkLeft.AddFrame (new Rectangle (64, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkLeft.AddFrame (new Rectangle (48, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkLeft.AddFrame (new Rectangle (80, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + walkRight = new Animation (); + walkRight.AddFrame (new Rectangle (96, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkRight.AddFrame (new Rectangle (112, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkRight.AddFrame (new Rectangle (96, 0, 16, 16), TimeSpan.FromSeconds (.25)); + walkRight.AddFrame (new Rectangle (128, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + // Standing animations only have a single frame of animation: + standDown = new Animation (); + standDown.AddFrame (new Rectangle (0, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + standUp = new Animation (); + standUp.AddFrame (new Rectangle (144, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + standLeft = new Animation (); + standLeft.AddFrame (new Rectangle (48, 0, 16, 16), TimeSpan.FromSeconds (.25)); + + standRight = new Animation (); + standRight.AddFrame (new Rectangle (96, 0, 16, 16), TimeSpan.FromSeconds (.25)); + } + + public void Draw(SpriteBatch spriteBatch) + { + Vector2 topLeftOfSprite = new Vector2 (this.X, this.Y); + Color tintColor = Color.White; + var sourceRectangle = currentAnimation.CurrentRectangle; + + spriteBatch.Draw(characterSheetTexture, topLeftOfSprite, sourceRectangle, Color.White); + } + + public void Update(GameTime gameTime) + { + var velocity = GetDesiredVelocityFromInput (); + + this.X += velocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds; + this.Y += velocity.Y * (float)gameTime.ElapsedGameTime.TotalSeconds; + + // We can use the velocity variable to determine if the + // character is moving or standing still + bool isMoving = velocity != Vector2.Zero; + if (isMoving) + { + // If the absolute value of the X component + // is larger than the absolute value of the Y + // component, then that means the character is + // moving horizontally: + bool isMovingHorizontally = Math.Abs (velocity.X) > Math.Abs (velocity.Y); + if (isMovingHorizontally) + { + // No that we know the character is moving horizontally + // we can check if the velocity is positive (moving right) + // or negative (moving left) + if (velocity.X > 0) + { + currentAnimation = walkRight; + } + else + { + currentAnimation = walkLeft; + } + } + else + { + // If the character is not moving horizontally + // then it must be moving vertically. The SpriteBatch + // class treats positive Y as down, so this defines the + // coordinate system for our game. Therefore if + // Y is positive then the character is moving down. + // Otherwise, the character is moving up. + if (velocity.Y > 0) + { + currentAnimation = walkDown; + } + else + { + currentAnimation = walkUp; + } + } + } + else + { + // This else statement contains logic for if the + // character is standing still. + // First we are going to check if the character + // is currently playing any walking animations. + // If so, then we want to switch to a standing animation. + // We want to preserve the direction that the character + // is facing so we'll set the corresponding standing + // animation according to the walking animation being played. + if (currentAnimation == walkRight) + { + currentAnimation = standRight; + } + else if (currentAnimation == walkLeft) + { + currentAnimation = standLeft; + } + else if (currentAnimation == walkUp) + { + currentAnimation = standUp; + } + else if (currentAnimation == walkDown) + { + currentAnimation = standDown; + } + // If the character is standing still but is not showing + // any animation at all then we'll default to facing down. + else if (currentAnimation == null) + { + currentAnimation = standDown; + } + } + + currentAnimation.Update (gameTime); + } + + Vector2 GetDesiredVelocityFromInput() + { + Vector2 desiredVelocity = new Vector2 (); + + TouchCollection touchCollection = TouchPanel.GetState(); + + if (touchCollection.Count > 0) + { + desiredVelocity.X = touchCollection [0].Position.X - this.X; + desiredVelocity.Y = touchCollection [0].Position.Y - this.Y; + + if (desiredVelocity.X != 0 || desiredVelocity.Y != 0) + { + desiredVelocity.Normalize(); + const float desiredSpeed = 200; + desiredVelocity *= desiredSpeed; + } + } + + return desiredVelocity; + } + } +} \ No newline at end of file diff --git a/WalkingGameMG/WalkingGame/Game1.cs b/WalkingGameMG/WalkingGame/Game1.cs new file mode 100644 index 000000000..63887b67e --- /dev/null +++ b/WalkingGameMG/WalkingGame/Game1.cs @@ -0,0 +1,86 @@ +#region Using Statements +using System; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Storage; +using Microsoft.Xna.Framework.Input; + +#endregion + +namespace WalkingGame +{ + /// + /// This is the main type for your game. + /// + public class Game1 : Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + + CharacterEntity character; + + public Game1 () + { + graphics = new GraphicsDeviceManager (this); + Content.RootDirectory = "Content"; + graphics.IsFullScreen = true; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize () + { + character = new CharacterEntity (this.GraphicsDevice); + + base.Initialize (); + + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent () + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch (GraphicsDevice); + + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update (GameTime gameTime) + { + character.Update (gameTime); + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.CornflowerBlue); + + // We'll start all of our drawing here: + spriteBatch.Begin (); + + // Now we can do any entity rendering: + character.Draw(spriteBatch); + // End renders all sprites to the screen: + spriteBatch.End (); + + base.Draw(gameTime); + } + } +} + diff --git a/WalkingGameMG/WalkingGame/WalkingGame.projitems b/WalkingGameMG/WalkingGame/WalkingGame.projitems new file mode 100644 index 000000000..cccb90583 --- /dev/null +++ b/WalkingGameMG/WalkingGame/WalkingGame.projitems @@ -0,0 +1,17 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {DC1CF201-F64E-420F-BEEA-849CFF7F9122} + + + WalkingGame + + + + + + + + \ No newline at end of file diff --git a/WalkingGameMG/WalkingGame/WalkingGame.shproj b/WalkingGameMG/WalkingGame/WalkingGame.shproj new file mode 100644 index 000000000..6b105e981 --- /dev/null +++ b/WalkingGameMG/WalkingGame/WalkingGame.shproj @@ -0,0 +1,11 @@ + + + + {DC1CF201-F64E-420F-BEEA-849CFF7F9122} + + + + + + + \ No newline at end of file diff --git a/WalkingGameMG/iOS/Content/Content.mgcb b/WalkingGameMG/iOS/Content/Content.mgcb new file mode 100644 index 000000000..802d8a9ff --- /dev/null +++ b/WalkingGameMG/iOS/Content/Content.mgcb @@ -0,0 +1,13 @@ +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:Windows +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# diff --git a/WalkingGameMG/iOS/Content/charactersheet.png b/WalkingGameMG/iOS/Content/charactersheet.png new file mode 100644 index 000000000..134b68986 Binary files /dev/null and b/WalkingGameMG/iOS/Content/charactersheet.png differ diff --git a/WalkingGameMG/iOS/Default.png b/WalkingGameMG/iOS/Default.png new file mode 100644 index 000000000..1f9b909f1 Binary files /dev/null and b/WalkingGameMG/iOS/Default.png differ diff --git a/WalkingGameMG/iOS/GameThumbnail.png b/WalkingGameMG/iOS/GameThumbnail.png new file mode 100644 index 000000000..99814c32f Binary files /dev/null and b/WalkingGameMG/iOS/GameThumbnail.png differ diff --git a/WalkingGameMG/iOS/Info.plist b/WalkingGameMG/iOS/Info.plist new file mode 100644 index 000000000..cb06a0334 --- /dev/null +++ b/WalkingGameMG/iOS/Info.plist @@ -0,0 +1,23 @@ + + + + + CFBundleDisplayName + WalkingGame.iOS + CFBundleIconFiles + + GameThumbnail.png + + CFBundleIdentifier + project.MonoGame.WalkingGame.iOS + MinimumOSVersion + 5.2 + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/WalkingGameMG/iOS/Main.cs b/WalkingGameMG/iOS/Main.cs new file mode 100644 index 000000000..c532bbe53 --- /dev/null +++ b/WalkingGameMG/iOS/Main.cs @@ -0,0 +1,86 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; + +#if MONOMAC +using MonoMac.AppKit; +using MonoMac.Foundation; + +#elif __IOS__ +using Foundation; +using UIKit; +#endif +#endregion + + +namespace WalkingGame.iOS +{ + #if __IOS__ + [Register("AppDelegate")] + class Program : UIApplicationDelegate + +#else + static class Program + #endif + { + private static Game1 game; + + internal static void RunGame () + { + game = new Game1 (); + game.Run (); + } + + /// + /// The main entry point for the application. + /// + #if !MONOMAC && !__IOS__ + [STAThread] + #endif + static void Main (string[] args) + { + #if MONOMAC + NSApplication.Init (); + + using (var p = new NSAutoreleasePool ()) { + NSApplication.SharedApplication.Delegate = new AppDelegate(); + NSApplication.Main(args); + } + #elif __IOS__ + UIApplication.Main(args, null, "AppDelegate"); + #else + RunGame (); + #endif + } + + #if __IOS__ + public override void FinishedLaunching(UIApplication app) + { + RunGame(); + } + #endif + } + + #if MONOMAC + class AppDelegate : NSApplicationDelegate + { + public override void FinishedLaunching (MonoMac.Foundation.NSObject notification) + { + AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs a) => { + if (a.Name.StartsWith("MonoMac")) { + return typeof(MonoMac.AppKit.AppKitFramework).Assembly; + } + return null; + }; + Program.RunGame(); + } + + public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender) + { + return true; + } + } + #endif +} + diff --git a/WalkingGameMG/iOS/Properties/AssemblyInfo.cs b/WalkingGameMG/iOS/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..5d22ac548 --- /dev/null +++ b/WalkingGameMG/iOS/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +#if __ANDROID__ +using Android.App; +#endif + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("WalkingGame.iOS")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("vchelaru")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.0")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/WalkingGameMG/iOS/WalkingGame.iOS.csproj b/WalkingGameMG/iOS/WalkingGame.iOS.csproj new file mode 100644 index 000000000..67d86aa33 --- /dev/null +++ b/WalkingGameMG/iOS/WalkingGame.iOS.csproj @@ -0,0 +1,89 @@ + + + + Debug + iPhoneSimulator + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {A91BC717-9CD2-4CC8-BF12-3AA87256F81A} + Exe + WalkingGame.iOS + Resources + WalkingGameiOS + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG; + prompt + 4 + false + i386 + None + true + true + iPhone Developer + + + full + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARMv7, ARM64 + false + iPhone Developer + + + full + true + bin\iPhoneSimulator\Release + prompt + 4 + i386 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG; + prompt + 4 + false + ARMv7, ARM64 + Entitlements.plist + true + iPhone Developer + true + + + + + + + + ..\packages\MonoGame.Framework.iOS.3.3.0.0\lib\XamariniOS\MonoGame.Framework.dll + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WalkingGameMG/iOS/packages.config b/WalkingGameMG/iOS/packages.config new file mode 100644 index 000000000..f66aa8d4e --- /dev/null +++ b/WalkingGameMG/iOS/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file