libnds help: moving sprite across both screens

Discussion in 'NDS - Emulation and Homebrew' started by Psyfira, Mar 16, 2010.

  1. Psyfira
    OP

    Psyfira Credit: 0ml. Insert tea to continue

    Member
    3,887
    15
    Dec 31, 2003
    England
    Bit of a technical question this but worth a shot...

    I've finished Patater's tutorial and realised I know enough to build something simple, like a small game of pong. But I've got myself a bit stuck trying to figure out how to get the ball to move across both screens.

    libnds uses a separate space in memory for sprites for each screen. So one solution would be to create the sprite twice, once in each memory bank, and toggle the visibility depending on which screen the sprite is on. But this strikes me as somewhat inefficient, with a single sprite taking up double the amount of memory it would theoretically need.

    Is this the correct way to do it, or is there a better solution than creating everything twice? I know I could just build it that way and forget about it but part of me just won't let the feeling that I'm missing something go...
     
  2. jeremy506

    jeremy506 Some dude.

    Member
    587
    0
    Oct 26, 2009
    Nauru
    America
    Just check weather the sprite is below 0, and make a boolean. If it is below 0, say... "screen" = true.
    Then if it is true create a new sprite on the top screen with the same X position, but the Y at 192.