![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
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;
}
|
|
|
|
|
|
|
#7 |
![]() ![]() Developer
|
^^ 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 );
}
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#9 |
|
No longer a community member.
|
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. |
|
|
|
|
|
#10 |
|
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 |
|
|
|
|
|
|
#11 |
![]() ![]() Developer
|
@ 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 |
|
|
|
![]() |
| Tags |
| cursor , make , place , stay |
| Thread Tools | |
|
|