The z-coordinate

From SCI Wiki
Jump to navigationJump to search

Chapter 6 - z-coordinate

All the classes that extend from Feature (PV, View, Prop, Act, Ego) have a z coordinate. This can be used to 'elevate' the object above or below the ground. The same could be accomplished with the y coordinate, but change this will affect the motion classes applied to the actor, and it will also change the priority of the actor.

Walking on elevated ground.

Suppose we have a section of elevated ground on which the ego can walk. We could draw a particular control color over this elevated ground in the pic.

Supposing ctlGREEN was the control color:

Code:
   (method (doit)
       (super:doit())
       
       (if (& (send gEgo:onControl()) ctlGREEN)
           (send gEgo:z(3)) // Ego is elevated by 3 pixels.
       )(else
           (send gEgo:z(0)) // Ego is back to normal
       )
   )

Incidentally, changing the z-coordinate has the same effect as changing the Y coordinate of a view's 'placement' (these are the X and Y coordinates of the view in SCI Studio's view editor). However, the placement of a view is fixed, while the z-coordinate can be changed in code.

 

< Previous: Chapter 5 - Jumping Bug Next: Chapter 7 - Memory Management (advanced) >