Show 40 post(s) from this thread on one page
Page 14 of 340 First ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 64 114 ... Last
• 06-27-2006, 04:26 PM
SG57
You could do something like that. I have a little easier way.
Code:

```int CollisionDetection(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) {   if ((y2 >= y1 && y1 + h1 >= y2) || (y2 + h2 >= y1 && y1 + h1 >= y2 + h2) || (y1 >= y2 && y2 + h2 >= y1) || (y1 + h1 >= y2 && y2 + h2 >= y1 + h1))           {            if (x2 >= x1 && x1 + w1 >= x2) {                return true;                }       if (x2 + w2 >= x1 && x1 + w1 >= x2 + w2) {                  return true;                  }       if (x1 >= x2 && x2 + w2 >= x1) {                  return true;                  }       if (x1 + w1 >= x2 && x2 + w2 >= x1 + w1) {                  return true;                  }     } return false; } typedef struct testing { int x; int y; int w; int h; } pics; struct pics Pic[2]; int main() { Pic[0] = { 20,20,30,229 }; Pic[1] = { 10,200,200,60 }; int speed = 5; Image* pic1, pic2; yellow = loadImage("yourimage.png"); blue = loadImage("you2ndimage.png"); while(1) {     blitAlphaImageToScreen(0,0,Pic[0].w,Pic[0].h,yellow,Pic[0].x,Pic[0].y-=speed);     blitAlphaImageToScreen(0,0,Pic[1].w,Pic[1].h,blue,Pic[1].x,Pic[1].y); Pic[0].y+=speed; if( (CollisionDetect ( Pic[0].x, Pic[0].y, Pic[0].w, Pic[0].h,                               Pic[1].x, Pic[1].y, Pic[1].w, Pic[1].h )) == 1)     {                     Pic[0].h -=speed;       } else if(Pic[1].h<0) Pic[1].h=0; } return 0; }```
This is a COMPLETE program that will blit the 2 images, the yellow bar and blue bar, yellow first to hide behind it a little, and start moving the yellow bar downwards, until hitting the blue rectangle, then it will keep moving,but shorten the height of the yellow bar as it collides.
• 06-27-2006, 05:14 PM
Waterbottle
Quote:

Originally Posted by SG57
You could do something like that. I have a little easier way.
*snip*

This is a COMPLETE program that will blit the 2 images, the yellow bar and blue bar, yellow first to hide behind it a little, and start moving the yellow bar downwards, until hitting the blue rectangle, then it will keep moving,but shorten the height of the yellow bar as it collides.

does it resize or crop the image? cause I need it to crop it
• 06-28-2006, 07:54 PM
PSPduh
I am having trouble making a game compile. :(
Quote:

Originally Posted by Cygwin..Mean...
FattyMcFat@D428G461 ~/projects
\$ make kxploit
make: *** No rule to make target `main.o', needed by `hello.elf'. Stop.

The makefile is:
Code:

```TARGET = hello OBJS = main.o graphics.o framebuffer.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = \$(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = \$(CFLAGS) LIBDIR = LIBS = -lpspgu -lpng -lz -lm LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Hello PSPSDK=\$(shell psp-config --pspsdk-path) include \$(PSPSDK)/lib/build.mak```
I do have framebuffer.c, framebuffer.h, graphics.c, and graphics.h all in the same dir with my main.c and my makefile.
This was just a little test to see if I could randomly blit an image...
--PSPduh
• 06-28-2006, 08:12 PM
soccerPMN
the target in your makefile needs to be main I think, but i'm not positive
• 06-28-2006, 08:35 PM
PSPduh
Quote:

Originally Posted by soccerPMN
the target in your makefile needs to be main I think, but i'm not positive

I changed Target = Hello to Target = main, and:
Quote:

FattyMcFat@D428G461 ~/projects
\$ make kxploit
make: *** No rule to make target `main.o', needed by `main.elf'. Stop.
And I got that makefile from Yeldarb's 4th tut too.
--PSPduh
• 06-28-2006, 09:31 PM
Devun_06
is there a OGG player lib like the one for MP3 that Smerity made a tutorial on... I thought I saw one in a forum topic here once, but I can't find it. :(
• 06-29-2006, 01:05 PM
Insert_Witty_Name
Quote:

Originally Posted by Devun_06
is there a OGG player lib like the one for MP3 that Smerity made a tutorial on... I thought I saw one in a forum topic here once, but I can't find it. :(

http://www.psp-programming.com/dev-f...opic.php?t=494
• 06-29-2006, 01:08 PM
hexecal
Is there any reason why I get a compiling error after completing the mp3 tutorial? I even tried copy/pasting, I still get errors!
• 06-29-2006, 01:12 PM
Ninjax1
I really need to know of a site that teaches you how to create a 2d side scroller.
• 06-29-2006, 02:32 PM
KunoNoOni
this is going to sound like a really noobish question... (you have been warned :))

