Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


berben12

Member Since 06 Feb 2011
Offline Last Active Aug 26 2012 08:39 PM

Topics I've Started

XNA - Creating Scripting Paths for Indie Game

08 June 2012 - 02:41 PM

Hello Everyone!

Currently, I have been working hard on a new Indie game! And I just finished adding animated movement into the game, which allows moving objects along paths. Each path is connected to a series of waypoints, and each edge can give different instructions to the object which is currectly moving along it. Think of like a ride, where each track can change the speed of the gears to create different mechanics of the object above.

To accomplish this new animated movement goal, I had to add several new scripting commands to my Indie game engine. The new commands allow me to choose some artwork, like a Palm-Tree, and tell it to move along a pre-created path system. So far, I have added rotations, translations, and scaling ability on any one path edge! This allows for multiple movements at the same time.

Also, I updated my cinematic camera system, to allow for smooth camera movement along other waypoint paths! This will allow for some cool effects, like introduction sequences.

Now, I was able to accomplish the movement paths, by creating a simple class which holds a collection of Queued items. Each item can be some scripting request, like move along this path. Then the next scripting request could be to rotate. Each of these request are then bunched up and stuck into this queue. I then have a manager class, which checks the queue each game cycle, and performs an operation on this particular scripting action! Once the request is complete, the manager will automatically take the item out of the queue.

So, with my new movement scripting system in the engine, I can simply script quick updates with a few scripting lines!

Check out my video with these new features; Posted Image


XNA – My PumpkinToss Game – Path Movement Scripting

01 June 2012 - 02:21 PM

Hello Everyone!

Posted Image

A simple idea, like tossing some pumpkin in XNA can take some time and thought to complete. I originally started my Indie game engine "Temporal Wars" back in 2008 with the idea of creating a specific Real-Time-Strategy game. Now, in 2012, I decided to change gears and update the engine to allow for some simple and complex movement patterns, based on scripting calls.
The idea is to transform some XNA scene item, like a rotation action, scale action or movement action. With this in mind, I started creating some simple scripting calls which allows updating any scene item in the engine. After several hours of work, I came up with a couple of basic commands to move an object. But, the problem with these simple move commands was the fact they only allowed movement from point A to point B. What I needed was a more complex movement concept, where the movements would combine different operations, like the scaling with movement, while following some path. As I thought about this a little longer, I then came up with another idea, which was to allow different movement actions based on a paths edge! This would then allow an item to move on a mult-path connection, changing speeds and rotation, while on the same path! So, how did I accomplish this? Well... with some nifty collections, queues and stacks, all hidden by some simple scripting calls at the end.

Posted Image

Once I got the code completed, I was able to test my new path movement idea! As you can see in picture-A, a path was created in the engine, which moves between waypoints 1 - 5. Each red line in between the waypoint pairs is called an 'Edge'. As some scene item moves along the path or edge, it reacts differently, depending on what actions are entered for that 'Edge'. The palm tree is slowly moving along this path, with the first edge doing a simple movement interpolation between the two waypoints.

Posted Image

By the time the palm tree reaches the edge junction point, between waypoint 3 and 4, then scaling operation takes effect automatically, as shown in prior picture. By the time it reaches the end of the path, the palm tree is now scaled back to full size, and is doing a rotation. Any 'Edge' can have multiple scripting action request for some scene item!

Posted Image
Once you set your edges with the required actions, it is just a matter of calling one 'Scripting' call, and away your scene items goes!! :)

Ben
www.temporalwars.com

A* Pathfinding Game Late-Bindable Component

23 April 2012 - 10:03 PM

The AStarComponent.dll is now available in the marketplace, within the software development section! Posted Image
What you Get!

The download zip file contains the 'AStarComponent.dll' assembly, designed to be usable in any other XNA project for the PC and Xbox-360. You can also use the bindable component in other types of projects, like simple WPF (Windows Presentation Format) projects for school demonstrations or for learning the A* algorithm. The 'AStarComponent.dll' assembly is designed for extreme performance, and was tested 1000 of hours on the Xbox-360 and PC.

The download zip also contains a simple WPF (Windows Presentation Format) 'AStarSampleApp', shown in the picture in the marketplace, which shows you how to use the A* pathfinding component. With this sample application, you can study the C# code to see how to call and create A* solution paths in seconds. The code shows how to start bind the assembly, initialize the internal A* graph, and make "Find-Path" solution paths in a matter of seconds!

Feel free to use the code in any project you desire!

AStar Game Late-Bindable Component - XNA/PC

