예제 #1
0
int calc_splash(Uint32 steps)
{
  splash_rotation+=steps*32;
  splash_counter -= steps;
  if (splash_counter <=0)
    return 1;
  PspInput engineInput = spGetInput();
  if ((engineInput->button[SP_BUTTON_START] ||
      engineInput->button[SP_BUTTON_A] || engineInput->button[SP_BUTTON_B] ||
      engineInput->button[SP_BUTTON_X] || engineInput->button[SP_BUTTON_Y]))
  {
    engineInput->button[SP_BUTTON_START] = 0;
    engineInput->button[SP_BUTTON_A] = 0;
    engineInput->button[SP_BUTTON_B] = 0;
    engineInput->button[SP_BUTTON_X] = 0;
    engineInput->button[SP_BUTTON_Y] = 0;
    return 1;
  }
  //Update Rotation
  int i;
  for (i = 0; i < MESH_SIZE*2; i ++)
  {
		Sint32 rotation = -(splash_rotation*3 + i*SP_PI/MESH_SIZE/8);
		sparrow_mesh->texPoint[i].x = saved_points[i][0];
		sparrow_mesh->texPoint[i].y = spMul(spCos(rotation),saved_points[i][1]) + spMul(spSin(rotation),saved_points[i][2]);
		sparrow_mesh->texPoint[i].z = spMul(spSin(rotation),saved_points[i][1]) + spMul(spCos(rotation),saved_points[i][2]);
		rotation += SP_PI;
		logo_mesh->texPoint[i].x = saved_points[i][0];
		logo_mesh->texPoint[i].y = spMul(spCos(rotation),saved_points[i][1]) + spMul(spSin(rotation),saved_points[i][2]);
		logo_mesh->texPoint[i].z = spMul(spSin(rotation),saved_points[i][1]) + spMul(spCos(rotation),saved_points[i][2]);
	}
  
  return 0;
}
예제 #2
0
void Craft::RenderOffsetToPosition( Vector2f* Offset )
{
	float ox;
	ox = PositionCurrent->x + ((float)((float)(spSin( Rotation ) * Offset->y) / (float)SP_ONE) * Scale) + ((float)((float)(spCos( Rotation ) * Offset->x) / (float)SP_ONE) * Scale);
	Offset->y = PositionCurrent->y - ((float)((float)(spCos( Rotation ) * Offset->y) / (float)SP_ONE) * Scale) + ((float)((float)(spSin( Rotation ) * Offset->x) / (float)SP_ONE) * Scale);
	Offset->x = ox;
	return;
}
예제 #3
0
void Craft::GenerateBullet( float FireAngle )
{
	Bullet* b;

	float ox = (((float)spSin( FireAngle ) / (float)SP_ONE) * 24.0);
	float oy = (((float)spCos( FireAngle ) / (float)SP_ONE) * 24.0);

	Vector2f* o = new Vector2f( ox, oy );
	RenderOffsetToPosition( o );
	b = new Bullet( this, o->x, o->y );
	b->Life = 60;
	b->Rotation = Rotation + FireAngle;
	b->Scale = Scale;
	b->Velocity = 4.0;
	CurrentGame->Bullets.push_back( b );
	delete o;
}
예제 #4
0
파일: testsprite.c 프로젝트: bzar/sparrow3d
int calc_function( Uint32 steps )
{
	//update rotation counter
	rotation += steps * 32;
	//if "Start" (or "Menu" for Wiz or "Home" for Caanoo or "Return" at the P) is
	//pressed: exit
	if ( spGetInput()->button[SP_BUTTON_START] )
		return 1;

	//Update the sprite (next picture)
	spUpdateSprite( sprite, steps );
	//rotozoom the sprite (without rotozoom it's faster):
	sprite->zoomX = spSin( rotation * 8 ) / 2 + ( 3 << SP_ACCURACY - 1 );
	sprite->zoomY = spCos( rotation * 6 ) / 2 + ( 3 << SP_ACCURACY - 1 );
	sprite->rotation = rotation * 4;

	return 0;
}
예제 #5
0
void draw_sprites(int rotation)
{
	spSetZTest( sprites_z );
	spSetZSet( sprites_z );
	SDL_Surface* screen = spGetWindowSurface();
	spRotozoomSurface( screen->w / 4, screen->h / 4, 0, sprites_garfield, spSin( rotation * 4 ) + ( spFloatToFixed( 1.5f ) ) >> 2, spCos( rotation * 8 ) + ( spFloatToFixed( 1.5f ) ) >> 2, rotation );
	spRotozoomSurfacePart( 3 * screen->w / 4, screen->h / 4, 0, sprites_garfield, sprites_garfield->w / 4, sprites_garfield->h / 4, sprites_garfield->w / 2, sprites_garfield->w / 2, spSin( rotation * 4 ) + ( spFloatToFixed( 1.5f ) ) >> 1, spCos( rotation * 8 ) + ( spFloatToFixed( 1.5f ) ) >> 1, rotation );
	sprite->rotation = 0;
	spDrawSprite( screen->w / 5, 5 * screen->h / 8, 0, sprite );
	sprite->zoomX = spSin( rotation * 8 ) + ( spFloatToFixed( 1.5f ) );
	sprite->zoomY = spCos( rotation * 6 ) + ( spFloatToFixed( 1.5f ) );
	spDrawSprite( 2 * screen->w / 5, 5 * screen->h / 8, 0, sprite );
	sprite->zoomX *= -1;
	sprite->rotation = rotation * 4;
	spDrawSprite( 3 * screen->w / 5, 5 * screen->h / 8, 0, sprite );
	sprite->zoomX = SP_ONE;
	sprite->zoomY = SP_ONE;
	spDrawSprite( 4 * screen->w / 5, 5 * screen->h / 8, 0, sprite );
	spSetZTest( 0 );
	spSetZSet( 0 );
}
예제 #6
0
파일: particle.c 프로젝트: aapo/puzzletube
void draw_particle_circle(int direction,int counter)
{
	spSetAlphaPattern4x4(PARTICLE_ALPHA,0);
  if (direction == -1)
  {
    //Left Circle
    spBlit3D(+spCos(counter*700+5*SP_PI/10),spSin(counter*700+5*SP_PI/10),0,getBigParticle());
    spBlit3D(+spCos(counter*700+3*SP_PI/10),spSin(counter*700+3*SP_PI/10),0,getMiddleParticle());
    spBlit3D(+spCos(counter*700+2*SP_PI/10),spSin(counter*700+2*SP_PI/10),0,getMiddleParticle());
    spBlit3D(+spCos(counter*700+1*SP_PI/10),spSin(counter*700+1*SP_PI/10),0,getSmallParticle());
    spBlit3D(+spCos(counter*700+0*SP_PI/10),spSin(counter*700+0*SP_PI/10),0,getSmallParticle());
    
    spBlit3D(+spCos(counter*700+15*SP_PI/10),spSin(counter*700+15*SP_PI/10),0,getBigParticle());
    spBlit3D(+spCos(counter*700+13*SP_PI/10),spSin(counter*700+13*SP_PI/10),0,getMiddleParticle());
    spBlit3D(+spCos(counter*700+12*SP_PI/10),spSin(counter*700+12*SP_PI/10),0,getMiddleParticle());
    spBlit3D(+spCos(counter*700+11*SP_PI/10),spSin(counter*700+11*SP_PI/10),0,getSmallParticle());
    spBlit3D(+spCos(counter*700+10*SP_PI/10),spSin(counter*700+10*SP_PI/10),0,getSmallParticle());
  }
  if (direction == 1)
  {  
    //Right circle
    spBlit3D(-spCos(counter*700+5*SP_PI/10),spSin(counter*700+5*SP_PI/10),0,getBigParticle());
    spBlit3D(-spCos(counter*700+3*SP_PI/10),spSin(counter*700+3*SP_PI/10),0,getMiddleParticle());
    spBlit3D(-spCos(counter*700+2*SP_PI/10),spSin(counter*700+2*SP_PI/10),0,getMiddleParticle());
    spBlit3D(-spCos(counter*700+1*SP_PI/10),spSin(counter*700+1*SP_PI/10),0,getSmallParticle());
    spBlit3D(-spCos(counter*700+0*SP_PI/10),spSin(counter*700+0*SP_PI/10),0,getSmallParticle());

    spBlit3D(-spCos(counter*700+15*SP_PI/10),spSin(counter*700+15*SP_PI/10),0,getBigParticle());
    spBlit3D(-spCos(counter*700+13*SP_PI/10),spSin(counter*700+13*SP_PI/10),0,getMiddleParticle());
    spBlit3D(-spCos(counter*700+12*SP_PI/10),spSin(counter*700+12*SP_PI/10),0,getMiddleParticle());
    spBlit3D(-spCos(counter*700+11*SP_PI/10),spSin(counter*700+11*SP_PI/10),0,getSmallParticle());
    spBlit3D(-spCos(counter*700+10*SP_PI/10),spSin(counter*700+10*SP_PI/10),0,getSmallParticle());
  }
  spDeactivatePattern();
}  
예제 #7
0
void draw_target(int rotation)
{
	SDL_Surface* screen = spGetWindowSurface();
  //drawing on the target_texture
  spSelectRenderTarget(target_texture);
	spClearTarget(65535);
	spSetZSet(0);
	spSetZTest(0);
	target_sprite->rotation = 0;
	spDrawSprite( target_texture->w / 4, target_texture->h / 4, 0, target_sprite );
	target_sprite->zoomX = spSin( rotation * 8 ) + spFloatToFixed( 1.5f );
	target_sprite->zoomY = spCos( rotation * 6 ) + spFloatToFixed( 1.5f );
	spDrawSprite( 3 * target_texture->w / 4, target_texture->h / 4, 0, target_sprite );
	target_sprite->rotation = rotation * 4;
	spDrawSprite( target_texture->w / 4, 3 * target_texture->h / 4, 0, target_sprite );
	target_sprite->zoomX = SP_ONE;
	target_sprite->zoomY = SP_ONE;
	spDrawSprite( 3 * target_texture->w / 4, 3 * target_texture->h / 4, 0, target_sprite );

  //drawing on the target_graph
  spSelectRenderTarget(target_graph);
	spClearTarget(01234);
	spSetZSet(0);
	spSetZTest(0);
	Uint16* pixeldata = spGetTargetPixel();
	int x;
	for (x = 0;x < GRAPH_SIZE; x++)
	{
		Sint32 sx = spIntToFixed(x-GRAPH_SIZE/2)/16;
		Sint32 sy = spSin(sx+rotation*16);
		int y = spFixedToInt(sy*16)+GRAPH_SIZE/2;
		if (y>=0 && y<GRAPH_SIZE)
      pixeldata[y*GRAPH_SIZE+x] = 56789;
		sy = spCos(sx+rotation*32);
		y = spFixedToInt(sy*16)+GRAPH_SIZE/2;
		if (y>=0 && y<GRAPH_SIZE)
      pixeldata[y*GRAPH_SIZE+x] = 45678;
  }
  spUnlockRenderTarget();
	for (x = 0;x < GRAPH_SIZE-1; x++)
	{
		Sint32 sx1 = spIntToFixed(x-GRAPH_SIZE/2)/16;
		Sint32 sy1 = spTan(sx1+rotation*8);
		int y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2;
		Sint32 sx2 = spIntToFixed(x+1-GRAPH_SIZE/2)/16;
		Sint32 sy2 = spTan(sx2+rotation*8);
		int y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2;
		spLine(x,y1,0,x+1,y2,0,34567);
		sy1 = spAcos(sx1/2+spSin(rotation*24));
		y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2;
		sy2 = spAcos(sx2/2+spSin(rotation*24));
		y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2;
		spLine(x,y1,0,x+1,y2,0,23456);
		sy1 = spAsin(sx1/2+spCos(rotation*24));
		y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2;
		sy2 = spAsin(sx2/2+spCos(rotation*24));
		y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2;
		spLine(x,y1,0,x+1,y2,0,12345);
  }
  
  //drawing on the screen
  spSelectRenderTarget(screen);
	spClearTarget(0);
	spSetZSet(1);
	spSetZTest(1);
  spResetZBuffer();
	spIdentity();

	spTranslate( 0,0, spFloatToFixed( -7.0f ) );
	spRotateX( rotation );
	spRotateY( rotation );
	spRotateZ( rotation );

	//Front / Back
	spBindTexture(target_texture);
	spQuadTex3D( -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_texture->h - 1,
				 -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, 0,
				 spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_texture->w - 1, 0,
				 spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_texture->w - 1, target_texture->h - 1, 65535);
	spQuadTex3D( spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, target_texture->h - 1,
				 spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0,
				 -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_texture->w - 1, 0,
				 -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_texture->w - 1, target_texture->h - 1, 65535 );
	//Left / Right
	spBindTexture(target_graph);
	spQuadTex3D( -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_graph->h - 1,
				 -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0,
				 -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_graph->w - 1, 0,
				 -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_graph->w - 1, target_graph->h - 1, 65535 );
	spQuadTex3D( spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_graph->h - 1,
				 spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0,
				 spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_graph->w - 1, 0,
				 spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_graph->w - 1, target_graph->h - 1, 65535 );
	//Up / Down
	spBindTexture(target_garfield);
	spQuadTex3D( spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_garfield->h - 1,
				 spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0,
				 -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_garfield->w - 1, 0,
				 -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_garfield->w - 1, target_garfield->h - 1, 65535 );
	spQuadTex3D( -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_garfield->h - 1,
				 -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0,
				 spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_garfield->w - 1, 0,
				 spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_garfield->w - 1, target_garfield->h - 1, 65535 );
}