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


C++ Laser类代码示例

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


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

示例1: switch

int Emitter::eventHandler( const df::Event *event ) {
	if ( event->getType( ) == df::STEP_EVENT ) {
		df::Position pos = this->getPosition( );
		switch ( this->getDirection( ) ) {
		case UP:
			pos.setY( pos.getY( ) - 1 );
			break;
		case DOWN:
			pos.setY( pos.getY( ) + 1 );
			break;
		case LEFT:
			pos.setX( pos.getX( ) - 1 );
			break;
		case RIGHT:
			pos.setX( pos.getX( ) + 1 );
			break;
		default:
			break;
		}
		Laser* laser = new Laser( this->getColor( ), this->getDirection( ) );
		laser->setPosition( pos );
		return 1;
	}
	return Component::eventHandler( event );
}
开发者ID:alray2569,项目名称:LaZerDragon,代码行数:25,代码来源:Emitter.cpp

示例2: Laser

void Player::FireLaser(void )
{
    Laser *l = new Laser();
    l->Initialise(position, rotation, LASER_RADIUS, LASER_VELOCITY);

    lasers.push_back(l);
}
开发者ID:russdaygh,项目名称:SpaceshipsInSpace,代码行数:7,代码来源:Player.cpp

示例3: create_element

Laser *create_laser(complex pos, float time, float deathtime, Color *color, LaserPosRule prule, LaserLogicRule lrule, complex a0, complex a1, complex a2, complex a3) {
	Laser *l = create_element((void **)&global.lasers, sizeof(Laser));
		
	l->birthtime = global.frames;
	l->timespan = time;
	l->deathtime = deathtime;
	l->pos = pos;
	l->color = color;
	
	l->args[0] = a0;	
	l->args[1] = a1;
	l->args[2] = a2;
	l->args[3] = a3;
	
	l->prule = prule;
	l->lrule = lrule;
	
	l->shader = NULL;
	l->collision_step = 5;
	l->width = 10;
	l->speed = 1;
	l->timeshift = 0;
	
	if(l->lrule)
		l->lrule(l, EVENT_BIRTH);
	
	l->prule(l, EVENT_BIRTH);
	
	return l;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例4: radians

Player::Player() : radians(PI / 2.0f) {
	this->collisionType     = entityNS::CIRCLE;
	this->mass              = playerNS::MASS;
	this->radius            = playerNS::WIDTH / 2;
	this->spriteData.height = playerNS::HEIGHT;
	this->spriteData.scale  = 1;
	this->spriteData.width  = playerNS::WIDTH;
	this->spriteData.x      = playerNS::X;
	this->spriteData.y      = playerNS::Y;

//Calculate several values regarding the position of the turret ring
	this->mirrorRadius = playerNS::HEIGHT / 2 + 10;
	this->trueCenterX = playerNS::X + playerNS::WIDTH / 2;
	this->trueCenterY = playerNS::Y + playerNS::HEIGHT / 2;
	this->turretRadius = playerNS::HEIGHT / 2 + 6;

	for(int i = 0; i < playerNS::TOTAL_LASERS; i++)
	{
		Laser* l = new Laser(graphicsNS::BLUE);
		l->setEnemyLaser(false);
		lasers[i] = l;
		l=0;
	}
	playerHealth = gladiatorNS::NUM_HEALTH_BARS;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例5: getAsteroidBoundingSphereRadius

bool LaserPhysicsComponent::testIntersectionWithAsteroid(Laser &laser, Asteroid &asteroid)
{
    D3DXVECTOR3 currLaserPos = laser.getPosition(), lastLaserPos = laser.getLastPosition(), 
        laserDir = laser.getDirection(), asteroidPosition = asteroid.getPosition();
    float asteroidRadius = getAsteroidBoundingSphereRadius(asteroid);
    float asteroidPosToLaserEnd;

    //check if the laser ray intersects a rough bounding sphere of the asteroid
    if (!D3DXSphereBoundProbe(&asteroidPosition, asteroidRadius, &lastLaserPos, &laserDir)) {
        return false;
    }

    asteroidPosToLaserEnd = D3DXVec3LengthSq(&(currLaserPos - asteroidPosition));

    //if this is true then the laser's current position does not fall within the sphere, and a ray starting at the laser's
    //current point crosses the circle. A ray starting at the last point already crosses the sphere, so this means both
    //points are "before" the sphere, along the ray in the direction the laser is travelling.
    if (asteroidRadius * asteroidRadius < asteroidPosToLaserEnd && 
        D3DXSphereBoundProbe(&asteroidPosition, asteroidRadius, &currLaserPos, &laserDir)) {
        return false;
    }

    //it may have collided. Now check ray against mesh
    shared_ptr<GraphicsComponent> gfx = asteroid.getGraphicsComponent();
    AsteroidGraphicsComponent *asteroidGraphicsComponent = dynamic_cast<AsteroidGraphicsComponent*>(gfx.get());
    
    if (asteroidGraphicsComponent == NULL) {
        throw "Asteroid didn't have a valid asteroid graphics component!";
    }

    BOOL hit;
    float dist;
    D3DXVECTOR3 laserPosRelativeToAsteroid = lastLaserPos - asteroidPosition;
    D3DXVECTOR3 asteroidScale = asteroid.getScale();
    D3DXQUATERNION rotationQuat = asteroid.getRotationQuat();
    D3DXMATRIX rot, scale;
    D3DXMatrixScaling(&scale, 0.8f/asteroidScale.x, 0.8f/asteroidScale.y, 0.8f/asteroidScale.z);
    D3DXMatrixRotationQuaternion(&rot, &rotationQuat);
    D3DXVec3TransformCoord(&laserPosRelativeToAsteroid, &laserPosRelativeToAsteroid, &(scale * rot));

    D3DXIntersect(asteroidGraphicsComponent->getMesh(),
        &laserPosRelativeToAsteroid,
        &laserDir,
        &hit,
        NULL,
        NULL,
        NULL,
        &dist,
        NULL,
        NULL);

    float distTravelledSq = D3DXVec3LengthSq(&(currLaserPos - lastLaserPos));
    if (!hit || dist * dist > D3DXVec3LengthSq(&(currLaserPos - lastLaserPos))) {
        return false;
    }

    return true;
}
开发者ID:love-rollercoaster,项目名称:space-game,代码行数:58,代码来源:LaserPhysicsComponent.cpp

示例6: _delete_laser

void _delete_laser(void **lasers, void *laser) {
	Laser *l = laser;
	
	if(l->lrule)
		l->lrule(l, EVENT_DEATH);
		
	if(l->color)
		free(l->color);
	del_ref(laser);
	delete_element(lasers, laser);
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例7: Laser

int Lens::eventHandler( const df::Event* evt ) {
  // Reset the output color on step
  if (evt->getType() == df::STEP_EVENT) {
    if (this->color != laser::BLACK) {
      Laser* laser = new Laser(this->color, getDirection());
      laser->setPosition(getPosition());
      this->color = laser::BLACK;
    }
    return 1;
  }
  return Component::eventHandler(evt);
}
开发者ID:alray2569,项目名称:LaZerDragon,代码行数:12,代码来源:Lens.cpp

示例8: main

int main()
{
    Laser<Salida> l;
    Salida s;
    cout << "Hello World 00!" << endl;
    l.setCallback(&Salida::SecondTriggered, s);
    cout << "Hello World 10!" << endl;
    l.StartLaser();
    for(int j=0;j<100000000;j++);
    cout << "Hello World 01!" << endl;

    return 0;
}
开发者ID:kill4n,项目名称:Kuro_ACM,代码行数:13,代码来源:main.cpp

示例9: Laser

Laser* Laser::create(Type _type)
{
	Laser *laser = new Laser();
	if (laser && laser->init(_type))
	{
		laser->autorelease();
		return laser;
	}
	else
	{
		delete laser;
		laser = NULL;
		return NULL;
	}
}
开发者ID:killy295630580,项目名称:MeteoriteCrisis,代码行数:15,代码来源:Laser.cpp

示例10: fire

void Player::fire(Laser &laser) {
	if(turret.getActive())
	{
		laser.fireRad(turret.getCenterX(), turret.getCenterY(), -this->radians + 3*PI/2);
		audio->playCue(LASER_CUE);
	}
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例11: loadLaserState

bool GameManager::loadLaserState(
	TiXmlElement* element,
	Apollo::SceneObject* parent)
{
	TiXmlElement* childElem = NULL;
	TiXmlElement* spriteElem = NULL;
	Laser* laser;

	laser = this->CreateLaser();
	laser->LoadState(element, parent);
	
	childElem = element->FirstChildElement("Children");
	if (childElem)
	{
		return loadChildObjects(childElem, laser);
	}

	return true;
}
开发者ID:DanAlbert,项目名称:apollo,代码行数:19,代码来源:GameManager.cpp

示例12: process_lasers

void process_lasers(void) {
	Laser *laser = global.lasers, *del = NULL;
	
	while(laser != NULL) {
		if(collision_laser_curve(laser))
			player_death(&global.plr);
		
		if(laser->lrule)
			laser->lrule(laser, global.frames - laser->birthtime);
		
		if(global.frames - laser->birthtime > laser->deathtime + laser->timespan*laser->speed) {
			del = laser;
			laser = laser->next;
			_delete_laser((void **)&global.lasers, del);
			if(laser == NULL) break;
		} else {
			laser = laser->next;
		}
	}
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例13: update

double Map::update(double x, double y, double yaw, const Laser& laser)
{
	// Handle new Obstacles
	vector<Point> obstacles;
	laser.getObstacles(x, y, yaw, obstacles);

	Point initalPoint(x, y);
	double matchPercent = handleObstacles(initalPoint, obstacles);

	return matchPercent;
}
开发者ID:jossef,项目名称:robotics,代码行数:11,代码来源:Map.cpp

示例14: while

void Player::CheckLaserAsteroidCollisions(std::list<Asteroid*>* asteroids)
{
    std::list<Asteroid*>::iterator a_iter = asteroids->begin();
    std::list<Asteroid*> a_tbd;
    std::list<Laser*> l_tbd;

    while(a_iter != asteroids->end())
    {
        Asteroid *ast = a_iter._Ptr->_Myval;
        std::list<Laser*>::iterator l_iter = lasers.begin();

        while(l_iter != lasers.end())
        {
            Laser *las = l_iter._Ptr->_Myval;

            if(ast->GetBSphere().Contains(las->GetPosition()))
            {
                //The laser is inside the asteroid bsphere
                a_tbd.push_back(ast);
                l_tbd.push_back(las);
                AddScore(ast->GetBSphere().GetRadius());
            }
            l_iter++;
        }
        a_iter++;
    }

    //Do the deletions
    std::list<Laser*>::iterator l_iter = l_tbd.begin();
    while(l_iter != l_tbd.end())
    {
        lasers.remove(l_iter._Ptr->_Myval);
        l_iter++;
    }
    a_iter = a_tbd.begin();
    while(a_iter != a_tbd.end())
    {
        asteroids->remove(a_iter._Ptr->_Myval);
        a_iter++;
    }
}
开发者ID:russdaygh,项目名称:SpaceshipsInSpace,代码行数:41,代码来源:Player.cpp

示例15: timer3_init

  void Laser::Init() {

    // Initialize timers for laser intensity control
    #if LASER_CONTROL == 1

      #if IS_TIMER_3_PWR
        timer3_init(LASER_PWR_PIN);
      #elif IS_TIMER_4_PWR
        timer4_init(LASER_PWR_PIN);
      #endif

    #elif LASER_CONTROL == 2

      #if IS_TIMER_3_PWM
        timer3_init(LASER_PWM_PIN);
      #elif IS_TIMER_4_PWM
        timer4_init(LASER_PWM_PIN);
      #endif

    #endif

    #if ENABLED(LASER_PERIPHERALS)
      OUT_WRITE(LASER_PERIPHERALS_PIN, HIGH);         // Laser peripherals are active LOW, so preset the pin
      OUT_WRITE(LASER_PERIPHERALS_STATUS_PIN, HIGH);  // Set the peripherals status pin to pull-up.
    #endif

    #if LASER_CONTROL == 2
      OUT_WRITE(LASER_PWR_PIN, LASER_UNARM);  // Laser FIRING is active LOW, so preset the pin
    #endif

    // initialize state to some sane defaults
    laser.intensity = 100.0;
    laser.ppm = 0.0;
    laser.duration = 0;
    laser.status = LASER_OFF;
    laser.firing = LASER_ON;
    laser.mode = CONTINUOUS;
    laser.last_firing = 0;
    laser.diagnostics = false;
    laser.time = 0;

    #if ENABLED(LASER_RASTER)
      laser.raster_aspect_ratio = LASER_RASTER_ASPECT_RATIO;
      laser.raster_mm_per_pulse = LASER_RASTER_MM_PER_PULSE;
      laser.raster_direction = 1;
    #endif // LASER_RASTER

    laser.extinguish();

  }
开发者ID:simonepri,项目名称:MK4duo,代码行数:50,代码来源:laser_avr.cpp


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