Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Jan 2008
Offline Last Active Mar 01 2012 09:26 AM

#4913676 How To Block(Cost)Cells Based on the Terrain ready for A* path finding.

Posted by on 16 February 2012 - 09:44 AM

now back to the problem at hand.
See the cliff at the left top the cell covers the top and the wall of the cliff how should I handle that sort of thing besides making smaller cells.
I want the units to go up there if they need to. thanks.

If you want to deal with variable size pathfinding nodes then perhaps it's worth looking into using Quadtree nodes for pathfinding.

This isn't a completed algorithm (and it's not my video either) but this demonstrates the idea well:

This may or may not be helpful:

Essentially, from the sounds of it, you're looking for pathfinding on a variable-size grid. If not, then I can think of only two other options. Place custom nodes manually or make the grid finer.

#4913483 Need help with an excercise from Beginning C++ 2nd edition

Posted by on 15 February 2012 - 04:12 PM

Thank you everyone, got it working now = )

You're welcome.

#4913401 Need help with an excercise from Beginning C++ 2nd edition

Posted by on 15 February 2012 - 11:26 AM

The problem lies on two lines...


		unsigned short int options; // <-- THIS ONE


} while (options == 1); // <-- AND THIS ONE

The problem lies in something called SCOPE.

Lets look at this...

int options;
//... other code here...
} while (options == 0)

Now options is contained within bracers, these control the SCOPE of the local variable. The variable options ONLY EXISTS within the curly bracers in which it was defined.

// options doesn't exist
int options;
// options exists
// options doesn't exist anymore.

Since you are trying to check your do/while loop with a variable that goes OUT OF SCOPE before the conditional statement, the compiler should flag an error and it DOES on Visual Studio 2010.

The easiest fix is to simply define options BEFORE the do-while loop.

//Program that allows a user to maintain a list of his or her favorite games.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
		vector<string> gameList;

		vector<string>::iterator myIterator;
		vector<string>::const_iterator iter;

		unsigned short int options;


		cout << "Select an option:\n";
		cout << "1 - Add a game to your favorites list.\n";
		cin >> options;

		string game;

				  cout << "\nAdd a game to your favorites: ";
				  cin >> game;

		gameList.insert(gameList.end(), game);

		cout << "\nYour current list:\n";
		for (iter = gameList.begin(); iter != gameList.end(); ++iter)
				cout << *iter << endl;
				} while (options == 1);
char theEnd;
cin >> theEnd;
return 0;

You'll find this code now works.

If you still don't understand, please let me know and I'll try to explain it more clearly.

Can someone please recommend/write a decent tutorial that explains scope in C++? There used to be a perfect one on about.com but I'll be blasted if I can find it now...

#4913197 How To Block(Cost)Cells Based on the Terrain ready for A* path finding.

Posted by on 14 February 2012 - 06:57 PM

I'm sorry but I've seen way too many people acting as if this community owes them their time. This is FREE advice you're getting here, try to respect it a bit better. One reply is better than none.

His advice is sound. There is nothing wrong with it. Perhaps if you provided a little more information about your A* implementation then people would be able to tailor their answers better to your... ability... to comprehend.

I sounds to me like you're using an A* algorithm that was coded by someone else and you don't really understand how it works.

There is a great section on pathfinding here:

Specifically to costs:

This is all I needed to write any pathfinders I've ever wanted.

#4913040 Java or C++?

Posted by on 14 February 2012 - 11:40 AM

Yes, C++ generally is the standard language in the game industry. Although, that being said, there are companies using C# and Java successfully to make decent games. Most notably Notch, who wrote Minecraft in Java.

I found Java programming pretty easy after being experienced with C++. While there are certain tricks, shortcuts, workarounds and techniques that are language-specific, the actual skill of programming games is something that caries over to any language or format.

My advice would be to use Java to write more and more complex games. Once you are extremely confident programming games in Java, start learning how to achieve the same results in C++. This way, you get to learn the complex systems of games in a language that you are comfortable with.