PDA

View Full Version : noob c question



Prasoc
January 12th, 2008, 15:58
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

thehumanidiot
January 19th, 2008, 03:18
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

yaustar
January 20th, 2008, 17:40
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