| View previous topic :: View next topic |
| Author |
Message |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 2:59 am Post subject: Image Movement Help |
|
|
| Code: | int x=120;
int y=60;
int main() {
SceCtrlData pad;
char buffer[200];
Image* ourImage;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
sprintf(buffer, "ourImage.png");
ourImage = loadImage(buffer);
sceDisplayWaitVblankStart();
while(1){
blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
if(pad.Buttons & PSP_CTRL_LEFT) {
x-=1;
}
if(pad.Buttons & PSP_CTRL_RIGHT) {
x+=1;
}
if(pad.Buttons & PSP_CTRL_UP) {
y-=1;
}
if(pad.Buttons & PSP_CTRL_DOWN) {
y+=1;
}
}
flipScreen();
sceKernelSleepThread();
return 0;
}
|
Why won't this work?
What can I do to fix it so that my image actually moves around whenever I press the buttons?
I've tried like, 50 different combinations and positions of stuff and I couldn't get it to work. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Sep 21, 2008 3:04 am Post subject: |
|
|
place this after you open your while loop:
| Code: | | sceCtrlPeekBufferPositive(&pad, 1); |
_________________
Upgrade your PSP |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 3:16 am Post subject: |
|
|
| Pirata Nervo wrote: | place this after you open your while loop:
| Code: | | sceCtrlPeekBufferPositive(&pad, 1); |
|
Oh, yeah! I can't believe I forgot that!
I don't think that's all that I need to make this work though. |
|
| Back to top |
|
 |
hibbyware
Joined: 28 Mar 2007 Posts: 78
|
Posted: Sun Sep 21, 2008 3:27 am Post subject: |
|
|
flipScreen(); will never be reached where you have placed it,
Also before your next question comes you need to also clearscreen every loop as without it your image will leave a smudgy trail, |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 5:17 am Post subject: |
|
|
| Code: | int x=120;
int y=60;
int main() {
SceCtrlData pad;
char buffer[200];
Image* ourImage;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
sprintf(buffer, "ourImage.png");
ourImage = loadImage(buffer);
sceDisplayWaitVblankStart();
while(1){
sceCtrlPeekBufferPositive(&pad, 1);
blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y);
if(pad.Buttons & PSP_CTRL_LEFT) {
x-=1;
}
if(pad.Buttons & PSP_CTRL_RIGHT) {
x+=1;
}
if(pad.Buttons & PSP_CTRL_UP) {
y-=1;
}
if(pad.Buttons & PSP_CTRL_DOWN) {
y+=1;
}
pspDebugScreenClear();
flipScreen();
}
sceKernelSleepThread();
return 0;
}
|
So, this is what I have now.
It's not working though. how would I fix it? |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Sep 21, 2008 5:26 am Post subject: |
|
|
you are clearing the screen with the debug. you can't have debug + GU working at the same time. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Sep 21, 2008 5:55 am Post subject: |
|
|
| You also need to clear the screen BEFORE you write to it, not before you flip. That simply would erase everything you'd done. :D |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 6:41 am Post subject: |
|
|
| So, what would I need to do instead pspDebugScreenClear(); ? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Sep 21, 2008 7:05 am Post subject: |
|
|
| You seem to be using graphics.c. Look through it - there's lots of stuff in there. |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 7:23 am Post subject: |
|
|
Okay, wow. I love you guys!
Okay, I checked the graphics.c and I saw a function called screenClear(color color); and I tried that and it didn't work. So I was like, oh yeah, I need to have a color in it. So I put 0x00 and it worked!
I'm soooo happy!
I've been trying to get this to work for at least a year and a half! Thanks soo much!
BTW, psp-programming is an awful forum to go onto for questions. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Sep 21, 2008 7:29 am Post subject: |
|
|
a year and a half? o.O
by the way, I recommend you to use unsigned 32 colors.
Remember the PSP little endian so the colors are in a inverted order:
0xAABBGGRR
alpha, blue, green, red _________________
Upgrade your PSP |
|
| Back to top |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sun Sep 21, 2008 7:38 am Post subject: |
|
|
| And be sure to check for warnings in the cygwin or command prompt. it could help lead to a solution. |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 7:59 am Post subject: |
|
|
Yeah, I was just now about to change that to 0xFFFFFFFF
I was just using it as an example. |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 8:02 am Post subject: |
|
|
For the time being, I want the background of the screen to be white.
What's the function for this?
I forgot. Heehee. |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 8:10 am Post subject: |
|
|
Nvm. I got it!
Oh.. um. triple post? Sorry. |
|
| Back to top |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sun Sep 21, 2008 8:37 am Post subject: |
|
|
| Please read the rules before posting so many times. Its ok to edit the post you made. |
|
| Back to top |
|
 |
^L^
Joined: 14 Jun 2008 Posts: 19
|
Posted: Sun Sep 21, 2008 8:53 am Post subject: |
|
|
Yeah, Sorryz.
And....
Actually, it didn't work.
I used this code I used right after pspDebugScreenInit(); at the beginning of my main loop.
| Code: | pspDebugScreenEnableBackColor(1);
pspDebugScreenSetBackColor(0x00000000); |
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Sep 21, 2008 1:15 pm Post subject: |
|
|
| You should be looking at examples more. There's TONS of PSP code floating around, and all of it works. Most emulators come with the source. Most games do as well. I've posted tests, apps, and game conversions here. Do more searching and looking at existing code. You don't seem prepared for this. More homework is needed. :) |
|
| Back to top |
|
 |
|