示例#1
0
void init_sprites()
{
	sprites_garfield = spLoadSurface( "./data/garfield.png" );
	sprites_texture = spLoadSurface( "./data/science_guy_frames01.png" );
	sprite = spNewSprite(NULL);
	spNewSubSpriteTilingRow( sprite, sprites_texture, 1, 1, 22, 46, 24, 48, 9 ,100);
}
示例#2
0
void init_target()
{
	//Textures loading
	target_scientist = spLoadSurface( "./data/science_guy_frames01.png" );
	target_garfield = spLoadSurface( "./data/garfield.png" );
	target_texture = spCreateSurface(256,256);
	target_graph = spCreateSurface(GRAPH_SIZE,GRAPH_SIZE);


	//Sprite Creating
	target_sprite = spNewSprite( NULL );
	int i;
	for ( i = 0; i < 9; i++ )
		spNewSubSpriteWithTiling( target_sprite, target_scientist, i * 24 + 1, 1, 22, 46, 100 );
}
示例#3
0
文件: testmesh.c 项目: bzar/sparrow3d
int main(int argc, char **argv)
{
	//sparrow3D Init
	spSetDefaultWindowSize(640,480); //Creates a 640x480 window at PC instead of 320x240
	spInitCore();
	
	//Setup
	screen = spCreateDefaultWindow();
	//Selecting the renderTarget. It could be every surface
	spSelectRenderTarget(screen);
	resize(screen->w,screen->h);
	
	//Textures loading
	texture = spLoadSurface("./data/garfield.png");
	//Setting alpha test to 0, because the texture has pink parts
	spSetAlphaTest(0);
	//Mesh loading
	mesh = spMeshLoadObj("./data/testmeshuv_tri.obj",texture,65535);
		
	//Light on! There is one "default" light at 0,0,0 with color white. We just use it.
	spSetLight(1);
	
	//All glory the main loop
	//every frame the draw_function is called
	//every frame the calc_function is called with the past time as argument
	//at least 10 ms have to be between to frames (max 100 fps)
	//if the window is resized, the resize feedback-function is called (again)
	spLoop(draw_function,calc_function,10,resize,NULL);
	
	//Winter Wrap up, Winter Wrap up
	spMeshDelete(mesh);
	spDeleteSurface(texture);
	spQuitCore();
	return 0;
}
示例#4
0
// Stage control
void TitleStage::Begin()
{
	background = spLoadSurface( ".//resource//title.png" );
	mainFont = spFontLoad( ".//resource//standard.ttf", gameSettings->ScreenHeight / 12 );
	spFontAddRange( mainFont, " ", "~", SDL_MapRGB( display->format, 192, 220, 255 ) );
	
}
示例#5
0
文件: debugstage.cpp 项目: pmprog/P01
void DebugStage::Begin()
{
	carTexture = spLoadSurface( ".//resource//car.png" );
	roadTexture = spLoadSurface( ".//resource//road.png" );
	offroadTexture = spLoadSurface( ".//resource//off.png" );
	roadsideTexture = spLoadSurface( ".//resource//roadside.png" );
	carMesh = spMeshLoadObjSize( ".//resource/car.obj", carTexture, 65535, 12000 );
	fontHnd = spFontLoad( "./resource/standard.ttf", 32 );
	spFontAddRange( fontHnd, ' ', '~', SDL_MapRGB( display->format, 0, 0, 0 ) );

	fontHiHnd = spFontLoad( "./resource/standard.ttf", 64 );
	spFontAddRange( fontHiHnd, ' ', '~', SDL_MapRGB( display->format, 255, 220, 128 ) );
	fontHiSHnd = spFontLoad( "./resource/standard.ttf", 64 );
	spFontAddRange( fontHiSHnd, ' ', '~', SDL_MapRGB( display->format, 0, 0, 0 ) );

}
示例#6
0
void run_splashscreen(void (*resize)(Uint16 w,Uint16 h))
{
	//spSetPerspectiveTextureMapping(1);
  splash_rotation = 0;
  sparrow = spLoadSurface("./images/sparrow.png");
  logo = spLoadSurface("./images/dragonbox.png");
  sparrow_mesh = spMeshLoadObj( "./images/splash.obj", sparrow, 65535 );
  logo_mesh = spMeshLoadObj( "./images/splash.obj", logo, 65535 );
  int i;
  for (i = 0; i < MESH_SIZE*2; i ++)
  {
		saved_points[i][0] = sparrow_mesh->texPoint[i].x;
		saved_points[i][1] = sparrow_mesh->texPoint[i].y;
		saved_points[i][2] = sparrow_mesh->texPoint[i].z;
	}
  splash_counter = SPLASH_WAIT;
  spLoop(draw_splash,calc_splash,10,resize,NULL);
  spMeshDelete( sparrow_mesh );
  spMeshDelete( logo_mesh );
  SDL_FreeSurface(sparrow);
  SDL_FreeSurface(logo);
  //spSetPerspectiveTextureMapping(0);
}
示例#7
0
int main( int argc, char **argv )
{
	//sparrow3D Init
	spSetDefaultWindowSize( 640, 480 ); //Creates a 640x480 window at PC instead of 320x240
	spInitCore();

	//Setup
	screen = spCreateDefaultWindow();
	spSelectRenderTarget(screen);

	//Tile map loading
	tile_map = spLoadSurface( "./data/science_guy_frames01.png" );

	//Creating an empty sprite
	sprite = spNewSprite();
	//Filling it with it subsprites.
	int i;
	for ( i = 0; i < 9; i++ )
		spNewSubSpriteWithTiling( sprite, tile_map, i * 24 + 1, 1, 22, 46, 100 );

	//We don't want to use the zBuffer in any way
	spSetZSet(0);
	spSetZTest(0);

	//All glory the main loop
	//every frame the draw_function is called
	//every frame the calc_function is called with the past time as argument
	//at least 10 ms have to be between to frames (max 100 fps)
	//if the window is resized, the resize feedback-function is called (again)
	spLoop( draw_function, calc_function, 10, NULL, NULL );

	//Winter Wrap up, Winter Wrap up
	spDeleteSprite( sprite );
	spDeleteSurface( tile_map );
	spQuitCore();
	return 0;
}
示例#8
0
void DebugStage::Begin()
{
	ShipBases.push_back(spLoadSurface( ".//resource//ship_base_green.png" ));
	ShipCockpits.push_back(spLoadSurface( ".//resource//ship_cockpit_green.png" ));
	ShipLeftWing.push_back(spLoadSurface( ".//resource//ship_wing_left_green.png" ));
	ShipRightWing.push_back(spLoadSurface( ".//resource//ship_wing_right_green.png" ));
	ShipLeftBlade1.push_back(spLoadSurface( ".//resource//ship_blade1_left_green.png" ));
	ShipRightBlade1.push_back(spLoadSurface( ".//resource//ship_blade1_right_green.png" ));
	ShipLeftBlade2.push_back(spLoadSurface( ".//resource//ship_blade2_left_green.png" ));
	ShipRightBlade2.push_back(spLoadSurface( ".//resource//ship_blade2_right_green.png" ));

	BulletGraphics.push_back(spLoadSurface( ".//resource//bullet_standard.png" ));
	BulletGraphicFrames.push_back( 1 );
	BulletGraphics.push_back(spLoadSurface( ".//resource//bullet_upgrade1.png" ));
	BulletGraphicFrames.push_back( 1 );
	BulletGraphics.push_back(spLoadSurface( ".//resource//bullet_upgrade2.png" ));
	BulletGraphicFrames.push_back( 4 );
	BulletGraphics.push_back(spLoadSurface( ".//resource//bullet_upgrade3.png" ));
	BulletGraphicFrames.push_back( 1 );
	BulletGraphics.push_back(spLoadSurface( ".//resource//bullet_upgrade4.png" ));
	BulletGraphicFrames.push_back( 4 );

	ShipBaseFlames = spLoadSurface( ".//resource//ship_base_burner.png" );

	TestShip = new Craft( this );
	TestShip->PositionCurrent->x = gameSettings->ScreenWidth / 2;
	TestShip->PositionCurrent->y = gameSettings->ScreenHeight / 2;
	TestShip->Scale = 2.0;
}
示例#9
0
PREFIX spSpriteCollectionPointer spLoadSpriteCollection(char* filename,SDL_Surface* fallback_surface)
{
	SDL_RWops *file = SDL_RWFromFile(filename, "rt");
	if (!file)
		return NULL;
	spSpriteCollectionPointer collection = spNewSpriteCollection();
	
	//Loading the file line by line
	int end = 0;
	spSpritePointer sprite = NULL;
	char surface_d[1024] = "";
	//border default
	int bw_d = 0;
	int bh_d = 0;
	//frame default
	int fw_d = 0;
	int fh_d = 0;
	int fps_d = 0;
	char sprite_d[1024] = "";
	char surface[1024] = "";
	int bw = bw_d;
	int bh = bh_d;
	int fw = fw_d;
	int fh = fh_d;
	int fps = fps_d;
	while (!end) 
	{
		char line[512];
		end = spReadOneLine(file,line,512);
		//parsing the line
		if (line[0] == '#' || line[0] == ';') {} //comment
		else
		if (line[0] == '[') //new sprite
		{
			int i;
			for (i = 1; line[i]!=']' && line[i]!=0; i++);
			line[i] = 0;
			sprite = spNewSprite(&(line[1]));
			spAddSpriteToCollection(collection,sprite);
			sprintf(surface,"%s",surface_d);
			bw = bw_d;
			bh = bh_d;
			fw = fw_d;
			fh = fh_d;
			fps = fps_d;
		}
		else //some keywords
		{
			//searching the '=', ' ' or \0.
			int i;
			for (i = 1; line[i]!='=' && line[i]!=' ' && line[i]!=0; i++);
			if (line[i]==0) //hm, not good...
				continue;
			int keyword = 0;
			if (line[i]=='=')
			{
				line[i] = 0;
				keyword = spSpriteCollectionGetKeyword(line);
				line[i] = '=';
			}
			else // ' '
			{
				line[i] = 0;
				keyword = spSpriteCollectionGetKeyword(line);
				line[i] =' ';
				for (i++;line[i]!='=' && line[i]!=0; i++);
				if (line[i]==0) //hm, not good...
					continue;
			}
			for (i++;line[i]==' '; i++);
			char* value = &(line[i]);
			int j;
			for (j = strlen(value)-1;value[j]==' ' && j>=0;j--);
			value[j+1] = 0;
			int x,y,n;
			switch (keyword)
			{
				case 1: //"default"
					sprintf(sprite_d,"%s",value);
					break;
				case 2: //"image"
					if (sprite)
						sprintf(surface,"%s",value);
					else
						sprintf(surface_d,"%s",value);
					break;
				case 3: //fps
					if (sprite)
						fps = atoi(value);
					else
						fps_d = atoi(value);
					break;
				case 4: //framesize
					if (sprite)
						fw = atoi(value);
					else
						fw_d = atoi(value);
					for (i++;line[i]!=',' && line[i]!=0; i++);
					if (line[i] == 0)
						continue;
					value = &(line[i+1]);
					if (sprite)
						fh = atoi(value);
					else
						fh_d = atoi(value);
					break;
				case 5: //bordersize
					if (sprite)
						bw = atoi(value);
					else
						bw_d = atoi(value);
					for (i++;line[i]!=',' && line[i]!=0; i++);
					if (line[i] == 0)
						continue;
					value = &(line[i+1]);
					if (sprite)
						bh = atoi(value);
					else
						bh_d = atoi(value);
					break;
				case 6: //frame
					if (!sprite)
						break;
					x = atoi(value);
					for (i++;line[i]!=',' && line[i]!=0; i++);
					if (line[i] == 0)
						continue;
					value = &(line[i+1]);
					y = atoi(value);
					for (i++;line[i]!=',' && line[i]!=0; i++);
					
					SDL_Surface* s = spLoadSurface( surface );
					if (s == NULL)
						s = fallback_surface;
					if (line[i] == 0)
						spNewSubSpriteWithTiling(sprite,s,x+(bw-fw)/2,y+(bh-fh)/2,fw,fh,1000/(fps>0?fps:1));
					else
					{
						value = &(line[i+1]);
						n = atoi(value);						
						if (n > 0)
							spNewSubSpriteTilingRow(sprite,s,x+(bw-fw)/2,y+(bh-fh)/2,fw,fh,bw,bh,n,1000/(fps>0?fps:1));
					}
					//We loaded the surface one time more, than we will it delete later, so lets decrease the ref counter:
					spDeleteSurface( s );
					break;
			}
		}
	}
	spSelectSprite(collection,sprite_d);
	SDL_RWclose(file);
	return collection;
}