![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on need help quickly within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; OSL_IMAGE *tar; int main(int argc, char **argv) { //Initialization of the Oslib library oslInit(0); //Initialization of the graphics mode oslInitGfx(OSL_PF_8888, ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 | |||
![]() ![]() |
Quote:
Quote:
Quote:
|
|||
|
|
|
|
|
#2 |
![]() ![]() Developer
|
Post the whole code please. (How did you know that the value changed?)
__________________
[Blog] [Portfolio] [Homebrew Illuminati - Serious Homebrew Development Forums] [I want to make Homebrew FAQ] [How I broke into the Games Industry] [Programming Book List] [Programming Article List] |
|
|
|
|
|
#3 |
![]() ![]() |
i placed a print statement saying "if(load_tar==1)print blah blah on screen"...thats how i knew the value changed..i was wondering if its because the the loadimage function in the main and is called only once? when i change the value of the "int load_tar;" to "int load_tar=0;" manually it loads whatever i set the value to but when i try to pressing left or right in the game the value changes but not the image.
|
|
|
|
|
|
#5 | |
![]() ![]() Developer
|
Quote:
assuming c++ Code:
//init code
int main(int argc, char **argv){
int disp_img = 0; //similar to your load_tar
OSL_IMAGE **Images = new OSL_IMAGE[4];
Images[0] = oslLoadImageFile("tar.png ", OSL_IN_RAM, OSL_PF_5551);
Images[1] = oslLoadImageFile("tar1.png ", OSL_IN_RAM, OSL_PF_5551);
Images[2] = oslLoadImageFile("tar2.png ", OSL_IN_RAM, OSL_PF_5551);
Images[3] = oslLoadImageFile("tar3.png ", OSL_IN_RAM, OSL_PF_5551);
while(!osl_quit){
oslReadKeys();
oslStartDrawing();
oslDrawImage(Images[disp_img]);
oslEndDrawing();
if(osl_keys->held.left){
disp_img = 1;
}
//all other img changes based on button presses go here
}
//release images, and quit oslib calls
return 0;
}
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
|
#6 |
![]() ![]() Developer
|
Code:
OSL_IMAGE **Images = new OSL_IMAGE[4]; Code:
OSL_IMAGE *Images[4];
__________________
[Blog] [Portfolio] [Homebrew Illuminati - Serious Homebrew Development Forums] [I want to make Homebrew FAQ] [How I broke into the Games Industry] [Programming Book List] [Programming Article List] |
|
|
|
|
|
#7 | ||
![]() ![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#8 | |
![]() ![]() Developer
|
Quote:
anyways @kronicali, your not giving the psp any heap memory, underneath PSP_MAIN_THREAD_ATTR place: PSP_HEAP_SIZE_KB(-1024); that should solve your problem, i'll look over your code a little bit more and edit if i see anything else wrong with it that might cause a crash
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
|
#9 | ||
![]() ![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#10 |
![]() ![]() Developer
|
k, well it's working for me, here's my main.c:
Code:
//OSlib header file
#include <oslib/oslib.h>
//Necessary to create eboot
PSP_MODULE_INFO("OSLib Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
//my toolchain isn't fully updated so i have to use 20480, since you should have a fully updated toolchain using -1024 should be fine.
PSP_HEAP_SIZE_KB(20480);
//declaration of the pointers of our images
OSL_IMAGE *pic0, *tar[4];
int i=2;
int main(int argc, char **argv){
//Initialization of the Oslib library
oslInit(0);
//Initialization of the graphics mode
oslInitGfx(OSL_PF_8888, 1);
//Text
oslInitConsole();
//loads our images into memory
pic0 = oslLoadImageFile("pic0.png", OSL_IN_RAM, OSL_PF_5551);
tar[0] = oslLoadImageFile("tar.png", OSL_IN_RAM, OSL_PF_5551);
tar[1] = oslLoadImageFile("tar1.png", OSL_IN_RAM, OSL_PF_5551);
tar[2] = oslLoadImageFile("tar2.png", OSL_IN_RAM, OSL_PF_5551);
tar[3] = oslLoadImageFile("tar3.png", OSL_IN_RAM, OSL_PF_5551);
//main while loop
while (!osl_quit){
//Clear the screen
oslCls();
//To be able to draw on the screen
oslStartDrawing();
//initiate the PSP's buttons
oslReadKeys();
//draw on the screen
oslDrawImage(pic0);
oslDrawImage(tar[i]);
if(osl_keys->held.left){
i = 0;
}
if(osl_keys->held.right){
i = 1;
}
if(osl_keys->held.up){
i = 2;
}
if(osl_keys->held.down){
i = 3;
}
//Ends drawing mode
oslEndDrawing();
//Synchronizes the screen
oslSyncFrame();
}
//Terminate the program
oslEndGfx();
oslQuit();
return 0;
}
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#12 |
![]() ![]() Developer
|
i did get 1 crash before i posted because an image didn't load in properly because i forgot to change a name in the filepath so try this quickly:
Code:
//OSlib header file
#include <oslib/oslib.h>
//Necessary to create eboot
PSP_MODULE_INFO("OSLib Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
//my toolchain isn't fully updated so i have to use 20480, since you should have a fully updated toolchain using -1024 should be fine.
PSP_HEAP_SIZE_KB(20480);
//declaration of the pointers of our images
OSL_IMAGE *pic0, *tar[4];
int i=2;
int main(int argc, char **argv){
//Initialization of the Oslib library
oslInit(0);
//Initialization of the graphics mode
oslInitGfx(OSL_PF_8888, 1);
//Text
oslInitConsole();
//loads our images into memory
pic0 = oslLoadImageFile("pic0.png", OSL_IN_RAM, OSL_PF_5551);
if(pic0==NULL) oslFatalError("pic0 didn't load in");
tar[0] = oslLoadImageFile("tar.png", OSL_IN_RAM, OSL_PF_5551);
if(tar[0]==NULL) oslFatalError("pic0 didn't load in");
tar[1] = oslLoadImageFile("tar1.png", OSL_IN_RAM, OSL_PF_5551);
if(tar[1]==NULL) oslFatalError("pic0 didn't load in");
tar[2] = oslLoadImageFile("tar2.png", OSL_IN_RAM, OSL_PF_5551);
if(tar[2]==NULL) oslFatalError("pic0 didn't load in");
tar[3] = oslLoadImageFile("tar3.png", OSL_IN_RAM, OSL_PF_5551);
if(tar[3]==NULL) oslFatalError("pic0 didn't load in");
//main while loop
while (!osl_quit){
//Clear the screen
oslCls();
//To be able to draw on the screen
oslStartDrawing();
//initiate the PSP's buttons
oslReadKeys();
//draw on the screen
oslDrawImage(pic0);
oslDrawImage(tar[i]);
if(osl_keys->held.left){
i = 0;
}
if(osl_keys->held.right){
i = 1;
}
if(osl_keys->held.up){
i = 2;
}
if(osl_keys->held.down){
i = 3;
}
//Ends drawing mode
oslEndDrawing();
//Synchronizes the screen
oslSyncFrame();
}
//Terminate the program
oslEndGfx();
oslQuit();
return 0;
}
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#13 |
![]() ![]() |
Gontry now.
ok kool np..thanks for your help dude.later -=Double Post Merge =- lol..how noobish of me...haha thanks so me much i feel like a fool..i forgot to rename my Tar.png files in the folder ::krp did a double post Last edited by kronicali; 02-02-2009 at 01:50 PM.. Reason: Automerged Doublepost |
|
|
|
|
|
#14 |
![]() ![]() &amp;lt;font color=black&amp;gt;Develo per
|
Pretty inefficient way of checking whether the images loaded. I remember Yaustar showed me a better way. Besides, use the oslib built in function for checking whether the image loaded.
__________________
Calypso - Enjoy the excellent 2D space shooter: http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195 "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...) |
|
|
|
|
|
#15 |
![]() ![]() Developer
|
SuperBat, quickly written up, but i wouldn't say that's an inefficent way to check(simple checking for null isn't that hard, however i do understand how you mean for a large number of images such checks can become numerous, however i personally wouldn't do it this way, but i figured images not loading correctly was the problem=-)
glad i managed to help you fix your problem before i left=-), i just realized the output from the fatal error's were all the same, but from the sounds of it you figured it out=-)
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#16 |
![]() ![]() |
lol yeah i figured that out i do that soetimes when am to lazy to retype...one more thing i have and animation system not the best but it works gud for my programming lvl..anyway i.
#define RIGHT 0 ///then have my animation code then i set tar_position=RIGHT; but when the game loads i see the whole sprite sheet...then i starts animating..i thought setting the position would take care of it that problem? |
|
|
|
|
|
#17 |
![]() ![]() Developer
|
it's hard to say without seeing how ur actually handling the animation
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#18 | |
![]() ![]() |
ok i will upload the code later when i get home frm school..
-=Double Post Merge =- Quote:
Last edited by kronicali; 02-03-2009 at 07:13 PM.. Reason: Automerged Doublepost |
|
|
|
|
![]() |
| Tags |
| quickly |
| Thread Tools | |
|
|