say I have a file test.c that dealt with one aspect of my program and I wanted to add it to my main.c, would include "test.c" work? and do I need to have a .h file for it?
• 06-29-2006, 02:51 PM
SodR
Quote:

Originally Posted by KunoNoOni
this is going to sound like a really noobish question... (you have been warned :))

say I have a file test.c that dealt with one aspect of my program and I wanted to add it to my main.c, would include "test.c" work? and do I need to have a .h file for it?

Let's say you have created a function like this:
Code:

```void Function() { printf("hello"); }```
and placed it in function.c. Then just create a .h file called function.h that should contain only
Code:

`void Function();`
Then just include function.h in your main.c file. And don't forget to add function.o to your makefile.
• 06-29-2006, 04:03 PM
Waterbottle
I have a function inside main(){} called menu(). now I want to declare it so I can go to it eventhough it's under the thoigh that points to it (menu();). so then I thought I should add int menu(); out side of all functions. but then I get and undefined reference to menu error.

so I thought that maybe I should have it inside the main() function since the function it self is inside main() but then I get:

error: static declaration of 'menu' follows non-static declaration
error: previous declaration of 'menu' was here

how should I do this?
• 06-29-2006, 04:51 PM
Insert_Witty_Name
Quote:

Originally Posted by hexecal
Is there any reason why I get a compiling error after completing the mp3 tutorial? I even tried copy/pasting, I still get errors!

List the actual errors mate and we'll see if we can help you.
• 06-29-2006, 04:54 PM
Insert_Witty_Name
Quote:

Originally Posted by waterbottle
I have a function inside main(){} called menu(). now I want to declare it so I can go to it eventhough it's under the thoigh that points to it (menu();). so then I thought I should add int menu(); out side of all functions. but then I get and undefined reference to menu error.

so I thought that maybe I should have it inside the main() function since the function it self is inside main() but then I get:

error: static declaration of 'menu' follows non-static declaration
error: previous declaration of 'menu' was here

how should I do this?

That's pretty much gibberish mate. I would recommend an English lesson before a C lesson.

I think you are trying to declare a function within another function (which you cannot do), you need to have all your functions separate. Don't forget main is a function too!
• 06-29-2006, 05:09 PM
Waterbottle
Quote:

Originally Posted by Insomniac197
That's pretty much gibberish mate. I would recommend an English lesson before a C lesson.

I think you are trying to declare a function within another function (which you cannot do), you need to have all your functions separate. Don't forget main is a function too!

yes, that's what I'm trying do.
The function inside main() works though (aslong as menu(); is after the menu() function), just that I can't get the prototype to work.
So you're sure that I can't use prototypes for functions inside functions? (would be alot simpler becouse I have alot of images and I want all to load at the start and this way I don't have to write all the Image variables into the variable section of the function).

(and sorry for not being great at english :) )
• 06-29-2006, 09:33 PM
KunoNoOni
is there any other function besides printTexttoImage that will allow you to print on an image with a variable? I have a counter that I want to watch inc/dec but the screen I want to print it on has a full screen image.
• 06-29-2006, 11:07 PM
Insert_Witty_Name
Quote:

