With this post, I would like to close efforts to port chapter 3. I have completed all steering behaviors. Added one control view to enable switching on/off of some parameters in the SHOAL build.
Couple of things that are not working or I have not attempted to further debug/complete are the Smoother Class, Spatial Partitioning, and Neighbor Rendering. Neighbor Rendering works partially as you will see. I did not pay that much attention to memory management too except for creating auto-release objects. My itch to move to either chapter 4 or chapter 5 is greater than my commitment to stick to all of Mat's chapter 3 code. So I have omitted what I think is not pertinent to the actual behaviors, especially the render aids etc.
As usual, build the code with uncommenting just one behavior in the BehaviorControl.h file. Following are the behaviors listed and that will work.
- Seek
- Arrive
- Pursuit
- Wander
- Evade
- Flee
- Hide
- Offset Pursuit
- Interpose
- Path Following
- Wall Avoidance
- Obstacle Avoidance
Wander and Evade are part of the builds, so you don't find them explicitly listed. Also added, touch recognition to move the crosshair in some of the behavior tests.
The SHOAL build shows the the control view. This control view could possibly be expanded upon to show render aids in other builds too. And could possibly be somehow used when there is more real estate on a screen like iPad.


There are many parameters that can be tweaked in the SteeringBehavior class. I have tried my best to tweak them just enough to make all the behaviors in my BehaviorTests.h file work as expected.
Did I understand every single line of the code which I ported? Absolutely not. But do I have a fair idea of how things work? Certainly yes. This is in part due to my debugging sessions. And I really doubt I would have understood as much if I had not attempted to port the code. I hope my efforts benefit someone even if they do not help me in completing a game in future.
I am not sure whether to go to Chapter 4 (Sports Simulation) or Chapter 5 (Graphs) but I would guess graphs are more important. One thing I can say is that Mat's book looks small but there is so much content and code to cover that its going to take a while for me to finish the book I think. Some of the road blocks I may face in using iOS is when Mat starts to use Lua for some of the scripting based games. In the meantime, I have begun to start thinking of how the knowledge so far acquired can be of help in thinking of a game concept.
SteeringBehavior Objective-C Chapter 3 Port :
SteeringBehavior Objective-C Chapter 3 Port :
Im looking through your code and realising what a fantastic achievement it is to get as far as you have! Truly Matts book covers so many complicated topics, he makes them sound simple, until you delve into the detail.
ReplyDeleteIll put a +1 vote on chapter 4 next, as that is the interesting part for me. After doing much research, there is much interest from sports fans to generate a "Sports Management" game for their sport of choice. Creating Rosters, leagues etc seems easy enough. The true challenge is in creating a truly representative simulation of a match. It appears Matts Soccer game is truly a foundation of such a simulation.
However if you choose to go to Chapter 5 next have fun, it might force me to spend the time to try the port for myself based on your code :.)
Well done!
@Ross Millan Thanks Ross! And thanks to @Jawzapps for the Cgdi class. I did not need to think too much there! Its been very eye opening when I compare this book to all those other "Make a game in iOS in a day" books. I have started reading chapter 5 as the game concept I have may by more of an RPG/RTS game (if it ever sees the light of the day) and graphs seem to be important to that. I definitely plan to visit chapter 4 either later or in case there is dependency in the code connecting chapter 5 to 4. Right now they look independent enough.
ReplyDeleteHi Nata,
ReplyDeleteI am working on a sheepherding game for iPad using cocos2d-my final yr Uni Project & am quite interested to see your implementation of the steering behaviours but the link is broken :( Any chance you can upload this to a dropbox folder & mail the link to me? Many thanks nev
@Nevena I have fixed the links for both the source code file and the doxygen class diagrams. Hope it helps your project at least, as I have not been able to do much with it after I ported. If I was to port the code now, it will be much cleaner but as such the code you see just works without any performance optimizations. Please note this code is straight port of the book's code that I was reading and hence has a lot of Math code too. I am sure using Cocos2d libraries my port can be cut down a lot. Drop me a word if you do end up using some part of my code.
Delete