berben11 0 Newbie Poster

Hello Everyone!


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.


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.


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!


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 Scharbach

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.