Help Programming

Discussion in 'The Edge of the Forum' started by mat88, Mar 4, 2008.

  1. mat88
    OP

    mat88 GBAtemp Regular

    Member
    169
    0
    Jun 21, 2003
    Canada
    Montreal
    Hi,
    I'm trying to program the scrolling of a background (NDS) and it's working. The only problem is, when I continu to press on the left et we are at the limit, the background stop (ok) but the value of scrolling continu to decrease (not ok). I tryed put a condition if to bloc the value to zero but it didn't work.

    there is a part of the code [​IMG]
    CODEÂÂÂÂscrollx += (Pad.Held.Right - Pad.Held.Left);
    ÂÂÂÂscrolly += (Pad.Held.Down - Pad.Held.Up);
    ÂÂÂÂif(scrollx
     
  2. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    3,889
    5
    Jan 14, 2006
    Brazil
    Brazil
    How do you know that the values are decreasing? Are you using something to print the values for you?

    Anyway.. are you using unsigned variables? That can lead to overflow and keep your variables always positive..
     
  3. mat88
    OP

    mat88 GBAtemp Regular

    Member
    169
    0
    Jun 21, 2003
    Canada
    Montreal
    I use u32 scrolly, scrollx
    Yes I have a debug function that print it.

    Code:
    ÂÂÂÂPA_InitText(0,2);
    ÂÂÂÂPA_OutputText(0,1,6,"Position: (x=%d;y=%d)",scrollx,scrolly);
    Between I use PAlib to code on DS
     
  4. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    3,889
    5
    Jan 14, 2006
    Brazil
    Brazil
    Here's your problem.. those are unsigned numbers.. they are only positives.. try using int instead of u32
     
  5. mat88
    OP

    mat88 GBAtemp Regular

    Member
    169
    0
    Jun 21, 2003
    Canada
    Montreal
    oh thanx!! It's working fine whit int instead of unsigned [​IMG] (what a newbie i'm I!)
     
  6. mat88
    OP

    mat88 GBAtemp Regular

    Member
    169
    0
    Jun 21, 2003
    Canada
    Montreal
    I have an other problem [​IMG]
    I need help with a table of string
    CODE#include or? #include
    int main(int argc, char ** argv)
    {
    string city[10]={"Ville départ","Port1"}; or? std::string city[10]={"Ville départ","Port1"};
    }
    I'm using Devkitpro whit PAlib (using the build.exe)
     
  7. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    3,889
    5
    Jan 14, 2006
    Brazil
    Brazil
    You can use

    CODE#include
    using namespace std;
    int main(int argc, char ** argv)
    {
    string city[10]={"Ville départ","Port1"};
    }

    or

    CODE#include
    int main(int argc, char ** argv)
    {
    std::string city[10]={"Ville départ","Port1"};
    }

    same result..
     
  8. Linkiboy

    Linkiboy GBAtemp Testing Area

    Member
    4,888
    37
    May 14, 2006
    United States
    And while we're on discussion of PAlib, how would I go about assigning array values to sprites? like if I have something like arrayx[10] and araayy[7], and I have an actual grid with sprites on screen.
     
  9. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    3,889
    5
    Jan 14, 2006
    Brazil
    Brazil
    I don't understand your problem linki [​IMG]

    Wouldn't be easier to use arrayxy[10][7] instead of arrayx[10] and arrayy[7] ?
     
  10. mat88
    OP

    mat88 GBAtemp Regular

    Member
    169
    0
    Jun 21, 2003
    Canada
    Montreal
    thank you, it's working now!

    but my next problem is coming.
    Is it possible to have 2 PA_InitText? (in different function)

    like
    Code:
    function1()
    {PA_InitText(0,2);}
    function2()
    {PA_InitText(1,2);}
    
    int main()
    {
    while(1)
    {
    function1();
    function2();
    }
    }
     
  11. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    3,889
    5
    Jan 14, 2006
    Brazil
    Brazil
    Never used PAlib.. can't help you with that :/