当前位置: 首页>>代码示例>>C++>>正文


C++ Disc类代码示例

本文整理汇总了C++中Disc的典型用法代码示例。如果您正苦于以下问题:C++ Disc类的具体用法?C++ Disc怎么用?C++ Disc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Disc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getDisc

void Field::draw(std::ostream& os) {
    Disc* dsc;
    for(unsigned int i = height; i > 0; i--) {
        for(unsigned int j = 0; j < width; j++) {
            dsc = getDisc(j,i-1);
            if(dsc == NULL) {
                os << " [";
                Field::spacer(os, tlMax, " ");
                os << "]";
             } else {
                 os << " [" << *dsc->getColor()->getToken();
                 Field::spacer(os, (unsigned int)(tlMax-dsc->getColor()->getToken()->length()), " ");
                 os << "]";
             }
        }
        os << std::endl;
    }
    // draw column numbers and separation line
    for(unsigned int i = 0; i < width; i++) {
        os << "---";
        Field::spacer(os, tlMax, "-");
    }
    os << std::endl;
    for(unsigned int i = 0; i < width; i++) {
        os << " [" << i+1;
        Field::spacer(os, tlMax-1, " ");
        os << "]";
    }
    os << std::endl << std::endl;
}
开发者ID:fried-ice,项目名称:connect_four,代码行数:30,代码来源:field.cpp

示例2: identify_partition

static float
identify_partition(int fd, partition_data *partition, void **cookie)
{
	DEBUG_INIT_ETC(NULL, ("fd: %d, id: %ld, offset: %Ld, "
		"size: %Ld, block_size: %ld, flags: 0x%lx", fd,
		partition->id, partition->offset, partition->size,
		partition->block_size, partition->flags));

	device_geometry geometry;
	float result = -1;
	if ((partition->flags & B_PARTITION_IS_DEVICE) != 0
		&& partition->block_size == 2048
		&& ioctl(fd, B_GET_GEOMETRY, &geometry) == 0
		&& geometry.device_type == B_CD) {
		Disc *disc = new(std::nothrow) Disc(fd);
		if (disc != NULL && disc->InitCheck() == B_OK) {
			// If we have only a single session then we can let the file system
			// drivers play directly with the device.
			Session *session = disc->GetSession(1);
			if (session != NULL) {
				result = 0.9f;
				delete session;
			} else
				result = 0.1f;

			*cookie = static_cast<void*>(disc);
		} else
			delete disc;
	}
	PRINT(("returning %g\n", result));
	return result;
}
开发者ID:DonCN,项目名称:haiku,代码行数:32,代码来源:session.cpp

示例3: isDiscInside

bool isDiscInside(Disc d,Hole h)
{
	if(isLessThan(abs(d.getX() - h.getX()),h.getRadius()) && isLessThan(abs(d.getY() - h.getY()),h.getRadius()))
		return true;
	else
		return false;
}
开发者ID:NikDelhi,项目名称:Carrom,代码行数:7,代码来源:physics.cpp

示例4: loop_pulse_function

void loop_pulse_function(void *data, int message){
  Disc *d = static_cast<Disc *>(data);
  if (message != -100) d->set_texture(15 + message);
  if (message == -4){
    d->set_orb_maintain(100);
  }
  d->pulse();
}
开发者ID:chetgnegy,项目名称:CollideFx,代码行数:8,代码来源:Disc.cpp

示例5: checkNearness

bool checkNearness(Disc d, Wall w,int wallno)
{
	bool cond = (wallno==0 || wallno==2);
	if(abs((cond?d.getY():d.getX()) - (cond?w.getY():w.getX())) <= d.getRadius() && (cond?d.getVy():d.getVx())*(cond?w.getY():w.getX())>= 0)
	{
		//cout<<d.getDiscNo()<<" colliding with wall"<<wallno<<endl;
		return true;
	}
	return false;
}
开发者ID:NikDelhi,项目名称:Carrom,代码行数:10,代码来源:physics.cpp

示例6: discid_new

Disc *
MusicBrainz::readDisc(const std::string &deviceName)
{
#ifdef DISCID_FOUND
	DiscId *discid = discid_new();
	if (!discid) {
		throw DiscError("Couldn't create a new DiscId instance.");
	}
	
	if (!discid_read(discid, deviceName.empty() ? NULL : deviceName.c_str())) {
		string msg(discid_get_error_msg(discid));
		discid_free(discid);
		throw DiscError(msg);
	}
	
	Disc *disc = new Disc;
	disc->setId(discid_get_id(discid));
	disc->setSectors(discid_get_sectors(discid));
	disc->setFirstTrackNum(discid_get_first_track_num(discid));
	disc->setLastTrackNum(discid_get_last_track_num(discid));
	for (int i = disc->getFirstTrackNum(); i <= disc->getLastTrackNum(); i++) {
		disc->addTrack(Disc::Track(discid_get_track_offset(discid, i),
								   discid_get_track_length(discid, i)));
	}
	
	discid_free(discid);
	return disc;
#else
	throw DiscError("libdiscid is not available.");
#endif
}
开发者ID:Seltzer,项目名称:foo-bulk-tagger,代码行数:31,代码来源:disc.cpp

示例7: checkNextCollision

bool checkNextCollision(Disc d1,Disc d2)
{
	double relVx = d1.getVx() - d2.getVx();
	double relVy = d1.getVy() - d2.getVy();
	double relx = d1.getX() - d2.getX();
	double rely = d1.getY() - d2.getY();
	if(relVx*relx + relVy*rely < 0) return true;
	return false;
}
开发者ID:NikDelhi,项目名称:Carrom,代码行数:9,代码来源:physics.cpp

示例8: move

	bool TowerHanoi::move(int from, int to) {
		if (!this->towers[from]->empty()) {
			Disc* objFrom = this->towers[from]->front();
			if (!this->towers[to]->empty()) {
				Disc* objTo = this->towers[to]->front();
				if (objFrom->getCount() < objTo->getCount()) {
					this->towers[to]->push(this->towers[from]->pop());
					if ((to > 0) && (this->towers[to]->size() == this->discs)) {
						this->win = true;
					}
					return true;
				}
			} else {
				this->towers[to]->push(this->towers[from]->pop());
				return true;
			}
		}
		return false;
	}
开发者ID:izuc,项目名称:SENG6120_assignment2,代码行数:19,代码来源:TowerHanoi.cpp

示例9: DisplayDisc

void DisplayDisc()
{
	Window * window = Window::FindCurrentWindow(windows);
	if (window->handle == BAD_GL_VALUE)
		return;

	glViewport(0, 0, window->size.x, window->size.y);
	vec4 crimson(0.6f , 0.0f , 0.0f , 1.0f);
	vec3 ambient = vec3(0.0f , 0.0f , 0.0f);
	vec3 specular = vec3(0.0f , 0.0f , 0.3f);
	vec3 diffuse = vec3(0.0f , 0.0f , 0.9f);

	glClearColor(crimson.r , crimson.g , crimson.b , crimson.a);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	glEnable(GL_DEPTH_TEST);

	mat4 model_matrix = rotate(mat4() , radians(window->LocalTime() * 30.0f) , vec3(0.0f , 1.0f , 0.0f));
	model_matrix = scale(model_matrix , vec3(3.0f , 3.0f , 3.0f));

	mat4 view_matrix = lookAt(vec3(0.0f , 0.0f , 8.0f) , vec3(0.0f , 0.0f , 0.0f) , vec3(0.0f , 1.0f , 0.0f));
	
	mat4 projection_matrix = perspective(radians(window->fovy) , window->aspect , window->near_distance , window->far_distance);
	
	phong_shader.Use(model_matrix , view_matrix , projection_matrix);
	phong_shader.SetMaterial(diffuse , specular , 128.0f , ambient);
	phong_shader.SetLightPosition(vec3(0.0f , 0.0f , 1000.0f));
	phong_shader.SelectSubroutine(PhongShader::PHONG_WITH_TEXTURE);
	phong_shader.EnableTexture(textures[2] , 0);
	disc3.Draw(false);
	phong_shader.UnUse();

	if (window->draw_normals)
	{
		constant_shader.Use(model_matrix , view_matrix , projection_matrix);
		constant_shader.SetMaterial(diffuse , specular , 32.0f , vec3(1.0f , 1.0f , 1.0f));
		disc3.Draw(true);
		constant_shader.UnUse();
	}
	glutSwapBuffers();
	disc3.UpdateValues(TestUpdateDisc , window->LocalTime(), nullptr);
}
开发者ID:Goobae,项目名称:Shapes,代码行数:41,代码来源:main_pk.cpp

示例10: afterCollision

void afterCollision(Disc d1,Disc d2,double v[][2])
{
	//double **v = (double**) malloc(4*sizeof(double));
	//cout<<"array declared"<<endl;
	//sleep(2);
	double vector_par[2],vector_per[2],u_par[2],v_per[2],v_par[2],l;
	double v1[2][2],y,x;
	double v1x = d1.getVx(),v2x = d2.getVx(),v1y = d1.getVy(),v2y = d2.getVy(),m1 = d1.getMass(),m2 = d2.getMass();
	double slope;
	y=(d1.getY()-d2.getY());
	x=(d1.getX()-d2.getX());
	l=sqrt(y*y+x*x);
	vector_par[0]=x/l;
	vector_par[1]=y/l;
	vector_per[0]=y/l;
	vector_per[1]=-x/l;
	//cout<<"vector par"<<vector_par[0]<<"+"<<vector_par[1]<<"\n";
	//cout<<"vector_per"<<vector_per[0]<<"+"<<vector_per[1]<<"\n";
	//cout<<"v1"<<v1x<<"+"<<v1y<<"\n";
	//cout<<"v2"<<v2x<<"+"<<v2y<<"\n";
	u_par[0]=v1x*vector_par[0]+v1y*vector_par[1];
	u_par[1]=v2x*vector_par[0]+v2y*vector_par[1];
	//cout<<u_par[0]<<"+"<<u_par[1]<<"\n";
	
	v_per[0]=v1x*vector_per[0]+v1y*vector_per[1];
	v_per[1]=v2x*vector_per[0]+v2y*vector_per[1];
		//cout<<v_per[0]<<"+"<<v_per[1]<<"\n";

	v_par[0]=(m1*u_par[0] + m2*u_par[1] + m2*ed*(u_par[1]-u_par[0]))/(m1+m2);
	v_par[1]=(m1*u_par[0] + m2*u_par[1] - m1*ed*(u_par[1]-u_par[0]))/(m1+m2);
	//cout<<v_par[0]<<"+"<<v_par[1]<<"+";
	
	//cout<<"slope"<<slope<<"\n";
	//sleep(2);
	v[0][0]=v_par[0]*vector_par[0]+v_per[0]*vector_per[0];
	v[0][1]=v_par[0]*vector_par[1]+v_per[0]*vector_per[1];
	v[1][0]=v_par[1]*vector_par[0]+v_per[1]*vector_per[0];
	v[1][1]=v_par[1]*vector_par[1]+v_per[1]*vector_per[1];
	//cout<<"disk"<<v[0][0]<<"+"<<v[0][1]<<"\n";
	//cout<<"striker"<<v[1][0]<<"+"<<v[1][1]<<"\n";
	
	
}
开发者ID:NikDelhi,项目名称:Carrom,代码行数:43,代码来源:physics.cpp

示例11: scan_partition

static status_t
scan_partition(int fd, partition_data *partition, void *cookie)
{
	DEBUG_INIT_ETC(NULL, ("fd: %d, id: %ld, offset: %Ld, size: %Ld, "
		"block_size: %ld, cookie: %p", fd, partition->id, partition->offset,
		partition->size, partition->block_size, cookie));

	Disc *disc = static_cast<Disc*>(cookie);
	partition->status = B_PARTITION_VALID;
	partition->flags |= B_PARTITION_PARTITIONING_SYSTEM
		| B_PARTITION_READ_ONLY;
	partition->content_size = partition->size;

	Session *session = NULL;
	status_t error = B_OK;
	for (int i = 0; (session = disc->GetSession(i)); i++) {
		partition_data *child = create_child_partition(partition->id,
			i, partition->offset + session->Offset(), session->Size(), -1);
		if (!child) {
			PRINT(("Unable to create child at index %d.\n", i));
			// something went wrong
			error = B_ERROR;
			break;
		}
		child->block_size = session->BlockSize();
		child->flags |= session->Flags();
		child->type = strdup(session->Type());
		delete session;
		if (!child->type) {
			error = B_NO_MEMORY;
			break;
		}
		child->parameters = NULL;
	}
	PRINT(("error: 0x%lx, `%s'\n", error, strerror(error)));
	RETURN(error);
}
开发者ID:DonCN,项目名称:haiku,代码行数:37,代码来源:session.cpp

示例12: playHole

void playHole(int holeName, Hole currentHole, Player jimmy, int *score )
{
    //array of things to pass from graphics to disc class
    double* stuff;   
    int scoreHole = 0 ;
    Disc disc;
    int past = 0;
    int diff;
    
    std::string currentPic;
    
     while( !disc.checkHole(currentHole.getX(), currentHole.getY()) && !past)
    {
    	currentPic = disc.pickScreen(holeName);
    	
    	//cout << currentPic << endl;
    	
    	//play the current hole
        stuff = play(currentPic, jimmy.getSong(), currentHole.getY() - disc.getY(), currentHole.getX() - disc.getX(), *score, scoreHole);
        //throw the frisbee
        disc.letFly(stuff[0],stuff[1],stuff[2],jimmy.getPower(),jimmy.getAccuracy(), currentHole);
        //track score
        (*score)++;
        scoreHole++;
        
        //see if disc has passed hole
         if(disc.getX() > currentHole.getX()) {
        	past = 1;
        	//cout << "You passed the hole. Auto score set to 8." << endl;
        	diff = 8 - scoreHole;
        	scoreHole = 8;
        	(*score) += diff;
        }
    } 
    	// determine which end screen to show
   	if( past )
		play(currentPic,jimmy.getSong(), -6, -6, *score, scoreHole);  
        else
		play(currentPic,jimmy.getSong(), 0,0, *score, scoreHole);
	
	if( holeName == 5)
		play("../../pictures/Pat_being_a_goon.png",jimmy.getSong(), -7,-7, *score, 0);
}
开发者ID:cbrant,项目名称:final_project,代码行数:43,代码来源:fullGame.cpp

示例13: while

Scene* ConfigReader::parse(){
	
	string line, label, rest, svalue;
	while ( getline(is_f,line)){
		    parseObject(line,label,rest);

			if (label == "sphere"   )  {
				Sphere* s = new Sphere();
				if (parseSphere(rest,*s)){
					_s.objects.push_back(s);
					
				}
				if (s->isLight())
					_s.olights.push_back(s);
			}
			else if (label == "scene"    )  {
				if (parseScene(rest,_s)){
					
				}
			}
			else if (label == "camera"    )  {
				
				if (parseCamera(rest,_s.camera)){
					
				}
			}else if (label == "material" )  {
				Material tmp;
				Material *m = NULL;
				if (parseMaterial(rest,tmp)){
					switch (tmp.type) {
					case DIFF:
						m = new DiffuseMaterial(tmp);
						break;
					case SPEC:
						m = new MirrorMaterial(tmp);
						break;
					case SPECP:
						m = new PhongMetalMaterial(tmp);
						break;
					case DSPEC:
						m = new DiffSpecularMaterial(tmp);
						break;
					case REFR:
						m = new DielectricMaterial(tmp);
						break;
					}
					_s.materials.push_back(m);
				}
			}
			else if (label == "plane"    )  {
				Plane* p  = new Plane();
				if (parsePlane(rest,*p)){
					_s.objects.push_back(p);
					
				}
				if (p->isLight())
					_s.olights.push_back(p);
			}
			else if (label == "frame"    )  {
				Frame* f  = new Frame();
				if (parseFrame(rest,*f)){
					_s.objects.push_back(f);
					
				}
				if (f->isLight())
					_s.olights.push_back(f);
			}
			else if (label == "disc"    )  {
				Disc* c  = new Disc();
				if (parseDisc(rest,*c)){
					_s.objects.push_back(c);
					
				}
				if (c->isLight())
					_s.olights.push_back(c);
			}
			if (label == "triangle"    )  {
				Triangle* t  = new Triangle();
				if (parseTriangle(rest,*t)){
					_s.objects.push_back(t);
					
				}
				if (t->isLight())
					_s.olights.push_back(t);
			}
			else if (label == "box"     )  {
				Box* b  = new Box();
				if (parseBox(rest,*b)){
					b->fill();
					_s.objects.push_back(b);
					
				}				
				if (b->isLight())
					_s.olights.push_back(b);
			}			
	}
	
	return &_s;
}
开发者ID:asolis,项目名称:raytracing,代码行数:99,代码来源:configreader.cpp

示例14: main