Originally Posted by waterbottle
yes, that's what I'm trying do.
The function inside main() works though (aslong as menu(); is after the menu() function), just that I can't get the prototype to work.
So you're sure that I can't use prototypes for functions inside functions? (would be alot simpler becouse I have alot of images and I want all to load at the start and this way I don't have to write all the Image variables into the variable section of the function).

(and sorry for not being great at english :) )

Showing us the code for this would help us no end, care to post it?
• 06-29-2006, 11:10 PM
Insert_Witty_Name
Quote:

Originally Posted by KunoNoOni
is there any other function besides printTexttoImage that will allow you to print on an image with a variable? I have a counter that I want to watch inc/dec but the screen I want to print it on has a full screen image.

Doesn't matter what's underneath the text - it will still be shown. When you blit stuff to the screen it is 'layered', so just put the text after the image. ie.

blitAlphaImageToScreen
printTextScreen (or whatever the function is called)

The text will be printed on top of the image.
• 06-30-2006, 12:29 AM
KunoNoOni
but I can't use a variable with that function. I want to print out something like "counter is now: " and then print out the variable holding the counter. Using printf it would be :

Code:

`printf("Counter is now: %d",x);`
hmm... if I did use printf would the text be seen or covered by the image? even if I put it after the blit?

EDIT: umm, I think thats kinda what you said... ;)

EDIT2: ok, printf does work if its the last thin before the flipscreen();
• 06-30-2006, 10:27 AM
Waterbottle
Quote:

Originally Posted by Insomniac197
Showing us the code for this would help us no end, care to post it?

so this works, it goes into menu becouse it calls to menu after menu has been declared.
but if I added menu(); right after main() it wouldn't work becouse menu() hasn't been declared, I need help decalring it (having a prototype for it)
Code:

```int main() {                   int menu() {                       menubuttonsY = -200;                       while(menubuttonsY < 80) {                                           blit(0,0,480,272,background,0,0);                                           blit(0,0,228,27,menutext[4],20,menubuttonsY);                                               blit(0,0,279,27,menutext[1],20,menubuttonsY+40);                                               blit(0,0,207,27,menutext[2],20,menubuttonsY+80);                                               blit(0,0,86,27,menutext[3],20,menubuttonsY+120);                                               blit(0,0,118,10,menutext[8],10 ,255);                                               flipScreen();                                               menubuttonsY += 10;                                               }                       menubuttonsX = 20;                       menubuttonsY = 272;                   while(1) {                               //blit menu images                               blit(0,0,480,272,background,0,0);                               if(menuselected == 0){                                               blit(0,0,228,27,menutext[4],20,80);                                               blit(0,0,279,27,menutext[1],20,120);                                               blit(0,0,207,27,menutext[2],20,160);                                               blit(0,0,86,27,menutext[3],20,200);                               }                               if(menuselected == 1){                                               blit(0,0,228,27,menutext[0],20,80);                                               blit(0,0,279,27,menutext[5],20,120);                                               blit(0,0,207,27,menutext[2],20,160);                                               blit(0,0,86,27,menutext[3],20,200);                               }                               if(menuselected == 2){                                               blit(0,0,228,27,menutext[0],20,80);                                               blit(0,0,279,27,menutext[1],20,120);                                               blit(0,0,207,27,menutext[6],20,160);                                               blit(0,0,86,27,menutext[3],20,200);                               }                               if(menuselected == 3){                                               blit(0,0,228,27,menutext[0],20,80);                                               blit(0,0,279,27,menutext[1],20,120);                                               blit(0,0,207,27,menutext[2],20,160);                                               blit(0,0,86,27,menutext[7],20,200);                               }                               blit(0,0,118,10,menutext[8],10 ,255);                               flipScreen();                               //slow down menu movment                                                             readbuff(&pad, 1);                               if(checkD == 1) { if(pad.Buttons & PSP_CTRL_DOWN) { } else { checkD = 0; } }                               if(checkD == 0) { if(pad.Buttons & PSP_CTRL_DOWN) {                                               if(menuselected < 3) {                                                               menuselected++;                                               }                                               checkD = 1;                               }                               }                               if(checkU == 1) { if(pad.Buttons & PSP_CTRL_UP) { } else { checkU = 0; } }                               if(checkU == 0) { if(pad.Buttons & PSP_CTRL_UP) {                                               if(menuselected > 0) {                                                               menuselected--;                                               }                                               checkU = 1;                               }                               }                               if(checkX == 1) { if(pad.Buttons & PSP_CTRL_CROSS) { } else { checkX = 0; } }                               if(checkX == 0) { if(pad.Buttons & PSP_CTRL_CROSS) {                                         checkX = 1;                                               if(menuselected == 0) {                                         break;                                                               }//menuselected == 0                                               if(menuselected == 3) {                                                               sceKernelExitGame();                                               }                                               checkX = 1;                                               }                               }                   }//while(1)                   return 0;           }//menu()           while(1) {           menu();                 }                                     return 0;           }```
• 06-30-2006, 11:54 AM
Insert_Witty_Name
That code looks horrible mate - no offense.
I suggest you check out my game tutorial, which includes using a simple menu.

