[SOLVED]Problem with Analog Stick and 8 directions :S

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Puyover
Posts: 1
Joined: Mon Apr 14, 2008 2:28 am

[SOLVED]Problem with Analog Stick and 8 directions :S

Post by Puyover »

Hi all!

Well, I've a problem with the analog stick. I have a ship and it move in 8 directions. All directions work fine , except South-West and North-West :S

Here is the code:

Code: Select all

    #ifdef _PSP_
    float moveH, moveV;
    sceCtrlPeekBufferPositive(&pad, 1);

    moveH = (float)(pad.Lx)-128.0f;
    moveV = (float)(pad.Ly)-128.0f;
    
    // North-West
    if&#40;&#40;moveH < -16.0f&#41; && &#40;moveV < -16.0f&#41;&#41; &#123;
        Ship.dstrect.y += -VEL;
        Ship.dstrect.x += -VEL;
    &#125;
    // North-East
    else if&#40;&#40;moveV < -16.0f&#41; && &#40;moveH > 16.0f&#41;&#41; &#123;
        Ship.dstrect.y += -VEL;
        Ship.dstrect.x += VEL;
    &#125;
    // South-East
    else if&#40;&#40;moveH > 16.0f&#41; && &#40;moveV > 16.0f&#41;&#41; &#123;
        Ship.dstrect.y += VEL;
        Ship.dstrect.x += VEL;
    &#125;
    // South-West
    else if&#40;&#40;moveV > 16.0f&#41; && &#40;moveH < -16.0f&#41;&#41; &#123;
        Ship.dstrect.y += VEL;
        Ship.dstrect.x += -VEL;
    &#125;
    // North
    else if&#40;moveV < -16.0f&#41; &#123;
        Ship.dstrect.y += -VEL;
    &#125;
    // East
    else if&#40;moveH > 16.0f&#41; &#123;
        Ship.dstrect.x += VEL;
    &#125;
    // West
    else if&#40;moveH < -16.0f&#41; &#123;
        Ship.dstrect.x += -VEL;
    &#125;
    // South
    else if&#40;moveV > 16.0f&#41; &#123;
        Ship.dstrect.y += VEL;
    &#125;
    #endif

EDIT: The problem was in the main loop, but truely I don't know how I've solved xD
Cheers!!
a_noob
Posts: 97
Joined: Sun Sep 17, 2006 8:33 am
Location: _start: jr 0xDEADBEEF

Post by a_noob »

You did this completely wrong the code should only be about 6 lines long and that will also include sensitivity in the analog movement. Go to psp-programming.com/forums and search for analog code or similar. I have posted it.

Code: Select all

.øOº'ºOø.
'ºOo.oOº'
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

He means this thread: http://www.psp-programming.com/forums/i ... pic=2262.0

Man! That brings back memories... I contributed to that thread. :)
Post Reply