Help Programming

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

Mar 4, 2008

Help Programming by mat88 at 2:20 AM (1,102 Views / 0 Likes) 10 replies

  1. mat88
    OP

    Member mat88 GBAtemp Regular

    Joined:
    Jun 21, 2003
    Messages:
    169
    Location:
    Montreal
    Country:
    Canada
    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

    Member CockroachMan Scribbling around GBATemp's kitchen.

    Joined:
    Jan 14, 2006
    Messages:
    3,889
    Location:
    Brazil
    Country:
    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

    Member mat88 GBAtemp Regular

    Joined:
    Jun 21, 2003
    Messages:
    169
    Location:
    Montreal
    Country:
    Canada
    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

    Member CockroachMan Scribbling around GBATemp's kitchen.

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

    Member mat88 GBAtemp Regular

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

    Member mat88 GBAtemp Regular

    Joined:
    Jun 21, 2003
    Messages:
    169
    Location:
    Montreal
    Country:
    Canada
    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

    Member CockroachMan Scribbling around GBATemp's kitchen.

    Joined:
    Jan 14, 2006
    Messages:
    3,889
    Location:
    Brazil
    Country:
    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

    Member Linkiboy GBAtemp Testing Area

    Joined:
    May 14, 2006
    Messages:
    4,888
    Country:
    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

    Member CockroachMan Scribbling around GBATemp's kitchen.

    Joined:
    Jan 14, 2006
    Messages:
    3,889
    Location:
    Brazil
    Country:
    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

    Member mat88 GBAtemp Regular

    Joined:
    Jun 21, 2003
    Messages:
    169
    Location:
    Montreal
    Country:
    Canada
    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

    Member CockroachMan Scribbling around GBATemp's kitchen.

    Joined:
    Jan 14, 2006
    Messages:
    3,889
    Location:
    Brazil
    Country:
    Brazil
    Never used PAlib.. can't help you with that :/
     

Share This Page