Drawing in Layers


Groupwork

For Dragonfly, we’d like to provide the ability to draw in layers - for the game programmer to control order of Objects to be drawn. i.e., Draw these Objects first (in the background), then these objects second (on top), …

Assume this is called altitude.

  1. What code needs to be added to Dragonfly to keep track of an Object’s altitude?

  2. Consider the below code:

    // Draw world bottom up, from 0 to MAX_ALTITUDE.
    WorldManager::draw() {

      ObjectListIterator li(&m_updates);

      while (!li.isDone()) {

        Object *p_temp_o = li.currentObj();

        p_temp_o -> draw();

        li.next();
      }

    }

This code doesn’t do what we want. Why not? Fix it, providing code that does.


Hand-in

Have ONE person from each group submit the group’s answers:

https://wpi.qualtrics.com/jfe/form/SV_6P5PdnqkovHPuHY

Make sure to include the names of all group members.

Happy layer-ing!

– Mark