17 April 2012 - 08:30 PM

Hello everone!

I have learned a lot from these forums about pathfinding. I have also read quite a few articles and books on the subject. After all the reading, I decided to put together my own 'A*' component.

The A* component is designed to run on the Xbox 360, using the XNA framework. It also it usable in other applications, like within PC games or WPF window applications.

One of the topics I read about was regarding the use of 'Cheap List'. I'm sure some of you have heard of this, since it was used in an older RTS game; originally created in C++. Well, I decided to incorporate this 'Cheap List' into this A* component, and damn... it made a huge difference! The search time went from 250 ms down to 1-8 ms per search! Crazy.

Recently, I decided to decouple the A* from my Indie game engine, and make it usable outside the engine. I recently created a WPF application sample, which shows how this works and a YouTube video using this A* component.


Using “Late-Binding” in XNA 4.0 and the importance of Interfaces

07 April 2011 - 06:08 PM

When I first started programming my TemporalWars 3D game engine in 2008, very few interfaces were used. However, as the program grew in complexity I quickly realize the importance of compartmentalizing code and abstracting the connections to those units using ‘Interfaces’. For those who are not aware of what an Interface is, an Interface is simply the description of the connections (properties, methods, events) you are making public to some component or class. As your program grows in complexity, you quickly will appreciate the power interfaces bring to your project. So, some of you are reading this saying, “I already know that! What the point?” Well, let’s talk about ‘Late-Binding’ first and connect how Interfaces become useful in this situation.


Posted Image


“Early-Binding” is the typical way of programming, where you add some reference to an assembly at the top of the code-base, using C# as an example, and compile the program. With “Early-Binding” the program is aware of the assembly before compilation. In comparison, “Late-Binding” is binding some assembly after a program is compiled, which the original program was not aware of or didn’t have access to the base code during the original compilation.

