Walking duck

Started by Whelandrew, Sat 14/08/2004 08:54:11

Previous topic - Next topic

Whelandrew

I have a duck. I want this duck to walk around the screen. It has no real purpose but to add a bit more decor to the screen it's in. My problem is that my hours of battling scripting has left me without any idea how to get the Duck to walk around randomly on the screen.

How can I get it to just walk around the screen with no set direction?
The bulb in my reading lamp went out.
I'm seeking enlightenment.

Phemar

short re=0;
while (re<1) { //will repeatedly execute
  MoveCharacter (DUCK, Random(320), Random(200));
  }

I haven't fully tested this out yet so there may be errors. The problem that might come here is you'll need a wait command somewhere, defeating the whole purpose... I dunno.

Darth Mandarb

#2
Sprinkle bread crumbs around the background.

I kid ...

You can get Scorpiorus' Character Control System ... it might be what you're looking for.

Aside from that there's the, moveCharacterPath command you could look up the syntax in the help file ('cause I don't know it off hand!)

Mr Jake

#3
that will cause errors because its an infinate loop (wouldn't it?)

a way to do it might be:

If (walk == 0){
MoveCharacter (DUCK, Random(320), Random(200));
walk = 1;
}

if (Character[DUCK].walking == 0) {
walk = 0;
}

put this into the Rep_exe of the room, and make sure you define
int walk
at the start of the room script.

Ashen

In the rooms rep_ex:

if (character[DUCK].walking  == 0) {
  MoveCharacterStraight (DUCK, Random (320), Random (240));
}

(Works for me, anyway)
The MoveCharacterStraight command means you can limit it to walkable areas (or, perhaps,  create a seperate area to be a pond). To have it wander the whole screen, replace it with MoveCharacterDirect.
I know what you're thinking ... Don't think that.

Mr Jake

duh, stupid me, those Ints were useless. :)

Ashens code does the same and mine but with less lines.

Scummbuddy

you can make it so that it runs on a variable. and have it to have 4 "walk points". when it reaches one point, you add to the variable, which an if statement would cause it to find its way to the next point, and continue the procedure.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Whelandrew

Yes! Ashens code did it! Thank you, Ashen! Now my duck is walking around and bouncing off the trees and buildings like a good little ignorant bird.
The bulb in my reading lamp went out.
I'm seeking enlightenment.

Phemar


YOke

I used an alternate solution in the soon to be released teamgame. There I had several child characters that were supposed to roam randomly around an object and, at one point, follow the character. For this i used an invisible character standing still that all the child-characters followed.
I used the FollowCharacterEx (CHARID, int chartofollow, int dist, int eagerness)

Adjusting dist to the distance they were allowed to roam from their parent, and eagerness to 0 to keep them wandering around randomly.
Might not be the best solution for a single character, but for a flock it worked like a charm.

Enlightenment is not something you earn, it's something you pay for the rest of your life.

SMF spam blocked by CleanTalk