Random actor placement

Game Editor comments and discussion.

Random actor placement

Postby stevirt » Fri Feb 10, 2006 5:49 pm

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!
stevirt
 
Posts: 9
Joined: Fri Feb 10, 2006 4:27 am
Score: 0 Give a positive score

Postby Novice » Fri Feb 10, 2006 6:33 pm

Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby stevirt » Sat Feb 11, 2006 7:33 am

Thanks Novice! - I thought the answer must be out there somewhere - I guess I was looking up the wrong keywords.
stevirt
 
Posts: 9
Joined: Fri Feb 10, 2006 4:27 am
Score: 0 Give a positive score

Postby Novice » Sat Feb 11, 2006 10:29 am

NP. Where here to help :wink:
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Troodon » Sun Feb 12, 2006 4:00 pm

There is no other way to check if the place is allready taken!? :( :( :shock: :shock:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby makslane » Sun Feb 12, 2006 5:45 pm

Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Troodon » Mon Feb 13, 2006 7:02 pm

Thanks! I searched it from every where in this forum but not from the documentation. :oops: :oops: :oops: :oops:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby stevirt » Tue Feb 14, 2006 7:07 am

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?
stevirt
 
Posts: 9
Joined: Fri Feb 10, 2006 4:27 am
Score: 0 Give a positive score

Postby makslane » Wed Feb 15, 2006 1:14 am

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;
}
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Murd-Machine[_] » Wed Jun 20, 2007 12:11 am

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:
User avatar
Murd-Machine[_]
 
Posts: 72
Joined: Fri Nov 04, 2005 7:04 pm
Location: Moscow-city
Score: 1 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron