I'm really new to PSP programming, but I've done a little C++ before.
Anyway, I'm having trouble with my game.
I'm trying to display a background and be able to move a character on the screen.
So I made the background and the character in photoshop, saved as PNG.
The character is transparent at some pixels.
But the background is flashing and the character leaves a trail after itself.
It's not removing the previously drawn character.
Here's the code:
Code: Select all
// C-Application, png test
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("Png image display in C", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main()
{
char buffer[200];
Image* ourImage;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
SceCtrlData pad;
int x=480/2;
int y=272/2;
int y2=0;
int x2=0;
sprintf(buffer, "Image.png");
ourImage = loadImage(buffer);
if (!ourImage)
{
printf("Image load failed!\n");
}
else
{
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0 ,0 ,480 , 272, ourImage, 0, 0);
flipScreen();
}
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
sprintf(buffer, "Eye.png");
ourImage = loadImage(buffer);
if (!ourImage)
{
printf("Image load failed!\n");
}
else
{
sceDisplayWaitVblankStart();
blitAlphaImageToScreen(0 ,0 ,16 , 16, ourImage, x, y);
flipScreen();
}
if(pad.Buttons & PSP_CTRL_DOWN)
y++;
if(pad.Buttons & PSP_CTRL_UP)
y--;
if(pad.Buttons & PSP_CTRL_RIGHT)
x++;
if(pad.Buttons & PSP_CTRL_LEFT)
x--;
}
sceKernelSleepThread();
return 0;
}
PataPon style :)
Character:
Do you know how to fix this?