Original Post
well, I'm working on a 2d top-down game for my cs class, and am currently setting up the terrain. However, I've run into a problem. To spare you a confusing explanation, I've taken the liberty of using ASCII to draw a diagram. :
,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,,,,
,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,,,,</font><font color = "orange">
""""""""""""""""""""""
""""""""""""""""""""""
" """"""" "
""""""" </font><font color = "cyan">* *</font><font color = "orange"> """"""""""
</font><font color = "white">,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,,,,
,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,,,,
,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,
,,,,,</font><font color = "yellow">"</font><font color = "gray">||</font><font color = "red">^</font><font color = "gray">||||</font><font color = "yellow">"</font><font color = "white">,,,,,,,,
</font><font color = "orange">"""""""</font><font color = "red">/_\</font><font color = "orange">"""""""""
"""""""</font><font color = "cyan">* *</font><font color = "orange">"""""""""
" """""" "
""""""" """""""""
</font><font color = "white">,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,, ,,,,,"|||||||",,,,,
,,,,,</font><font color = "yellow">"</font><font color = "gray">|||||||</font><font color = "yellow">"</font><font color = "white">,,,,,
The obvious problem is determining when a) the vehicle is beneath the bridge/object - the vehicle drawn first, then the bridge, and when it is it is over it (i.e. flying) - the bridge drawn first, vehicle last. The best I could think of was to make an ordered list of objects to draw (sorted by [y] value - those past a certain [y] are simply not drawn, but are included because collisions have to be checked for) to make it more efficient and to keep the drawing centralized. I'm using java with swing [straight up], so I need to minimize the drawing calls. Then use two [for] loops, checking for collisions and then switching the position of the two objects if one needs to be infront. that seems a little inefficient, though, and error prone. does anyone have a better thought/idea/solution ? any help is appreciated. [Edited by - stormrunner on October 29, 2004 6:05:18 PM]