Problem with diagonal wall baseline

Started by beomoud, Mon 16/02/2009 11:28:09

Previous topic - Next topic

beomoud

What i want to do is have a diagonal wall but i don't know what to do with it's baseline. When the character is in one side another may be on the other side and may appear to be in front of the wall when i need him to be behind it... How do i handle this?

jastorman

You could split the wall into several walk-behinds, each with a different baseline. There is probably a smoother way of achieving the same result, but I don't know it.
Bren,

From such crooked wood as that which man is made of, nothing straight can be fashioned.

Charity

#2
I would use regions.  Put a region over all the walkeable areas behind the wall.  Set the wall's baseline to the highest point on the wall that a character can stand in front of.

In the room script, make a function something like
Code: ags

function BehindWall (this Character*) {
  if (region[1].GetAtRoomXY(this.x, this.y) (
    int offset = this.y - [[a number greater than the difference between the wall's baseline and the lowest point where you can stand behind the walll]];
    if (offset<1) offset=1; //Experiment with removing this line, but I'm pretty sure it will crash you if you go to close to the top of the screen.
    this.baseline=offset;
  }
  else this.baseline=this.y;
}


Then in the room's repeatedly execute script, run the BehindWall function on every character that has the potential of standing behind the wall.

I haven't tested this, and depending on how the layout is, it might produce some weird results.  But something along these lines might work for you.

If you can make it so only one character ever goes behind the wall, you can just use the region and reset the wall's baseline with SetWalkBehindBase.

Trent R

#3
Lyaer's code sounds like it should work. But I personally would change this Character* to something like Character *CharAtRegion. This is because 'this' is used for extender functions, and it would bother me to see player.BehindWall pop up on the Autocomplete.

But that is purely a personal opinion. Nothing wrong with the code itself.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

Some additional thoughts:
if the second character isn't going to change positions, you can make them ignore walkbehinds (by settings their .IgnoreWalkbehinds  to true).

The best way to approach this really depends on whether there're going to be objects there, too, whether the other character's are moving, etc.

If you give us more info, we can provide you with the best solution.

SMF spam blocked by CleanTalk