Menu

#48 Parallax functionality problems

open-out-of-date
C Code (26)
5
2007-07-13
2005-09-09
No

If a map's parallax layer is larger than about 1/2 (or
whatever the map's "pmult / pdiv" is set to) of the map's
width or height, it gets chopped off.

One example of this is in cave3b.map. The background
in the game is visible until you get to the right-most
section of the map, where, although there are tiles there
(as shown in the Map Editor), nothing but black is
shown.

This happens in draw.c for draw_backlayer(),
draw_midlayer(), and possibly draw_forelayer().

The code is as follows for when the map is parallaxed:

for (dy = 0; dy < 16; dy++) {
/* Parallax problem here #1 */
if (ytc + dy >= v_y1 && ytc + dy <= v_y2) {
for (dx = 0; dx < 21; dx++) {
/* Parallax problem here #2 */
if (xtc + dx >= v_x1 && xtc + dx <= v_x2) {

If the code above were changed to the following:

for (dy = 0; dy < 16; dy++) {
if (ytc + dy >= v_y1) {
for (dx = 0; dx < 21; dx++) {
if (xtc + dx >= v_x1) {

Then the Parallax works correcly (isn't cut off), but the
code is broken when you go into town and warp to a
portion of the map (like when you walk through a door)
where set_view() specifies the right- and bottom-
boundaries that the player should see. So basically,
any rooms on the map to the right of the player's
position are visible when the player walks around.

Discussion

  • Anonymous

    Anonymous - 2006-02-21
    • assigned_to: nobody --> peterhull90
     
  • Anonymous

    Anonymous - 2006-02-21

    Logged In: YES
    user_id=295085

    TT, how about this patch
    Index: src/draw.c
    ===================================================================
    RCS file: /cvsroot/kqlives/KQ/src/draw.c,v
    retrieving revision 1.38
    diff -u -r1.38 draw.c
    --- src/draw.c 21 Dec 2005 21:51:04 -0000 1.38
    +++ src/draw.c 21 Feb 2006 19:40:12 -0000
    @@ -501,10 +501,10 @@
    dy = vy * g_map.pmult / g_map.pdiv;
    xtc = dx >> 4;
    ytc = dy >> 4;
    - v_x1 = view_x1 * g_map.pmult / g_map.pdiv;
    - v_y1 = view_y1 * g_map.pmult / g_map.pdiv;
    - v_x2 = view_x2 * g_map.pmult / g_map.pdiv;
    - v_y2 = view_y2 * g_map.pmult / g_map.pdiv;
    + v_x1 = view_x1;
    + v_y1 = view_y1;
    + v_x2 = view_x2;
    + v_y2 = view_y2;
    }
    xofs = 16 - (dx & 15);
    yofs = 16 - (dy & 15);

    Can you tell me an example of the second problem (the
    set_view one)?

    Pete

     
  • Anonymous

    Anonymous - 2007-07-11

    Logged In: YES
    user_id=295085
    Originator: NO

    The code no longer looks like this. I think it was fixed in a different way later.

     
  • Anonymous

    Anonymous - 2007-07-11
    • status: open --> pending-out-of-date
     
  • Team Terradactyl

    Logged In: YES
    user_id=651707
    Originator: YES

    The code no longer looks like this, but the problem persists. We may need to see why this is still happening, and what we need to do to correct it. It's only visible on a few maps, but I think it would be best if the entire engine was corrected in case we make more maps for the unfinished levels/worlds/villages and come across this some more.

     
  • Team Terradactyl

    • status: pending-out-of-date --> open-out-of-date
     

Log in to post a comment.