http://www.psp-programming.com/dev-f...opic.php?t=359
• 06-30-2006, 12:49 PM
KunoNoOni
Is there any way to make the buttons and dpad only accept input if the button is pressed, not if its held down? In LUA I'd do this:

Code:

`if pad:left() and oldpad:left() ~= pad:left() then`
I've tried several different methods but none are working... :Argh:

• 06-30-2006, 02:51 PM
Insert_Witty_Name
Quote:

Originally Posted by KunoNoOni

• 06-30-2006, 02:59 PM
Waterbottle
Quote:

Originally Posted by Insomniac197
That code looks horrible mate - no offense.
I suggest you check out my game tutorial, which includes using a simple menu.

http://www.psp-programming.com/dev-f...opic.php?t=359

mmh, I guess I'll rewrite the menu :p
• 06-30-2006, 05:39 PM
ttotto
Does anyone know how to create a timer in c like the one in lua wich can create new timers, stop timer,start timer, reset timer, and get the current time of a timer?
• 06-30-2006, 05:53 PM
Waterbottle
Quote:

Originally Posted by ttotto
Does anyone know how to create a timer in c like the one in lua wich can create new timers, stop timer,start timer, reset timer, and get the current time of a timer?

I don't know about any timrer actions (searched once and didn't find any posts about any).
but if you only need a timer that counts seconds you can use the psp's time to make it. like for example
starttimer = time(NULL);
while(1) {
timer = (starttimer - time(NULL)) * -1:
}

which then would count upwards 1 second at a time
• 06-30-2006, 06:31 PM
ttotto
that could work but how do u get the time from the psp?
• 06-30-2006, 06:33 PM
Waterbottle
Quote:

Originally Posted by ttotto
that could work but how do u get the time from the psp?

the time is
time(NULL);

so timer = time(NULL);
sets timer to the psp's time
• 06-30-2006, 06:44 PM
ttotto
o ok thanx :Punk: :) . does anyone also no how to print integers to the screen using PrintTextScreen?
• 06-30-2006, 06:54 PM
Waterbottle
Quote:

Originally Posted by ttotto
o ok thanx :Punk: :) . does anyone also no how to print integers to the screen using PrintTextScreen?

"%i", intergername

example:
sprintf(filler, "%i", timer);
printTextScreen(0, 0, filler, yellow);
Show 40 post(s) from this thread on one page
Page 14 of 340 First ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 64 114 ... Last