Page 3 of 99 FirstFirst 1 2 3 4 5 13 53 ... LastLast
Results 21 to 30 of 983

Thread: How to create Games and Apps on your PSP using OSlib

  
  1. #21
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    You need to have the Makefile and the main.c source file both in the same folder before you compile your program. Copy and paste the source code in a notepad and save it as main.c Then copy and paste the Makefile code and save it as Makefile with no extension. Place both of those files together in a folder and compile your program.

    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  2. #22
    cor3 is offline Senior Member -Hacks Guru
    Join Date
    Sep 2006
    Location
    Cleveland
    Posts
    1,889
    Rep Power
    14

    Default

    i did that and heres wat i get

  3. #23
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Did you set up your path variables in the other sticky that I provided? I also uploaded a modified build.mak to use in the other sticky as well. Are you able to compile any of the samples that are provided in the pspsdk folder from the other sticky?
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  4. #24
    cor3 is offline Senior Member -Hacks Guru
    Join Date
    Sep 2006
    Location
    Cleveland
    Posts
    1,889
    Rep Power
    14

    Default

    ya i can compile the samples but i cant complie that

    i have a makefile with no extension

    and a main.c thing in a folder called Hello World

  5. #25
    MooL is offline -Hacks Newbie
    Join Date
    Dec 2006
    Posts
    21
    Rep Power
    0

    Default

    Hi Great tuts :).Just wondering how do you add music and is there any sites that have more tuts?:bucktooth:

  6. #26
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    Here is Lesson 3 which will deal with loading images and sprite movement. This is simple sprite movement not animation. Animation of sprites with sprite sheets will be in the next lesson, lesson 4.

    Lesson 3 - Image loading and sprite movement

    What we are going to do is load a background image onto the PSP and then load a game sprite onto that image and move the sprite around with the D-pad.
    Here is the background image we are going to use:


    Here is the game sprite we are going to use:


    Notice how the sprite image is surrounded by a pink color. We need our image to be surrounded by a color which will be set as our transparent color. So once the sprite is displayed on the PSP, you will only see the sprite image and no pink color anywhere. It can be any color that you would like but it can't be any where else in your background image or your map since we are going to set the color pink as transparent. I will get more into that later.

    Here is the Makefile which we will use for our program:
    Code:
    TARGET = Donkey_Lesson3
    OBJS = main.o
    
    INCDIR = 
    CFLAGS = -G4 -Wall -O2 
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LDFLAGS =
    STDLIBS= -losl -lpng -lz \
    		-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
    LIBS=$(STDLIBS)$(YOURLIBS)
    
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Donkey_Lesson3
    
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    Again, our Makefile is the same as the previous lessons I gave except of the target name and EBOOT name change.

    Here is the source code we will be using:
    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);
    
    //declaration of the pointers of our images
    OSL_IMAGE *background, *sprite;
    
    int main()
    {
    	//Initialization of the Oslib library
    	oslInit(0);
    
    	//Initialization of the graphics mode
    	oslInitGfx(OSL_PF_8888, 1);
    
    	//Sets the transparency color (pink)
    	oslSetTransparentColor(RGB(255,0,255));
    
    	//loads our images into memory
    	background = oslLoadImageFile("background.png", OSL_IN_RAM, OSL_PF_5551);
    	sprite = oslLoadImageFile("sprite.png", OSL_IN_RAM, OSL_PF_5551);
    
    	//Disables the transpaent color (pink)
    	oslDisableTransparentColor();
    
    	//Verification that all files are present
    	if (!background || !sprite)
    		oslDebug("It is impossible to load one or more of the images that are required in this program. Please make sure you have all the files required in the eboot folder");
    
    	//Main while loop
    	while (!osl_quit)
    	{
    		//To be able to draw on the screen
    		oslStartDrawing();
    		
    		//initiate the PSP's buttons
    		oslReadKeys();
    		
    		//Sprite movement
    		if (osl_keys->held.down) sprite->y += 2;
    		if (osl_keys->held.up) sprite->y -= 2;
    		if (osl_keys->held.left) sprite->x -= 2;
    		if (osl_keys->held.right) sprite->x += 2;
    
    		//Draw the images to the screen
    		oslDrawImage(background);
    		oslDrawImage(sprite);
    
    		//Ends drawing mode
    		oslEndDrawing();
    
    		//Synchronizes the screen 
    		oslSyncFrame();		
    	}
    	
    	//Terminate the program
    	oslEndGfx();
    	oslQuit();
    	return 0;
    }
    Explanation of code:

    1) OSL_IMAGE *background, *sprite;
    This just defines the pointers of our images. You need a pointer for each image and make sure you do this at the beginning of your code.

    2) oslSetTransparentColor(RGB(255,0,255));
    This code is used to tell the PSP which color NOT to display on the screen. That is why I surrounded my sprite in a nice boxed shape with the pink color. This code will set the transparent color at (255,0,255) which is pink. That way, the game sprite will be drawn in a uniform shape and not in a boxed shape. The pink is used to fill up the box we need to load the sprite.
    Tip: If you have pink in your background image or in your map, set the transparent color to another color that is not used since no pink color will show in your game. Then surround your sprite with that new transparent color. (I used pink because I figured that no one would probably use pink in their game, but you never know :)
    Note: color is stored as RGB values, ranging from 0 to 255, thus (255,0,255) means 255 red, 0 green and 255 blue. So that basically means a mix of red and blue, with no green (red+blue=pink).

    3) <variable> = oslLoadImageFile("background.png", OSL_IN_RAM, OSL_PF_5551);
    This loads the image into memory with the name (<variable>) specified. In our case the names are background and sprite.
    OSL_IN_RAM simply means that we are loading our image in RAM and not VRAM.
    OSL_PF_5551 means the pixel formate that we are choosing for our images. Here we are using just 16bit pixel formate as we are using just simple sprites. You can use 32bt pixel formate for more advanced images.
    Tip: you cannot load background images larger then 512x512 pixels. That is the limit on the PSP. If you want larger, you have to transform your image into a map for larger view area. I will explain this in a future lesson.

    4) oslDisableTransparentColor ();
    This simply disables the transparent color that we set earlier. In our case it is the pink color at (255,0,255)

    5) if (!background || !sprite)
    oslDebug("It is impossible to load <...>

    This basically means "If background or sprite is not found then print on screen this "It is impossible to load <...>"
    This code should be placed in all your programs as it makes sure everything is included before continuing your program.
    oslDebug() is a nice little function call which will pop up a window message on your PSP with what ever message you would like to send to the user. In our case it lets the user know that he is missing a file or image in the EBOOT folder.

    6) if (osl_keys->held.down) sprite->y += 2;
    This is the actual movement of the sprite. If you hold down the d-pad down button, the sprite will move down 2 pixels. The code y+=2 actual means y=y+2. That means that where ever the sprite originally was placed on the screen (y), move it down 2 pixels when the d-pad down button is pressed. The same goes for when you press the up button or left button or right button. y coordinate is for up and down and X coordinate is for left and right.
    You can also make your sprite move faster by increasing the coordinate increase. So instead of y+=2; you can use y+=3; etc

    7) oslDrawImage(background); oslDrawImage(sprite);
    This code first draws the background image and then the sprite image on top of the background image.
    You can also use the code
    oslDrawImageXY (X, y, image)
    to specify where exactly on the screen you would like to draw your sprite to begin with. X,Y would be the coordinates you would like to draw the sprite on the screen and image would be the name of your image you are using. This can be useful for static images on your screen like "lives" and "score"


    So this concludes Lesson 3 on image loading and sprite movement. On the next lesson, I will either show you how to load music and use sound effects in your game or I will jump to sprite animation and sprite sheets. I'll let you know.


    Here is the files and source code you need to compile your program. I also included the compiled EBOOT here in case you want to try it on your PSP.
    http://www.mediafire.com/?c5zeayiznn4
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  7. #27
    PSdonkey's Avatar
    PSdonkey is offline Senior Member -Hacks Guru
    Join Date
    Dec 2005
    Posts
    2,123
    Rep Power
    40

    Default

    @cor3, it looks like you might not have installed the OSlib library to your PSP setup. Look at that first post to learn how to install the library into your setup.

    @MooL, yeah i will be giving lessons in loading music and using sound effects in your program. i will also go into sprite animation as well. As for other sites providing lessons, i am sure there are sites that give you lessons on the PSPSDK by itself like psp-programming.com but they are very basic and they don't use this library.
    Obey Beaker. That is all.


    Spoiler:
    Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/
    Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/
    Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/

  8. #28
    MooL is offline -Hacks Newbie
    Join Date
    Dec 2006
    Posts
    21
    Rep Power
    0

    Default

    ok thanks. Wow thats cool :o. that gives me a idea for a small game but first gonna learn the basics :mrgreen:

  9. #29
    APEXnow is offline -Hacks Newbie
    Join Date
    Feb 2007
    Location
    UK
    Posts
    6
    Rep Power
    0

    Default

    PSdonkey,

    I've tried to download the OSlib archive, but the link just takes me to the fileserver's homepage. Was wondering if you could post me the Cygwin version of the library so that I can use it?

    Many thanks.

    Paul.

  10. #30
    ZiNgABuRgA's Avatar
    ZiNgABuRgA is offline Senior Member -Hacks Titan
    Join Date
    Sep 2006
    Location
    4CHIN
    Posts
    11,044
    Rep Power
    25

    Default

    Quote Originally Posted by APEXnow
    I've tried to download the OSlib archive, but the link just takes me to the fileserver's homepage. Was wondering if you could post me the Cygwin version of the library so that I can use it?
    Hmm, not sure what you exactly want, but I can upload the OSLib archive for you (lol, MediaFire appears to be down for now).

    May take a few minutes cause I have the world's slowest upload... well, not really, but 2KB/sec is nothing to be proud of...

Page 3 of 99 FirstFirst 1 2 3 4 5 13 53 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •