Wednesday, July 4, 2018

Simpsons Trivia XNA Port

In 2015, Candy Kid was written in XNA as a simple maze chase video game and ported to Android and iOS mobile platforms using MonoGame. The game code was written in an external library and scaled out using SVN Externals.

Earlier in 2018, Simpsons Trivia was built for the Sega Master System. Now, we would like to employ similar techniques to re-write the game in XNA / MonoGame and scale out across multiple game clients accordingly. Let's check it out!

Outline
Create solution in Visual Studio and build the entire game using XNA. Write all game code in an external library to be consumed by multiple thin clients for all destination platforms. Add any experimental clients.
 Alias  Name  Development  Framework  Description  Source Code
 XNA  Windows Game  Visual Studio 2010  XNA 4.0  Game server  Download
 WP7  Windows Phone 7  Visual Studio 2010  XNA 4.0  Game client  Download
 WIN  Windows Project  Visual Studio 2015  MonoGame 3.6  Game client  Download
 AND  Android Project  Visual Studio 2017  MonoGame 3.4  Game client  Download
 IOS  iOS Project  Visual Studio 2017  MonoGame 3.5  Game client  Download
 WP8  Windows Phone 8  Visual Studio 2015  MonoGame 3.6  Game client  Experimental
 MAC  Cross Platform Desktop  Visual Studio 2017  MonoGame 3.6  Game client  Experimental
 UWP  Windows Universal Project  Visual Studio 2017  MonoGame 3.6  Game client  Experimental

IMPORTANT
Now that Microsoft integrates iOS templates into Visual Studio all clients can be developed on Windows PC. Mac computer is still required for iOS and Mac deployments, however.

Implementation
Create top level SimpsonsTrivia node in Subversion SVN. Add 1x sub-node for the XNA solution and multiple sub-nodes, one sub-node for each destination client such as WinPhone7 [WP7], Windows PC, Android + iOS.
 Alias  Path  URL
 XNA  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.XNA  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA 
 WP7  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WP7  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.WP7
 WIN  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WIN  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.WIN
 AND  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.AND  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.AND
 IOS  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.IOS  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.IOS
As Simpsons Trivia is small stand-alone game there will not be standard SVN branches / tags / trunk setup.

XNA Game Server
Launch Visual Studio 2010. Create blank solution. Add the following 4x new C#/.NET projects to solution:
 Project  Type  Description
 SimpsonsTrivia.XNA  XNA 4.0 Game  Entry point + game built content
 SimpsonsTrivia.XNA.Library  XNA 4.0 Game Library  Generic game library for all clients
 SimpsonsTrivia.XNA.SystemTests  Windows Class Library  Uses for game library system tests
 SimpsonsTrivia.XNA.UnitTests  Windows Class Library  Uses for game library unit tests

Checklist
Here is a quick checklist of tasks to complete first including Delete the default C#/.NET file, Update project properties profile to use "Reach" and Rename the default namepsace to WindowsGame. Add the packages:

packages
  • log4net.2.0.5
  • Ninject.3.2.2.0
  • NUnit.3.2.1
  • RhinoMocks.3.6.1
SimpsonsTrivia.XNA
  • Add Data folder for all text file data
  • Add SimpsonsTrivia.XNA.Library ref
  • Remove all unused XNA references
  • Replace all initial game icons
SimpsonsTrivia.XNA.Library
  • Add Common folder for all game code logic
  • Add Master folder for all game engine code
  • Remove all unused XNA references
  • Add XNA Input Touch reference
  • Add log4net reference
  • Add Ninject reference
SimpsonsTrivia.XNA.SystemTests
  • Remove DataSetExtensions reference
  • Add SimpsonsTrivia.XNA.Library ref
  • Add nunit framework reference
  • Add nunit GUI test runner
SimpsonsTrivia.XNA.UnitTests
  • Remove DataSetExtensions reference
  • Add SimpsonsTrivia.XNA.Library ref
  • Add nunit framework reference
  • Add Rhino Mocks reference
  • Add nunit GUI test runner

IMPORTANT
Create directory symbolic link using mklink to XNA Content folder to run system tests [and on build server]

Start | run | cmd
mklink /D C:\SimpsonsTrivia.XNA.Content 
C:\SVN\SimpsonsTrivia\SimpsonsTrivia.XNA\SimpsonsTrivia.XNA\SimpsonsTrivia.XNA\bin\x86\Debug\

// BaseSsytemTests.cs
protected const String CONTENT_ROOT = @"C:\SimpsonsTrivia.XNA.Content\";

Manually edit system and unit test projects in Notepad and add following XML to mitigate MSIL warning:
<PropertyGroup>
  <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>

ALL Game Clients
Refer to initial table and launch Visual Studio to create multiple thin client projects. SVN externals used to link XNA library to all destination platforms [below] such as WinPhone7 [WP7], Windows PC, Android + iOS.