int
main(int argc, char **argv)
{
	if (argc < 1) {
		cout << "Usage: cdlookup [device]"  << endl;
		return 1;
	}

	string device;
	if (argc > 1)
		device = argv[1];

	Disc *disc;
	try {
		disc = readDisc(device);
	}
	catch (DiscError &e) {
		cout << "Error: " << e.what() << endl;
		return 1;
	}
	string discId = disc->getId();
	delete disc;
	cout << "Disc Id: " << discId << endl << endl;

	Query q;
	ReleaseResultList results;
	try {
    ReleaseFilter f = ReleaseFilter().discId(discId);
        results = q.getReleases(&f);
	}
	catch (WebServiceError &e) {
		cout << "Error: " << e.what() << endl;
		return 1;
	}

	for (ReleaseResultList::iterator i = results.begin(); i != results.end(); i++) {
		ReleaseResult *result = *i;
		Release *release;
		try {
			release = q.getReleaseById(result->getRelease()->getId(), &ReleaseIncludes().tracks().artist());
		}
		catch (WebServiceError &e) {
			cout << "Error: " << e.what() << endl;
			continue;
		}
		cout << "Id      : " << release->getId() << endl;
		cout << "Title   : " << release->getTitle() << endl;
		cout << "Tracks  : ";
		int trackno = 1;
		for (TrackList::iterator j = release->getTracks().begin(); j != release->getTracks().end(); j++) {
			Track *track = *j;
			Artist *artist = track->getArtist();
			if (!artist)
				artist = release->getArtist();
			cout << trackno++ << ". " << artist->getName() << " / " << track->getTitle() << endl;
			cout << "          ";
		}
		cout << endl;
		delete result;
	}

	return 0;
}
开发者ID:Seltzer,项目名称:foo-bulk-tagger,代码行数:63,代码来源:cdlookup.cpp

示例15: drawRadar

void drawRadar(){
		//Set up orthographic projection for radar
		mat4 projection1 = perspective(45.0f, window.window_aspect, 0.01f, 10.0f);
		glm::mat4 Projection2 = glm::ortho( -10.0f, 10.0f, -10.0f, 00.0f,1.0f, 10.0f);
		glm::mat4 View       = glm::lookAt(
			glm::vec3(0,0,5), // Camera is at (0,0,5), in World Space
			glm::vec3(0,0,0), // and looks at the origin
			glm::vec3(0,1,0)  // Head is up (set to 0,-1,0 to look upside-down)
		);  
			
		mat4 another = View;
		mat4 healthBarMatrix = View;
		another = translate(another, vec3(8.5,-8.5,0));
		
		another = rotate(another, 90.0f, vec3(0,1,0));
		another = rotate(another, 90.0f, vec3(0,0,1));

		healthBarMatrix = translate(healthBarMatrix, vec3(-9.5,-0.5,0));
		
		//healthBarMatrix = rotate(healthBarMatrix, 90.0f, vec3(0,1,0));
		healthBarMatrix = rotate(healthBarMatrix, -90.0f, vec3(0,0,1));
		healthBarMatrix = scale(healthBarMatrix, vec3(0.05f, userTeam.soldiers[0].health/10.f, 0.05f));

		if(userTeam.soldiers[0].health < 50){
			healthBar.color = vec3(1.f, userTeam.soldiers[0].health/50.f, 0.f);
		}
		else{
			healthBar.color = vec3(1.f - (userTeam.soldiers[0].health-50.f)/50.f, 1.f, 0.f);
		}
		healthBar.Draw(Projection2, healthBarMatrix, tod, 0);

		mat4 radar = another;

		//Radar display
		
		int radarBlipTime = current_timeDisplay * 1000;
		float radarBlip = 0.0015 * (radarBlipTime%1000);
		radar = scale(radar, vec3(radarBlip, radarBlip, radarBlip));
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		disc.color = vec3(0,1,0);
		disc.Draw(Projection2, radar, tod, 0);

		another = scale(another, vec3(1.5, 1.5, 1.5));
		disc.Draw(Projection2, another, tod, 0);

		

		glPolygonMode(GL_FRONT_AND_BACK, window.wireframe ? GL_LINE : GL_FILL);
		disc.color = vec3(0,0.25,0);
		disc.Draw(Projection2, another, tod, 0);

		another = translate(View, vec3(8.5 - ((3/104.6)*transX),-8.6 + ((3/104.6)*transZ),0));
		usr.Draw(Projection2, another, tod, 0);

		stringstream ammo (stringstream::in | stringstream::out);
		ammo << userTeam.soldiers[0].ammo;
		activeTextDisplay(("Ammo: " + ammo.str()).c_str(), -0.95f, -0.85f, 16);
}
开发者ID:claytonsuplinski,项目名称:SolarSystem,代码行数:58,代码来源:main.cpp


注:本文中的Disc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。