I have three bits of code that are finally beginning to fit together in a pathfinding function I'm working on. Most of the pathfinding method itself hasn't been written yet, but after a day of trying to figure out how array and object syntax work, I'm having one last problem with these three bits:
a class defining each individual tile on the grid I'm trying to find paths over
a class that creates an array from that class
And the main code that calls the pathfind method.
That last line is being flagged with the error:
"Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static method pathfind(byte,byte,byte,byte,boolean,initalize.battle.pathfinding) cannot be referenced from a static context
There are two kinds of methods in java - static and non-static.
A static method is one that can be called without there being any object. It doesn't rely on the state of something. For example, a square root function can be called and you can get the result if you pass it in a number. i.e. sqrt(25) would return 5.
a non-statis method is one that needs an object to have been created. For example, it makes no send to call a method getName() if there is no Dog object created. What, exactly, would you get the name of?
You are calling a non-static method (pathfinding()), but doing so with the general class name, not a specific object. Jasonhu's suggestion should work.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors