A* or Similar Pathfinding...

Game Editor comments and discussion.

Re: A* or Similar Pathfinding...

Postby skydereign » Mon Oct 03, 2011 9:30 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: A* or Similar Pathfinding...

Postby EvanBlack » Mon Oct 03, 2011 11:44 pm

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.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: A* or Similar Pathfinding...

Postby skydereign » Mon Oct 03, 2011 11:56 pm

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;
      }
    }
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: A* or Similar Pathfinding...

Postby EvanBlack » Tue Oct 04, 2011 12:07 am

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!
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Previous

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest