To be able to use Neat, you need to create a class that inherits NeatGame, the core of Neat Engine. NeatGame inherits the Game class which is the main class in XNA games, so it is easy to modify the code you’ve already written to use Neat.
To create a Neat-based project, follow these steps:
Locate Neat.exe using the Browse tab:
Right click on the solution, and choose Add…>Existing Project… .Then locate NeatContent project file using the Add Existing Project dialog.
Now you should be able to see Neat content files in your solution. To add a reference to these content, right click on the Content References folder of your main game project and click Add Content Reference…
Choose NeatContent.
using Neat;
And your main class should inherit from Neat.NeatGame instead of Microsoft.Xna.Framework.Game; Which means you should change public class Game1 : Microsoft.Xna.Framework.Game to public class Game1 : NeatGame .
Because Neat handles most of the stuff internally, you must delete these lines from the code and let Neat take care of them:
GraphicsDeviceManager graphics; SpriteBatch spriteBatch; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; spriteBatch = new SpriteBatch(GraphicsDevice);
Basically, your could should be like this:
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Neat; namespace MyNeatGame { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : NeatGame { public Game1() { } /// <summary> /// 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. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { base.LoadContent(); } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here } /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // TODO: Add your update logic here base.Update(gameTime); } /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { // TODO: Add your drawing code here base.Draw(gameTime); } } }
If you build and run the project at this time, you can see the Main Menu screen in front of an undefined sprite. You can also access a fully functional Options menu where you are able to change the basic settings of the game like the resolution and the sound, and if you press the Tilde (~) button, you can work with Neat Console and Neat’s scripting features.
Each Neat game is made of a couple of Screens. for example, Each menu is a different screen. Neat’s Screen class helps you create a screen.
You can skip steps mentioned above by downloading the NeatStarter project which acts as a template for new Neat-based games. The NeatStarter project can be downloaded from the Releases section.
Good Luck!