Page 2 of 2

Re: A* or Similar Pathfinding...

PostPosted: Mon Oct 03, 2011 9:30 pm
by skydereign
Okay, every actor has a name, cloneindex, and clonename. An Actor* is a way of accessing an actor's variables (like x, y, animpos, animindex...). All an Actor* is, is a way of accessing any of the actor's variables. So you can use actor->name, or actor->clonename. But, only use this on existing actors.

Your use of getclone does that. But, it uses getclone on a non-existing actor, so it can get a fake Actor*. If you want to create a clone, you just need to create another Tile actor.

When you use CreateActor, the first parameter needs a name variable, not a clonename. You accounted for this in your code, by using ->name. But, the name is the same thing as the clonename without the .cloneindex.

For generating the map, you'll most likely have a nested for loop, with CreateActor inside.

Re: A* or Similar Pathfinding...

PostPosted: Mon Oct 03, 2011 11:44 pm
by EvanBlack
I tried using createactor() to create the tiles but it would only make 1. It would only create the actor that was available and wouldn't create more. If I wanted more tiles available for the map I would have to create them all one by one manually. I even tried using and positioning clones and it wouldn't work.

I was able to position the actors (not clones) but if I wanted a map of say 1000 tiles I would have to create, BY HAND, 1000 tiles. This is very time consuming. If you have a .ged that actually creates tiles from one actor I would like to see that.

I added my demo of what I made, it makes nodes.

Re: A* or Similar Pathfinding...

PostPosted: Mon Oct 03, 2011 11:56 pm
by skydereign
All the code is in the view's create actor. The actual map array is in global code.
http://game-editor.net/media/kunena/attachments/66/tiles.ged.zip

This is generally how people make map editors. The three ways people make levels are using gE's tile system, creating a map with arrays, and last is to create clones one by one in the level. The way I've been talking about, and you've been making it sound like, is the array system. In the example, the array has either 0, 1, or 2 in each sub. 0 doesn't create an actor, and 1 colors the actor, 2 makes the actor not colored. Instead of using color, usually you use different animations.

-Edit
I forgot to reverse i and j. So the map is rotated by 90 degrees. Here's what the script would look like with it correct.
Code: Select all
int i, j;

for(j=0;j<10;j++)
{
    for(i=0;i<10;i++)
    {
      if(map[i][j]!=0)
      {
        CreateActor("test", "icon", "(none)", "(none)", i*40+50, j*40+50, false)->r=map[i][j]*127;
      }
    }
}

Re: A* or Similar Pathfinding...

PostPosted: Tue Oct 04, 2011 12:07 am
by EvanBlack
Thank you! But I still don't understand why my code wouldn't make the tiles even when I didn't use the clone. I am going to re-read everything you said and try to fix my code. Thanks!!


OMG! THANK YOU!!! It works now!