adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] More on z-values (was: first real map gfx)


From: Kai Sterker
Subject: [Adonthell-devel] More on z-values (was: first real map gfx)
Date: Fri, 15 Mar 2002 00:22:36 +0100

On Thu, 14 Mar 2002 22:08:04 +0100 Kai Sterker wrote:

> Hm. Maybe that's where height levels would be useful. I am not sure
> that the idea I have in mind will work, but perhaps it gives you some
> inspiration.
> 
> Basically, each (flat?) object would have a height level, i.e. how
> many pixels it is above ground.
> 
> For example, a flat object (A) with a level of 10 would cover the 10
> bottom pixels of object B with level 0. If object A is translucent,
> we'll have the desired effect. For the mapengine that means that it
> needs to draw the bottom region of B, then draw the complete A and
> finally the upper region of B. Don't know if that can be easily done.
> 
> That way you could also have grass that goes up to the character's
> knees which would still look good when walking vertically. All you
> need is to set its level (or z value) a bit higher than the ground.

The more I think about it, the more useful the z value gets. Actually,
there would be two distinct z values. The distance of an object from the
ground (let's call it 'z') and an object's height, i.e. how tall it is.
(let's call that 'level').

There are a couple of applications for the two values


1. Walkability tests

If we want our character to jump over obstacles or climb up somewhere,
we need to know how high he is above the ground (z value) and how tall
the obstacle is (it's combined z value and level).

If we want birds to fly around, we simply can give them a bigger z-value
than the surrounding scenerie's level and they will no longer be
restricted by objects that block characters walking on the ground.


2. The character's shadow. 

The z value of a character defines how high he is above ground, and
therefore contains all information needed to draw his shadow at the
right position. 


3. Walking through water and bridges

For the water, we would give the surface a positive z value. While it's
level would be 0. The character walking in the water would use the
water's level as ground. We could even tell when the character is
completely under water. That happens if the distance between the waters
level and it's z value is bigger than the character's level. (that
means, for flat object, 'level' means the ground level, whereas for
nonflat objects, level means their hight).  

Anyway, for a bridge both z value and height of the planks would be 
bigger than 0 (and certainly the same value, unless we want the player 
to sink into the planks). If the player's z value is that of the planks 
(or possibly higher), he'll be able to walk over the bridge. (I.e. he's 
drawn above the planks,) If the z value is lower than the height of the 
bridge, he can walk beneath it, i.e. he's drawn below the planks, That 
means of course that the bridge must be high enough, otherwise part of 
the body will stick through the planks and we get the walking through 
water effect (you could also say a clipping error).

We could prevent the player from walking under low bridges by marking
the rail nonwalkable. The nonwalkable area would of course only cover
the distance between the rail's z value and it's level. So if the player
was on the bridge, he could still jump over the rail and fall down (if
he can jump high enough). And if he is small enough he can still walk
under the bridge.

All in all, the z value means an additional offset in y direction. That
means, a bird flying 240px above ground, would appear in the center of
the screen although it currently flies around the bottom line.


Apart from z-value and height we could define different ground levels.
Say one level covers 30px. That means an object at level 3 is 90px above
ground. An object with level -3 is 90px below ground. The z-value and
height of an object will always be relative to it's ground level. And
while the z-value and height are a property of the object, the level is
part of the map, so the same object can be placed at different levels. 

For example we could have the following terrain (viewed from the front)

  Level          ________  
    3           |
    2           |
    1   ________|

If a character comes from the right, his z-value would be 90, the same
as the ground's height. Once he walks over the edge, the engine would
notice that there is no ground under his feet, and he would fall down.
The character's new z value is the level of the ground: 0.

etc. etc.

There needs to be more thinking done, but that should give a good
overview of what might be possible.

Kai 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]