tutorial_BouncingBall/bball__versions/bball_subVersionsSprites/bball__v05/source/ball.c
// the diameter of the ball (integer)
the diameter of the ball (integer)
the diameter of the ball ( integer )
void ballRender( ball* b, int camera_x, int camera_y )
{
 u16* sprite = OAM + b->sprite_index * 4; 
 int x, y;
 x = ((b->x - c_radius*2) >> 8) - camera_x;
 y = ((b->y - c_radius*2) >> 8) - camera_y;
 if( x <= -16 || y <= -16 || x >= 256 || y >= 192 )
 {
        oamSetHidden( &oamMain, b->sprite_index, true);
	return;
 }
 sprite[0] = (y & 255) | ATTR0_ROTSCALE_DOUBLE;
 sprite[1] = (x & 511) | ATTR1_SIZE_16 | ATTR1_ROTDATA( b->sprite_affine_index );
 sprite[2] = 0;
 u16* affine;
 affine = OAM + b->sprite_affine_index * 16 + 3;
 affine[4] = 0;
 affine[8] = 0;
 int pa = (b->height * (65536/c_diam)) >> 16;
 int pd = 65536 / pa;
 affine[0] = pa;
 affine[12] = pd;
}
void ballRender ( ball * b , int camera_x , int camera_y ) { u16 * sprite = OAM + b -> sprite_index * 4 ; int x , y ; x = ( ( b -> x - c_radius * 2 ) >> 8 ) - camera_x ; y = ( ( b -> y - c_radius * 2 ) >> 8 ) - camera_y ; if ( x <= -16 || y <= -16 || x >= 256 || y >= 192 ) { oamSetHidden ( & oamMain , b -> sprite_index , true ) ; return ; } sprite [ 0 ] = ( y & 255 ) | ATTR0_ROTSCALE_DOUBLE ; sprite [ 1 ] = ( x & 511 ) | ATTR1_SIZE_16 | ATTR1_ROTDATA ( b -> sprite_affine_index ) ; sprite [ 2 ] = 0 ; u16 * affine ; affine = OAM + b -> sprite_affine_index * 16 + 3 ; affine [ 4 ] = 0 ; affine [ 8 ] = 0 ; int pa = ( b -> height * ( 65536 / c_diam ) ) >> 16 ; int pd = 65536 / pa ; affine [ 0 ] = pa ; affine [ 12 ] = pd ; }
the diameter of the ball (integer)
the diameter of the ball ( integer )
// Cada entrà de la taula de OAM ocupa 4 u16 //sprites fuera de rango. Deshabilitar el sprite //sprite[0] = ATTR0_DISABLED;