Jump to content

  • Log In with Google      Sign In   
  • Create Account


TehOwn

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 TehOwn 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:
http://www.youtube.com/watch?v=95aHGzzNCY8

This may or may not be helpful:
http://www.stanford....pen_terrain.pdf

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 TehOwn 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 TehOwn on 15 February 2012 - 11:26 AM

The problem lies on two lines...

do
		{

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

and

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

The problem lies in something called SCOPE.

Lets look at this...

do
{
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;

		// DEFINED BEFORE THE DO-WHILE.  
		unsigned short int options;

		do
		{

		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 TehOwn 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:
http://theory.stanfo...ameProgramming/

Specifically to costs:
http://theory.stanford.edu/~amitp/GameProgramming/MovementCosts.html

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


#4913040 Java or C++?

Posted by TehOwn 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.


PARTNERS