示例#1
0
void Object::moveRt(const int xBound)
{
	if (getLocationX() >= xBound - 1) {
		// std::cerr << "Can't move " << getName() << " right: boundary limit." << std::endl;
	} else {
		xLocation++;
	}
}
示例#2
0
void Object::moveLt(const int xBound)
{
	if (getLocationX() <= 0) {
		// std::cerr << "Can't move " << getName() << " left: boundary limit." << std::endl;
	} else {
		xLocation--;
	}
}
void PlayerObject::draw() {
	if (light >= 0) {
		GLfloat position[4];
		position[0] = getLocationX();
		position[1] = 3;
		position[2] = getLocationZ();
		position[3] = 1;
		glLightfv(light, GL_POSITION, position);
	}
	((Object*)this)->draw();
}
// doDraw
//--------------------------------------------------------------------------
void VehicleSelectionView::doDraw( Surface& dest )
{
    Objective* obj = ObjectiveInterface::getObjective(CURRENT_SELECTED_OUTPOST_ID);
    if ( !obj || obj->occupying_player != PlayerInterface::getLocalPlayer() )
    {
//        Desktop::setVisibilityNoDoAnything("VehicleSelectionView", false);
        changeMade = false;
        return;
    }
    
    char strBuf[256];

    const int color = Color::white;

    // Draw a line attaching the VehicleSelectionView to its outpost.
    {if (WorldInputCmdProcessor::isObjectiveSelected())
        {
            // Draw a line connecting the vehicleSelectionView and the objective.
            iRect gameViewRect;
            WorldViewInterface::getViewWindow(&gameViewRect);

            iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos());
            objectivePos -= gameViewRect.getLocation();

            iXY a(VehicleSelectionView::getLocation() + VehicleSelectionView::getSize() / 2);
            iXY b(objectivePos);

            // Calculate the starting point on the outside of the vehicleSelectionView box.
            fXY v2oSlope(Math::unitDirection(a, b));

            a.x += int(v2oSlope.x * float(VehicleSelectionView::getWidth() / 2));
            a.y += int(v2oSlope.y * float(VehicleSelectionView::getHeight() / 2));

            // Calculate the starting point on the outside of the objective box.
            iXY objectiveOutlineSize(3, 3);

            //fXY o2vSlope(Math::unitDirection(b, a));

            //b.x += o2vSlope.x * float(objectiveOutlineSize.x);
            //b.y += o2vSlope.y * float(objectiveOutlineSize.y);

            //screen.drawLine(a, b, Color::white);

            iRect r(objectivePos.x - objectiveOutlineSize.x,
                    objectivePos.y - objectiveOutlineSize.y,
                    objectiveOutlineSize.x,
                    objectiveOutlineSize.y);

            screen->fillRect(r, Color::white);

            //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2;

            //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black);

            iXY oos(objectiveOutlineSize);
            iXY cpos;

            if (v2oSlope.x > 0 && v2oSlope.y > 0) {
                cpos = iXY(getEndX(), getEndY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x > 0 && v2oSlope.y <= 0) {
                cpos = iXY(getEndX(), getLocationY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y > 0) {
                cpos = iXY(getLocationX(), getEndY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y <= 0) {
                cpos = iXY(getLocationX(), getLocationY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
//
            screen->drawLine(cpos, b, Color::white);
            screen->fillRect(r, Color::white);

            //screen.bltLookup(r, Palette::darkGray256.getColorArray());
            //screen.drawButtonBorder(r, Color::white, Color::gray96);

            // Draw the name of the outpost.
        }}

    bltViewBackground(dest);

    int remaining_time = 0;
    int generation_time = 0;

    if ( obj->unit_generation_on_flag )
    {
        remaining_time = obj->unit_generation_timer.getTimeLeft();
        UnitProfile* profile = UnitProfileInterface::getUnitProfile(obj->unit_generation_type);
        generation_time = profile->regen_time;
    }

    if (vsvUnitGenOn)
    {
        sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit));
        dest.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);

        sprintf(strBuf, "%01d:%02d/%01d:%02d",
                        remaining_time / 60, remaining_time % 60,
                        generation_time / 60, generation_time % 60);
         
        dest.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    }
    else
    {
        sprintf(strBuf, "%s", _("power off"));
        dest.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);
        dest.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    }

    int unitPerPlayer = GameConfig::game_maxunits / GameConfig::game_maxplayers;
    sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer);
    dest.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color);

    drawUnitProfileInfo(dest, iXY(0, unitProfileDataY), highlightedUnitType);

    //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 );
    //clientArea.bltString(timeRemainingPos, strBuf, color);

    View::doDraw( dest );

} // end VehicleSelectionView::doDraw
void RankView::notifyMoveTo()
{
    gameconfig->gameinterface.setRankPositionX(getLocationX());
    gameconfig->gameinterface.setRankPositionY(getLocationY());
}
示例#6
0
void CCylinder::drawHapticScene(bool primary_context)
{
	hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, m_stiffness);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, m_dampening);
	hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, m_static_friction);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, m_dynamic_friction);

	if ( !m_customRendered )
	{
		if(primary_context)
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID);
		else
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID_1);

		drawGLScene();
		hlEndShape();
	}
	else
	{
		// Draw cylinder section
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID_1 );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticCylinder::intersectSurface, (void *) customCylinder);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticCylinder::closestSurfaceFeatures, (void *) customCylinder);
		hlEndShape();

		// Draw disk A
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID_1 ());

		diskATrans->makeIdentity ();

		diskATrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, 0.5*PI ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( 0, 0, 0.5 ) );

		diskATrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskATrans->multRight ( getHduMatrix ( getRotation () ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskA);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskA);
		hlEndShape();

		// Draw disk B
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID_1 ());

		diskBTrans->makeIdentity ();

		diskBTrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, -0.5*PI ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( 0, 0, -0.5 ) );

		diskBTrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskBTrans->multRight ( getHduMatrix ( getRotation () ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskB);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskB);
		hlEndShape();
	}

}