Rand moving to clones!

Talk about making games.

Rand moving to clones!

Postby Camper1995 » Sat May 02, 2009 11:28 am

Hi ppl, I wanna know, how can I make this:
I have one player called P and 3 clone actor called E. So, when I click on
player, the player will move RANDOR to clone 1 or clone 2 or clone 3...
Is this possible?

Thanks, Camper :D
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Rand moving to clones!

Postby jimmynewguy » Sat May 02, 2009 2:28 pm

ummm im sure there is a better way to do this, but im too tired to think of one :lol:
Code: Select all
int random;
random = rand(number of clones);
switch(random)
{
case 0:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.0", "");
break;
case 1:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.1", "");
break;
//ect.
}


really long way though, maybe someone will think of the way i can't remember lol :lol:

Hold on i might have it gimme a sec
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Rand moving to clones!

Postby Camper1995 » Sat May 02, 2009 9:37 pm

Man, I dont understand this :D :D :D

I have maked this, this way: I make variable caller "var"
So, on, player, when he create, var=ceil(rand(3)); //rand "var" for 3 clones...

Then, when you click on player, If(var==1)
mover to...
if(var==2)
move to...
ETC.
:)
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Rand moving to clones!

Postby jimmynewguy » Sat May 02, 2009 10:55 pm

my code is basically that same thing, let me break it down for you

Code: Select all
int random;//create the actor variable named random;
random = rand(3);// you know this since it was in your code :)
switch(random)//switch the variable so you don't have to do if(var == 1)ect; case is like if(var ==)
{
case 0:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.0", "");//if case \\ 0 moveto actor 0
break;
case 1:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.1", "");
break;
case 2:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.2", "");
break;
}
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Rand moving to clones!

Postby skydereign » Sat May 02, 2009 11:28 pm

This is one way to do it. If you want me to explain I can, basically it uses getCloneIdx to give you the clones x and y.
Gobal Code
Code: Select all
Actor * getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];

    sprintf(buffer,"%s.%i",cname,cindex);

    return(getclone(buffer));
}

Actor* target;
int RANDOM;


Event that decides which clone to go towards
Code: Select all
RANDOM=rand(3);
target = getCloneIdx("E", RANDOM);
// Probably need a triggered variable


P->DrawActor->Script Editor
Code: Select all
// Probably need a conditional
MoveTo("Event Actor", target->x, target->y, 100, "Game Center", "");
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Rand moving to clones!

Postby Camper1995 » Sun May 03, 2009 7:59 am

Oh, :D ...its little bit complicated for me, but, I try to do this with this code.

And just one question. I have an actor called "factory" and another actor called "smoke"
So, how to do, when the factory create, create actore smoke, but in top of factory.
So, this is easy, but how to do this, when I have clones, you know, that smoke will be moved only to the one factory, but I want,
everytime when you buy factory and when you build it, the smoke will be create to the smokestack of that factory...
Do you understand? :D :D

Thanks for helping me :D
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Rand moving to clones!

Postby skydereign » Sun May 03, 2009 8:13 am

The method I had before, if you can understand it, will help a lot with clone work. I can explain more if you want. It uses Actor*s, which allow you to access a specific actor. The function getIdxClone gives back a specific clone's Actor*, pending what idx you give it. That means you can use that clone directly, it is similar to the getClones.
Okay, so you want the most recent factory to have smoke created from the top? If the factories are just clones of themselves, and you really just want the most recent to make smoke, then in the draw script that creates the smoke, just do this
Code: Select all
if(cloneindex==(ActorCount("factory")-1))
{
    //Create Actor code here
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Rand moving to clones!

Postby jimmynewguy » Sun May 03, 2009 2:29 pm

just curious, what kind of game will this be :)
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Rand moving to clones!

Postby Camper1995 » Sun May 03, 2009 5:40 pm

strategy, if you want, I can post demo :)
Its good game. :D
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Rand moving to clones!

Postby jimmynewguy » Sun May 03, 2009 6:17 pm

lol that's what i've been working on :lol: , can i see yours? I might post a demo for mine soon :)
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest