Пример #1
0
int main()
{
	VDP_setScreenWidth320();

	Vector2D speed		= { FIX32(0.2), FIX32(0.2) };
	Vector2D position	= { FIX32(  1), FIX32(  1) };

	// Init joy handler
	JOY_init();
	JOY_setEventHandler( &joyAtkHandler );

	// Under construction
	// SPR_init( (4 * 8) + (3 * 3 * 9) );	// Knighty is 2x2 tiles and 8 frames, Wizard is 3x3 and 9 frames
	SPR_init( (4 * 8) + (3 * 3 * 9) );
	draw_arena();
	init_player_wizard(140, 128);
	init_player_knighty(128, 128);

	spr_players[1] = WIZARD_SPR;
	spr_players[0] = KNIGHTY_SPR;

	// game loop
	while (1)
	{
		// directionalInput( &p1, &p2 );
		wizard_control(&p1, JOY_1);
		knighty_control(&p2, JOY_2);

		bounceCharacter( &speed, &position );
		debugPlayers(p1, p2, p1_dir, p2_dir);

		// control_wizard(&p1);
		SPR_update(spr_players, 2);

		// wait for the screen to refresh
		VDP_waitVSync();
	}
	
	SPR_end();

	return 0;
}
Пример #2
0
void SPR_init(u16 cacheSize)
{
    u16 index;
    u16 size;

    // already initialized --> end it first
    if (SPR_isInitialized()) SPR_end();

    // alloc cache structure memory
    VDPSpriteCache = MEM_alloc(SPRITE_CACHE_SIZE * sizeof(VDPSprite));

    size = cacheSize?cacheSize:384;
    // get start tile index for sprite cache (reserve VRAM area just before system font)
    index = TILE_FONTINDEX - size;

    // init tile cache engine if needed
    TC_init();
    // and create a tile cache for the sprite
    TC_createCache(&tcSprite, index, size);
}