Page 1 of 1

Random actor placement

PostPosted: Fri Feb 10, 2006 5:49 pm
by stevirt
I have an actor(ball) that pops up on the screen. When ball is touched by a controllable actor, ball changes to that actor's color (and remains there) and a new actor(ball) pops up randomly on the screen. I don't want the new ball actor that pops up to be on top of one that is already there. Is there a way to check and see if an actor is already in that location before placing one on top of it? Or any other ideas on how to make sure that each random coordinate is only used once?

Thanks for any help!

PostPosted: Fri Feb 10, 2006 6:33 pm
by Novice

PostPosted: Sat Feb 11, 2006 7:33 am
by stevirt
Thanks Novice! - I thought the answer must be out there somewhere - I guess I was looking up the wrong keywords.

PostPosted: Sat Feb 11, 2006 10:29 am
by Novice
NP. Where here to help :wink:

PostPosted: Sun Feb 12, 2006 4:00 pm
by Troodon
There is no other way to check if the place is allready taken!? :( :( :shock: :shock:

PostPosted: Sun Feb 12, 2006 5:45 pm
by makslane

PostPosted: Mon Feb 13, 2006 7:02 pm
by Troodon
Thanks! I searched it from every where in this forum but not from the documentation. :oops: :oops: :oops: :oops:

PostPosted: Tue Feb 14, 2006 7:07 am
by stevirt
Hi Makslane. Iv'e tried using the CollisionFree function but I can't seem to get it to work. Is it checking to see if there is any actor there or just one of it's own kind.

In this example I am checking to see if there is a green actor in the position. If there is not, then I want to put a monkey there. But it puts one there regardless of wether there is a green one or not:

if (CollisionFree("green", r1a, r2b))
{
monkey.xscreen = r1a;
monkey.yscreen = r2b;
}

Am I writing this function correctly?

PostPosted: Wed Feb 15, 2006 1:14 am
by makslane
In this case, I think is better test with getactor function:

Code: Select all
Actor *MyActor;
MyActor=getactor(r1a, r2b); //r1a, r2b must be game coordinates

if (strcmp(MyActor->name, "green") == 0)
{
  //There is a green actor at position
  //Assign the game coordinates
  monkey.x = r1a;
  monkey.y = r2b;
}

PostPosted: Wed Jun 20, 2007 12:11 am
by Murd-Machine[_]
I think getactor is very useful piece of code. But how do I use it if I have a lot of actor in one position? For instance I have ground, building, soldier, selection field, soldiers hud and so on. And I need to check if there is only field actor on the position. How do I control it? :roll: