rendered paste body// PSP Space Invaders
// by JumpR
#include <oslib/oslib.h>
PSP_MODULE_INFO("PSP Space Invaders", 0, 1, 0);
PSP_HEAP_SIZE_MAX();
OSL_IMAGE *player, *background, *bullet;
int shooting = 0;
int main()
{
oslInit(0);
oslInitGfx(OSL_PF_8888, 1);
oslSetTransparentColor(RGB(255,0,0));
player = oslLoadImageFile("player.png", OSL_IN_RAM, OSL_PF_5551);
background = oslLoadImageFile("background.png", OSL_IN_RAM, OSL_PF_5551);
bullet = oslLoadImageFile("bullet.png", OSL_IN_RAM, OSL_PF_5551);
if (!player || !background || !bullet){
oslDebug("Some files seem to be missing, can't continue.");
}
player->x = 6;
player->y = 250;
while (!osl_quit)
{
oslStartDrawing();
oslReadKeys();
if (osl_keys->held.left) player->x -= 2;
if (osl_keys->held.right) player->x += 2;
if (osl_keys->held.cross) shoot();
oslDrawImage(background);
oslDrawImage(player);
if (shooting == 1)
{
oslDrawImage(bullet);
bullet->y -= 2;
if (bullet->y = 5) shooting = 0;
}
oslEndDrawing();
oslSyncFrame();
}
oslEndGfx();
oslQuit();
return 0;
}
int shoot()
{
if (shooting == 0)
{
shooting = 1;
bullet->x = player->x + 15;
bullet->y = player->y - 5;
}
}