forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Puyover



Joined: 14 Apr 2008
Posts: 1

PostPosted: Mon Apr 14, 2008 2:41 am    Post subject: [SOLVED]Problem with Analog Stick and 8 directions :S Reply with quote

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:

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

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



EDIT: The problem was in the main loop, but truely I don't know how I've solved xD
Cheers!!
Back to top
View user's profile Send private message
a_noob



Joined: 17 Sep 2006
Posts: 97
Location: _start: jr 0xDEADBEEF

PostPosted: Wed Apr 16, 2008 3:32 pm    Post subject: Reply with quote

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:
.øOº'ºOø.
'ºOo.oOº'
Back to top
View user's profile Send private message AIM Address MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Apr 16, 2008 4:50 pm    Post subject: Reply with quote

He means this thread: http://www.psp-programming.com/forums/index.php?topic=2262.0

Man! That brings back memories... I contributed to that thread. :)
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group