SVN Externals
Employ SVN Externals to avoid copy + paste programming for Common and Master code and content Data.
At the start of a project, there won't be any SVN Externals setup by default. Verify from Command prompt:
 Alias   Folder 
 WP7  cd C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WP7\SimpsonsTrivia.WP7
 WIN  cd C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WIN\SimpsonsTrivia.WIN
 AND  cd C:\SVN\SimpsonsTrivia\SimpsonsTrivia.AND\SimpsonsTrivia.AND
 IOS  cd C:\SVN\SimpsonsTrivia\SimpsonsTrivia.IOS\SimpsonsTrivia.IOS
Start | run | cmd. Type svn propget -R svn:externals
empty


SimpsonsTrivia.XNA
Scale game built content including all text file Data as shared across multiple thin clients via SVN Externals:

DATA
 Path  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.XNA\SimpsonsTrivia.XNA\SimpsonsTrivia.XNAContent\Data
 URL  H://svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA/SimpsonsTrivia.XNAContent/Data
* H:// = http://build/

Launch Windows Explorer | Navigate to following [parent] folder:
 Alias   
 WP7  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WP7\SimpsonsTrivia.WP7
 Action :  Right click "SimpsonsTrivia.WP7Content" folder
 WIN  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WIN\SimpsonsTrivia.WIN
 Action :  Right click "Content" folder
 AND  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.AND\SimpsonsTrivia.AND\Assets
 Action :  Right click "Content" folder
 IOS  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.IOS\SimpsonsTrivia.IOS
 Action :  Right click "Content" folder

Tortoise SVN | Properties | New... | Externals
In popup window click New button:
 Local path:  Data
 URL:  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA/SimpsonsTrivia.XNAContent/Data
OK | OK | OK

Start | run | cmd. Type svn propget -R svn:externals
. - http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA/SimpsonsTrivia.XNAContent/Data

Windows Explorer | Navigate to [parent] folder as before. Tortoise SVN | Check for modifications | Commit
Finally, right click C:\SVN\SimpsonsTrivia | SVN Update. Data folder available to include in ALL clients.


SimpsonsTrivia.XNA.Library
Scale all Common game code and logic + Master engine code across multiple thin clients via SVN Externals:

COMMON
 Path  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.XNA\SimpsonsTrivia.XNA.Library\Common  Common game
 URL  H://svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Common  code and logic.
* H:// = http://build/

Launch Windows Explorer | Navigate to following [parent] folder:
 Alias   
 WP7  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WP7\SimpsonsTrivia.WP7
 Action :  Right click "SimpsonsTrivia.WP7" folder
 WIN  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WIN
 Action :  Right click "SimpsonsTrivia.WIN" folder
 AND  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.AND
 Action :  Right click "SimpsonsTrivia.AND" folder
 IOS  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.IOS
 Action :  Right click "SimpsonsTrivia.IOS" folder

Tortoise SVN | Properties | New... | Externals
In popup window click New button:
 Local path:  Common
 URL:  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Common
OK | OK | OK

Start | run | cmd. Type svn propget -R svn:externals
. - http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Common Common

Windows Explorer | Navigate to [parent] folder as before. Tortoise SVN | Check for modifications | Commit
Finally, right click C:\SVN\SimpsonsTrivia | SVN Update. Common folder available to include in ALL clients.


MASTER
 Path  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.XNA\SimpsonsTrivia.XNA.Library\Master  Master game
 URL  H://svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Master  engine code.
* H:// = http://build/

Launch Windows Explorer | Navigate to following [parent] folder:
 Alias   
 WP7  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WP7\SimpsonsTrivia.WP7
 Action :  Right click "SimpsonsTrivia.WP7" folder
 WIN  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.WIN
 Action :  Right click "SimpsonsTrivia.WIN" folder
 AND  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.AND
 Action :  Right click "SimpsonsTrivia.AND" folder
 IOS  Folder :  C:\SVN\SimpsonsTrivia\SimpsonsTrivia.IOS
 Action :  Right click "SimpsonsTrivia.IOS" folder

Tortoise SVN | Properties | New... | Externals
In popup window click New button:
 Local path:  Master
 URL:  http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Master
OK | OK | OK

Start | run | cmd. Type svn propget -R svn:externals
. - http://build/svn/SimpsonsTrivia/SimpsonsTrivia.XNA/SimpsonsTrivia.XNA.Library/Master Master

Windows Explorer | Navigate to [parent] folder as before. Tortoise SVN | Check for modifications | Commit
Finally, right click C:\SVN\SimpsonsTrivia | SVN Update. Master folder available to include in ALL clients.


Summary
To summarize, there will most likely become a point where it is difficult / impossible to install XNA 4.0 plus required Visual Studio 2010 pre-requisite onto Windows PC. Especially if / when Windows 7 is deprecated.

Therefore, it seems sensible to upgrade to Windows 10 : transfer these skills to integrate MonoGame 3.6 on Visual Studio 2015 as new baseline. After this, Android and iOS ports can resume using Visual Studio 2017.

Consequently, the next posts will document just that; starting with Windows port then to Android and iOS J

1 comment:

donnaj edwards said...

Thank you for your articles that you have shared with us. Hopefully you can give the article a good benefit to us. Apple Developer Enterprise Account

Post a Comment