QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

How do you make the cursor stay in its place??

This is a discussion on How do you make the cursor stay in its place?? within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Im my game I madde a cursor but everytime you let go of the ANAKOG stick it goes to the ...

Reply
 
LinkBack Thread Tools
Old 12-19-2006, 05:18 PM   #1
 
Join Date: Nov 2006
Posts: 13
Trader Feedback: 0
Default How do you make the cursor stay in its place??

Im my game I madde a cursor but everytime you let go of the ANAKOG stick it goes to the center of the screen. How do you make the cursor stay in its place??

Here is my source:
Code:
/* Windows XP!!!!!! 
*********************
*/

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "graphics.h" 
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) 
PSP_MODULE_INFO("Windows XP", 0, 1, 1); 
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
} 
    int CursorXPosition = 0;
int imagesareloaded =0;
char buffer[200];
Image* ourImage;
Image* cursor;


void load_images(){
if(imagesareloaded ==0){
sprintf(buffer, "windows/Bliss.png");
          ourImage = loadImage(buffer); 

sprintf(buffer, "cursor.PNG");
          cursor = loadImage(buffer); 

imagesareloaded =1;
}

}
int main() {



    SceCtrlData pad;

sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);


          SetupCallbacks();
          initGraphics(); 
while(1)
{
clearScreen(0);
	sceCtrlReadBufferPositive(&pad, 1);
		  
load_images();

if (!ourImage) {
                    //Image load failed
                    printf("Image load failed!\n");
          } else { 
 int x = 0;
                    int y = 0;
                    sceDisplayWaitVblankStart();
 while (x < 480) {
                              while (y < 272) { 
     blitAlphaImageToScreen(0 ,0 ,480 , 272, ourImage, x, y);
                                        y += 272;
                              } 
 x += 480;
                              y = 0;
                    } 
          } 


if (!cursor) {
                    //Image load failed
                    printf("Image load failed!\n");
          } else { 
                    sceDisplayWaitVblankStart(); 
     blitAlphaImageToScreen(0 ,0 ,10 , 16, cursor, CursorXPosition += (pad.Lx -128) /4, pad.Ly);
 flipScreen();
}
sceKernelSleepThread();
          return 0;
}
Lil' Homebrewer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 05:26 PM   #2
No longer a community member.
 
Join Date: Jan 2006
Posts: 2
Trader Feedback: 0
Default

What's an ANAKOG?
xploren is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 05:28 PM   #3
 
Join Date: Nov 2006
Posts: 13
Trader Feedback: 0
Default

Analog Stick
Lil' Homebrewer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 05:29 PM   #4
 
Join Date: Nov 2005
Location: NoWhere . . . .
Posts: 1,266
Trader Feedback: 0
Default

come on man you know he means analog
zmathue is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 05:52 PM   #5
 
Join Date: Nov 2006
Posts: 13
Trader Feedback: 0
Default

Yah seroiusly
Lil' Homebrewer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 05:54 PM   #6
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Learn how to indent properly.
I can't read that crap.
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 06:01 PM   #7

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Default

^^ what he said also you should try and make it get the variables for the joystick before blitting them so try this:

note: i'm using the oslib

Code:
DZ = 32;
sensitivity = 30;
     if( osl_keys->analogY > DZ ){
          CursorYPosition += ( osl_keys->analogY / SENSITIVITY  );
     }
     if( osl_keys->analogY < -DZ ){
          CursorYPosition += ( osl_keys->analogY / SENSITIVITY  );
     }
     if( osl_keys->analogX > DZ ){
          CursorXPosition += ( osl_keys->analogX / SENSITIVITY  );
     }
     if( osl_keys->analogX < -DZ ){
          CursorXPosition += ( osl_keys->analogX / SENSITIVITY  );
     }
there that should do just change the osl_keys->analog to pad.buttons & PSP_CTRL_ANALOG(X or Y)(i think thats what it is normally)
__________________
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 06:03 PM   #8
 
Join Date: Nov 2006
Posts: 13
Trader Feedback: 0
Default

Ok Ty
Lil' Homebrewer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 06:04 PM   #9
No longer a community member.
 
Join Date: Oct 2006
Posts: 8
Trader Feedback: 0
Default

don't know much about C (pretty sure thats C) but basically it appears to me, that your not telling it what to do with cursor.PNG after you let go of the nub, and SceCtrlData pad returns to false, so its restarting the sequence,

you need to hard code it to leave it there. or get it to save the location, and start from that spot next time.

i don't know how to do that in C however.
JEMdev is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 06:12 PM   #10
 
Join Date: Nov 2006
Posts: 13
Trader Feedback: 0
Default

Anyone know how to do that
-= Double Post =-
you need to hard code it to leave it there. or get it to save the location, and start from that spot next time.

This one by the way

Last edited by Lil' Homebrewer; 12-19-2006 at 06:12 PM.. Reason: Automerged Doublepost
Lil' Homebrewer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-19-2006, 06:41 PM   #11

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Default

@ lil' homebrewer i surgest if your makeing a game you use the oslib as it is 30x better and easyer and allows easyier manipulation of the image go to the c/c++ help thread and search for oslib you should find it near my name
-= Double Post =-
ok here:
http://oslib.palib.info/oslib.zip

dl that and extract to wherever you dl'd it to navigate to the folder in cygwin that you extracted it to and into the install folder then do the same thing you did for the the png libaries in yelabs tuts after that you can now use the oslib also make sure the install.bat is pointering to the proper drive as i don't think it's default drive is c
__________________
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects

Last edited by slicer4ever; 12-19-2006 at 06:41 PM.. Reason: Automerged Doublepost
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
cursor , make , place , stay

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:43 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us