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 

Image Movement Help

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



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 2:59 am    Post subject: Image Movement Help Reply with quote

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
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Sep 21, 2008 3:04 am    Post subject: Reply with quote

place this after you open your while loop:
Code:
sceCtrlPeekBufferPositive(&pad, 1);

_________________

Upgrade your PSP
Back to top
View user's profile Send private message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 3:16 am    Post subject: Reply with quote

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
View user's profile Send private message
hibbyware



Joined: 28 Mar 2007
Posts: 78

PostPosted: Sun Sep 21, 2008 3:27 am    Post subject: Reply with quote

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
View user's profile Send private message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 5:17 am    Post subject: Reply with quote

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
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Sep 21, 2008 5:26 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Sep 21, 2008 5:55 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 6:41 am    Post subject: Reply with quote

So, what would I need to do instead pspDebugScreenClear(); ?
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Sep 21, 2008 7:05 am    Post subject: Reply with quote

You seem to be using graphics.c. Look through it - there's lots of stuff in there.
Back to top
View user's profile Send private message AIM Address
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 7:23 am    Post subject: Reply with quote

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
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Sep 21, 2008 7:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Sun Sep 21, 2008 7:38 am    Post subject: Reply with quote

And be sure to check for warnings in the cygwin or command prompt. it could help lead to a solution.
Back to top
View user's profile Send private message AIM Address
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 7:59 am    Post subject: Reply with quote

Yeah, I was just now about to change that to 0xFFFFFFFF
I was just using it as an example.
Back to top
View user's profile Send private message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 8:02 am    Post subject: Reply with quote

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
View user's profile Send private message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 8:10 am    Post subject: Reply with quote

Nvm. I got it!



Oh.. um. triple post? Sorry.
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Sun Sep 21, 2008 8:37 am    Post subject: Reply with quote

Please read the rules before posting so many times. Its ok to edit the post you made.
Back to top
View user's profile Send private message AIM Address
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Sep 21, 2008 8:53 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Sep 21, 2008 1:15 pm    Post subject: Reply with quote

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
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