Ejemplo n.º 1
0
bool cGrafic::Crear (char *nom)
{
    sprite = Sprite_Create (nom);
    if (sprite->frame_actual->pixels != NULL)
        return true;
    else
        return false;
}
Ejemplo n.º 2
0
void	Test_Loop( void )
{
	sGraphicPos	lPos;
	S16			lAddX,lAddY;
	sSprite *	lpSprite;

	Screen_Init();

	gpPicture = File_Load( "SPRITE.PI1" );

	if( gpPicture )
	{
		Video_SetPalST( &gpPicture->Header.Palette[ 0 ] );

		lPos.X = 0;
		lPos.Y = 0;

		lAddX  = 1;
		lAddY  = 1;

		lpSprite = Sprite_Create(
			&gpPicture->Pixels[ 0 ],
			&gpPicture->Pixels[ 0 ],
			16,
			16,
			4,
			0 );

		while( !IKBD_GetKeyStatus(eIKBDSCAN_SPACE) )
		{
			Screen_Swap();

			gGraphic.pVRAM = gpLogic;
			gGraphic.pFuncs->ClearScreen( &gGraphic );

			gGraphic.pClipFuncs->DrawSprite(
				&gGraphic,
				&lPos,
				lpSprite );

			if( lAddX > 0 )
			{
				lPos.X++;
				if( lPos.X > (320-16) )
				{
					lPos.X = 320-16;
					lAddX  = -1;
				}
			}
			else
			{
				lPos.X--;
				if( lPos.X < 0 )
				{
					lPos.X = 0;
					lAddX  = 1;
				}
			}

			if( lAddY > 0 )
			{
				lPos.Y++;
				if( lPos.Y > (200-16) )
				{
					lPos.Y = 200-16;
					lAddY  = -1;
				}
			}
			else
			{
				lPos.Y--;
				if( lPos.Y < 0 )
				{
					lPos.Y = 0;
					lAddY  = 1;
				}
			}


		}
	}

	File_UnLoad( gpPicture );

	Screen_DeInit();
}
Ejemplo n.º 3
0
/*! 
 * @brief 读入一张png图像并生成一个精灵
 *
 * @param fileName png文件名
 * @return 一个精灵指针
 */
Sprite * Sprite_LoadImage (const char * fileName) {
    Sprite * sprite = Sprite_Create();
    sprite->surface = Media_LoadImage(fileName);
	return sprite;  
}
Ejemplo n.º 4
0
bool Sprite::Create(const std::string& name, bool immediate) { if (obj) Sprite_Destroy(obj); obj = Sprite_Create(name, immediate); return obj != NULL; }
Ejemplo n.º 5
0
/*
 * pCreateBlankSprite - Create a blank sprite.
 *
 * Create a blank sprite and add a palette if needed
 *
 * returns a pointer to the sprite when successful, otherwise NULL
 */
static sprite_areainfo *
pCreateBlankSprite(const imagedata_type *pImg, size_t *pSize)
{
	sprite_areainfo	*pArea;
	UCHAR	*pucTmp;
	size_t	tSize;
	screen_modeval	uMode;
	int	iIndex, iPaletteEntries;

	TRACE_MSG("pCreateBlankSprite");

	fail(pImg == NULL);
	fail(pSize == NULL);

	switch (pImg->uiBitsPerComponent) {
	case  1:
		uMode.screen_mode = 18;
		iPaletteEntries = 2;
		break;
	case  4:
		uMode.screen_mode = 20;
		iPaletteEntries = 16;
		break;
	case  8:
	case 24:
		uMode.screen_mode = 21;
		iPaletteEntries = 0;
		break;
	default:
		DBG_DEC(pImg->uiBitsPerComponent);
		return NULL;
	}
	fail(iPaletteEntries < 0 || iPaletteEntries > 16);

	/* Get memory for the sprite */
	tSize = sizeof(sprite_areainfo) +
		Sprite_MemorySize(pImg->iWidth, pImg->iHeight, uMode,
		iPaletteEntries > 0 ? sprite_HASPAL : sprite_HASNOMASKPAL);
	DBG_DEC(tSize);
	pArea = xmalloc(tSize);

	/* Initialise sprite area */
	pArea->areasize = tSize;
	pArea->numsprites = 0;
	pArea->firstoffset = sizeof(sprite_areainfo);
	pArea->freeoffset = sizeof(sprite_areainfo);

	/* Create a blank sprite */
	Error_CheckFatal(Sprite_Create(pArea, "wordimage",
		iPaletteEntries > 0 ? 1 : 0,
		pImg->iWidth, pImg->iHeight, uMode));

	/* Add the palette */
	pucTmp = (UCHAR *)pArea + pArea->firstoffset + sizeof(sprite_header);
	for (iIndex = 0; iIndex < iPaletteEntries; iIndex++) {
		/* First color */
		*pucTmp++ = 0;
		*pucTmp++ = pImg->aucPalette[iIndex][0];
		*pucTmp++ = pImg->aucPalette[iIndex][1];
		*pucTmp++ = pImg->aucPalette[iIndex][2];
		/* Second color */
		*pucTmp++ = 0;
		*pucTmp++ = pImg->aucPalette[iIndex][0];
		*pucTmp++ = pImg->aucPalette[iIndex][1];
		*pucTmp++ = pImg->aucPalette[iIndex][2];
	}

	*pSize = tSize;
	return pArea;
} /* end of pCreateBlankSprite */