| View previous topic :: View next topic |
| Author |
Message |
Puyover
Joined: 14 Apr 2008 Posts: 1
|
Posted: Mon Apr 14, 2008 2:41 am Post subject: [SOLVED]Problem with Analog Stick and 8 directions :S |
|
|
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 |
|
 |
a_noob
Joined: 17 Sep 2006 Posts: 97 Location: _start: jr 0xDEADBEEF
|
Posted: Wed Apr 16, 2008 3:32 pm Post subject: |
|
|
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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
|
| Back to top |
|
 |
|