Dragonfly Q&A

Adding Views has completely messed up drawing

0 like 0 dislike
After adding the implementation for Views, I tried running my collision test from Project 2b. What ended up happening was that, even though I set the boundaries of the world manager view and bounds to 80 x 24, the view was only being drawn as a 40 x 12 square. Also, I created a series of objects in that test program. For some reason, the first one is never drawn, no matter what it is. This has greatly frustrated me, as I have written down the pseudocode exactly as the book described, and I can't get it to function properly. If anyone has insight on this, help is greatly appreciated.
asked Sep 29, 2014 by cgporell

1 Answer

0 like 0 dislike
I don't have immediate insights, but I can suggest an approach that could help find the problem:

First, assuming you are using the boxIntersectsBox() function to check if the view intersects the object, make sure to debug your function carefully.  Test it with a bunch of different boxes - overlapping, containing, non-overlapping - to be sure it works.  In particular, test it with boxes that don't work in your example above - with a 80x24 box and the object.

Second, once that is tested, if the problem still persists, check that you are not doing something odd with the worldToView() translation.  Write unit tests that do the exact examples in Figure 4.7 (p. 152), for example, and see if the resulting values are correct.

Third, assuming that all checks out, make your functional test (the one you describe above) as small as possible and still illustrate the problem.  It sounds like you have two problems, actually - one object that does not draw, and a view that seems to be 40x12.  Try to get two functional tests, one for each problem.  Have each as small as possible - with as few objects as possible.  The, add log messages to print out values that are being displayed in the graphics manager, before and after view to world translation, and in the world manager right before drawing.  Carefully looking through these will hopefully show you the problem.
answered Sep 29, 2014 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.