In the TemporalWars 3D Engine I built, I used the following code to achieve “Late-Binding”;

 // 12/31/2009[font=Consolas][size=2][/size][/font]

     	[color=gray]///[/color][color=green] [/color][color=gray]<summary>[/color]

     	[color=gray]///[/color][color=green] Allows LateBinding some Assembly (dll) file, and then will[/color]

     	[color=gray]///[/color][color=green] instantiate the given 'ClassName', and return the object to the caller.[/color]

     	[color=gray]///[/color][color=green] [/color][color=gray]</summary>[/color]

     	[color=gray]///[/color][color=green] [/color][color=gray]<param name="assemblyFile">[/color][color=green]AssemblyFile name to load[/color][color=gray]</param>[/color]

     	[color=gray]///[/color][color=green] [/color][color=gray]<param name="className">[/color][color=green]Class Name to instantiate within Assembly[/color][color=gray]</param>[/color]

     	[color=gray]///[/color][color=green] [/color][color=gray]<param name="instantiatedObject">[/color][color=green](OUT) Instantiated object[/color][color=gray]</param>[/color]

     	[color=gray]///[/color][color=green] [/color][color=gray]<returns>[/color][color=green]True/False of success[/color][color=gray]</returns>[/color]

 

    	     	[color=blue]private[/color] [color=blue]bool[/color] LateBindAssembly([color=blue]string[/color] assemblyFile, [color=blue]string[/color] className, [color=blue]out[/color] [color=blue]object[/color] instantiatedObject)

     	{

             instantiatedObject = [color=blue]null[/color];

  

         	[color=blue]try[/color]

         	{

  

                 [color=green]// set platform location to load from.[/color]

 #if[size=2] XBOX360[/size]

             	const string platformType = "XBox360";[font=Consolas][size=2][/size][/font]

 #else[size=2][/size]

                 [color=blue]const[/color] [color=blue]string[/color] platformType = [color=#A31515]"x86"[/color];

 #endif

  

                 [color=blue]var[/color] a = [color=#2B91AF]Assembly[/color].LoadFrom([color=#A31515]"0LateBinds/"[/color] + platformType + [color=#A31515]"/"[/color] + assemblyFile);

  

                 [color=blue]var[/color] mytypes = a.GetTypes();

  

                 [color=green]//const BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static |[/color]

                 [color=green]//                           BindingFlags.Instance);[/color]

  

                 [color=green]// Search for Instance to instantiate from Assembly.[/color]

                 [color=blue]foreach[/color] ([color=blue]var[/color] t [color=blue]in[/color] mytypes)

                 {

                     [color=green]//var mi = t.GetMethods(flags);[/color]

  

 #if[size=2] XBOX360[/size]

     // locate class instance to instantiate.

             	if (t.Name == className)[font=Consolas][size=2][/size][/font]

             	{

                 	instantiatedObject = Activator.CreateInstance(t);[font=Consolas][size=2][/size][/font]

                 	((ICommonInitilization) instantiatedObject).CommonInitilization(this);

                 	return true;[font=Consolas][size=2][/size][/font]

             	}

 #else[size=2][/size]

                     [color=green]// locate class instance to instantiate.[/color]

                     [color=blue]if[/color] (t.Name == className)

                     {

                     	instantiatedObject = [color=#2B91AF]Activator[/color].CreateInstance(t, [color=blue]this[/color]);

                     	return [color=blue]true[/color];

                     }

 #endif

  

  

                     [color=green]/*foreach (var m in mi)[/color]

             	{

                 	m.Invoke(obj, null);[font=Consolas][size=2][/size][/font]

             	}*/[font=Consolas][size=2][/size][/font]

                 }

  

                 [color=green]// Name not found[/color]

                 [color=blue]return[/color] [color=blue]false[/color];

         	}

                 [color=green]// 1/1/2010 - Capture the possibility of the DLL not being in the folder at all.[/color]

         	[color=blue]catch[/color] ([color=#2B91AF]FileNotFoundException[/color]) [color=green]// PC throws this.[/color]

         	{

                 

                 System.[color=#2B91AF]Console[/color].WriteLine([color=#A31515]@"DLL Component {0} not found.  Therefore, this will be skipped for late binding."[/color], assemblyFile);

    	         [color=blue]return[/color] [color=blue]false[/color];

         	}

         	[color=blue]catch[/color]([color=#2B91AF]IOException[/color]) [color=green]// XBOX throws this.[/color]

         	{

                 System.[color=#2B91AF]Console[/color].WriteLine([color=#A31515]@"DLL Component {0} not found.  Therefore, this will be skipped for late binding."[/color], assemblyFile);

                 [color=blue]return[/color] [color=blue]false[/color];

         	}

 #if[size=2] !XBOX360[/size]

         	[color=blue]catch[/color] ([color=#2B91AF]ReflectionTypeLoadException[/color] err)

         	{

                 [color=blue]if[/color] (err.LoaderExceptions != [color=blue]null[/color])

                 {

                     [color=green]// List out each LoaderException error to console.[/color]

                     [color=blue]foreach[/color] ([color=blue]var[/color] loaderException [color=blue]in[/color] err.LoaderExceptions)

                     {

                     	if (loaderException.Message != [color=blue]null[/color])

                         	System.[color=#2B91AF]Console[/color].WriteLine([color=#A31515]@"LoaderExceptions reflection error - {0}"[/color], loaderException.Message);

                     }

  

                     [color=#2B91AF]MessageBox[/color].Show(

                     	@"Late-Binding failed, due to a Loading Exception on the Interface!  This usually occurs if you have an outdated interface; please update your interface for the assembly you are trying to late-bind.",

                     	@"LateBind Error", [color=fuchsia]MessageBoxButtons[/color].OK, [color=fuchsia]MessageBoxIcon[/color].Exclamation);

                 }

  

                 System.[color=#2B91AF]Console[/color].WriteLine([color=#A31515]@"DLL Component {0} reflection error.  Therefore, this will be skipped for late binding."[/color], assemblyFile);

                 [color=blue]return[/color] [color=blue]false[/color];

         	}

 #endif

     	}

 
 


The important piece to recognize is the C# line of code ‘instantiatedObject = Activator.CreateInstance(t, this); ’. This is the key to creating the “Late-Binding” component and using it in the runtime.

But now I ask you, if the original program is not aware of the code until runtime, how could you possibly use any “Late-Bind” object. Well, this is where ‘Interfaces’ come into play, which means at a minimum, the original program needs to be aware of the interface. However, even with this limitation, this concept does provide benefits.

In my TemporalWars 3D game engine, I used the concept of “Late-Binding” to abstract or separate out certain sections of code base from the original program; for example, the ‘AStar’ pathfinding component or the ‘Minimap’ component. This allows the main engine to be used separately without knowledge of these components, other than their interfaces. Then just by dropping one of these ‘Late-Bind’ components into a folder, the program will check for any components and then automatically bind and instantiate them at runtime. Immediately, the component becomes active and usable via the Interfaces.

You can download a copy of the “Minimap Component” at the following codeplex addresss => http://temporalwars.codeplex.com, which is late-bindable project.

PARTNERS