Results 1 to 3 of 3

Thread: noob c question

                  
   
  1. #1
    PSP User
    Join Date
    Jun 2006
    Location
    Under your bed (H)
    Posts
    377
    Rep Power
    70

    Default noob c question

    hey im learning c opposed to lua as a starting language in psp development, and i don't know why this doesn't work:

    #include <pspkernel.h>
    #include <pspctrl.h>
    #include <pspdisplay.h>
    #include <pspgu.h>
    #include <png.h>
    #include <pspdebug.h>
    #include <stdio.h>
    #include "graphics.h"
    #define text pspDebugScreenPrintf

    PSP_MODULE_INFO("test images", 0, 1, 1);
    int exit_callback(int arg1, int arg2, void *common) {
    sceKernelExitGame();
    return 0;
    }
    int CallbackThread(SceSize args, void *argp) {
    int cbid;
    cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCallback(cbid);
    sceKernelSleepThreadCB();
    return 0;
    }
    int SetupCallbacks(void) {
    int uth = 0;
    uth = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(uth >= 0) {
    sceKernelStartThread(uth, 0, 0);
    }
    return uth;
    }

    int main()
    {
    char buff[100];
    Image* player;
    Image* enemy;
    Image* ball;
    Image* bg1;
    Image* bg2;
    sprintf(buff,"images/player.png");
    player = loadImage(buff);
    if(!player)
    {
    text("Loading failed! (Check images are in the 'image' folder!)");
    }
    else
    {
    sceDisplayWaitVblankStart();
    blitAlphaImageToScreen(0,0,480,272,player,(480/2),(272/2));
    }
    pspDebugScreenInit();
    SetupCallbacks();
    SceCtrlData pad;
    while(1)
    {
    sceCtrlReadBufferPositive(&pad, 1);
    }
    flipScreen();
    sceKernelSleepThread();
    return 0;
    }
    the screen just stays black, and yes i have the images in the images folder
    Last edited by Prasoc; January 12th, 2008 at 15:59. Reason: code tag screwed up

  2. #2
    DCEmu Rookie
    Join Date
    May 2007
    Location
    Under your Bed
    Posts
    168
    Rep Power
    0

    Default

    1. make sure that the files are png
    2. try this, in your while loop add
    blitAlphaImageToScreen(0,0,480,272,player,(480/2),(272/2));
    sceDisplayWaitVblankStart();
    flipScreen();
    and delete it in the other place it is

  3. #3
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    Code:
    while(1)
    {
    sceCtrlReadBufferPositive(&pad, 1);
    }
    You get stuck in an infinite loop just reading the pad input. A standard game loop is:

    Start loop
    Read pad input
    Process game logic
    Clear screen
    Render screen
    Wait for Vertical Sync
    Flip buffers
    End loop

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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