コード例 #1
0
ファイル: repairCrew.cpp プロジェクト: Baknik/EmptyEpsilon
PVector<RepairCrew> getRepairCrewFor(P<PlayerSpaceship> ship)
{
    PVector<RepairCrew> ret;
    if (!ship)
        return ret;

    foreach(RepairCrew, c, repairCrewList)
        if (c->ship_id == ship->getMultiplayerId())
            ret.push_back(c);
    return ret;
}
コード例 #2
0
FactionInfo::FactionInfo()
{
    foreach(FactionInfo, i, factionInfo)
        i->states.push_back(FVF_Neutral);
    factionInfo.push_back(this);

    for(unsigned int n = 0; n < factionInfo.size(); n++)
        states.push_back(FVF_Neutral);
    for(unsigned int n = 0; n < factionInfo.size(); n++)
        if (factionInfo[n] == this)
            states[n] = FVF_Friendly;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: rmatil/uzh-apc
int main(int argc, const char * argv[])
{
    // Vectors
    PVector<int, persister<int> > pvInt = PVector<int, persister<int> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp.txt");
    pvInt.push_back(12);
    pvInt.push_back(13);
    
    PVector<std::string, persister<std::string> > pv = PVector<std::string, persister<std::string> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp2.txt");
    pv.push_back("Test1.");
    pv.push_back("Test2.a Test2.b Test2.c");
    
    PVector<Fraction, persister<Fraction> > pvFr = PVector<Fraction, persister<Fraction> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp5.txt");
    Fraction fr1 = Fraction();
    fr1.set_counter(4);
    fr1.set_denominator(5);
    Fraction fr2 = Fraction();
    fr2.set_counter(5);
    fr2.set_denominator(7);
    pvFr.push_back(fr1);
    pvFr.push_back(fr2);
    
    
    // Sets: unique Values
	PSet<int, persisterTwo<int> > psInt = PSet<int, persisterTwo<int> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp3.txt");
    psInt.insert(2);
    psInt.insert(4);
    
    PSet<std::string, persisterTwo<std::string> > ps = PSet<std::string, persisterTwo<std::string> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp4.txt");
    std::string a = "Test1";
    std::string b = "Test2.a Test2.b Test2.c";
	ps.insert(a);
	ps.insert(b);
    
    PSet<Fraction, persisterTwo<Fraction> > psFr = PSet<Fraction, persisterTwo<Fraction> >("/Users/Raphael/Dropbox/uzh/uzh-13-fall/uzh-apc/uzh-apc-ex/apc-ex-04-1/apc-ex-04-1/tmp6.txt");
    psFr.insert(fr1);
    psFr.insert(fr2);
    
    
	return 0;
}
コード例 #4
0
FactionInfo::FactionInfo()
{
    if (game_server) { LOG(ERROR) << "FactionInfo objects can not be created during a scenario right now."; destroy(); return; }

    foreach(FactionInfo, i, factionInfo)
        i->states.push_back(FVF_Neutral);
    factionInfo.push_back(this);

    for(unsigned int n = 0; n < factionInfo.size(); n++)
        states.push_back(FVF_Neutral);
    for(unsigned int n = 0; n < factionInfo.size(); n++)
        if (factionInfo[n] == this)
            states[n] = FVF_Friendly;
}
コード例 #5
0
ファイル: repairCrew.cpp プロジェクト: Baknik/EmptyEpsilon
RepairCrew::RepairCrew()
: MultiplayerObject("RepairCrew")
{
    ship_id = -1;
    position.x = -1;
    action = RC_Idle;
    direction = ERepairCrewDirection(irandom(RC_Up, RC_Right + 1));

    selected = false;

    registerMemberReplication(&ship_id);
    registerMemberReplication(&position, 1.0);
    registerMemberReplication(&target_position);

    repairCrewList.push_back(this);
}
コード例 #6
0
PlayerInfo::PlayerInfo()
: MultiplayerObject("PlayerInfo")
{
    clientId = -1;
    main_screen_control = false;
    registerMemberReplication(&clientId);

    for(int n=0; n<maxCrewPositions; n++)
    {
        crew_position[n] = false;
        registerMemberReplication(&crew_position[n]);
    }
    registerMemberReplication(&ship_id);
    registerMemberReplication(&main_screen_control);
    
    playerInfoList.push_back(this);
}
コード例 #7
0
void GuiViewport3D::onDraw(sf::RenderTarget& window)
{
#if FEATURE_3D_RENDERING
    if (my_spaceship)
        soundManager->setListenerPosition(my_spaceship->getPosition(), my_spaceship->getRotation());
    else
        soundManager->setListenerPosition(sf::Vector2f(camera_position.x, camera_position.y), camera_yaw);
    window.pushGLStates();

    billboardShader->setParameter("camera_position", camera_position);

    float camera_fov = 60.0f;
    float sx = window.getSize().x * window.getView().getViewport().width / window.getView().getSize().x;
    float sy = window.getSize().y * window.getView().getViewport().height / window.getView().getSize().y;
    glViewport(rect.left * sx, (float(window.getView().getSize().y) - rect.height - rect.top) * sx, rect.width * sx, rect.height * sy);

    glClearDepth(1.f);
    glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glDepthMask(GL_TRUE);
    glEnable(GL_CULL_FACE);
    glColor4f(1,1,1,1);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    _glPerspective(camera_fov, rect.width/rect.height, 1.f, 25000.f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    glRotatef(90, 1, 0, 0);
    glScalef(1,1,-1);
    glRotatef(-camera_pitch, 1, 0, 0);
    glRotatef(-camera_yaw - 90, 0, 0, 1);

    glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix);
    glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
    glGetDoublev(GL_VIEWPORT, viewport);

    sf::Texture::bind(textureManager.getTexture("Stars"), sf::Texture::Pixels);
    glDepthMask(false);
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f( 100, 100, 100);
    glTexCoord2f(   0,    0); glVertex3f( 100, 100,-100);
    glTexCoord2f(1024, 1024); glVertex3f(-100, 100, 100);
    glTexCoord2f(   0, 1024); glVertex3f(-100, 100,-100);
    glEnd();
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f(-100, 100, 100);
    glTexCoord2f(   0,    0); glVertex3f(-100, 100,-100);
    glTexCoord2f(1024, 1024); glVertex3f(-100,-100, 100);
    glTexCoord2f(   0, 1024); glVertex3f(-100,-100,-100);
    glEnd();
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f(-100,-100, 100);
    glTexCoord2f(   0,    0); glVertex3f(-100,-100,-100);
    glTexCoord2f(1024, 1024); glVertex3f( 100,-100, 100);
    glTexCoord2f(   0, 1024); glVertex3f( 100,-100,-100);
    glEnd();
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f( 100,-100, 100);
    glTexCoord2f(   0,    0); glVertex3f( 100,-100,-100);
    glTexCoord2f(1024, 1024); glVertex3f( 100, 100, 100);
    glTexCoord2f(   0, 1024); glVertex3f( 100, 100,-100);
    glEnd();
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f( 100,-100, 100);
    glTexCoord2f(   0,    0); glVertex3f(-100,-100, 100);
    glTexCoord2f(1024, 1024); glVertex3f( 100, 100, 100);
    glTexCoord2f(   0, 1024); glVertex3f(-100, 100, 100);
    glEnd();
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(1024,    0); glVertex3f( 100,-100,-100);
    glTexCoord2f(   0,    0); glVertex3f(-100,-100,-100);
    glTexCoord2f(1024, 1024); glVertex3f( 100, 100,-100);
    glTexCoord2f(   0, 1024); glVertex3f(-100, 100,-100);
    glEnd();

    if (gameGlobalInfo)
    {
        //Render the background nebulas from the gameGlobalInfo. This ensures that all screens see the same background as it is replicated across clients.
        for(int n=0; n<GameGlobalInfo::max_nebulas; n++)
        {
            sf::Texture::bind(textureManager.getTexture(gameGlobalInfo->nebula_info[n].textureName), sf::Texture::Pixels);
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE);
            glPushMatrix();
            glRotatef(180, gameGlobalInfo->nebula_info[n].vector.x, gameGlobalInfo->nebula_info[n].vector.y, gameGlobalInfo->nebula_info[n].vector.z);
            glColor4f(1,1,1,0.1);
            glBegin(GL_TRIANGLE_STRIP);
            glTexCoord2f(1024,    0); glVertex3f( 100, 100, 100);
            glTexCoord2f(   0,    0); glVertex3f( 100, 100,-100);
            glTexCoord2f(1024, 1024); glVertex3f(-100, 100, 100);
            glTexCoord2f(   0, 1024); glVertex3f(-100, 100,-100);
            glEnd();
            glPopMatrix();
        }
    }
    glColor4f(1,1,1,1);
    glDisable(GL_BLEND);
    sf::Texture::bind(NULL);
    glDepthMask(true);
    glEnable(GL_DEPTH_TEST);

    {
        float lightpos1[4] = {0, 0, 0, 1.0};
        glLightfv(GL_LIGHT1, GL_POSITION, lightpos1);

        float lightpos0[4] = {20000, 20000, 20000, 1.0};
        glLightfv(GL_LIGHT0, GL_POSITION, lightpos0);
    }

    PVector<SpaceObject> renderList;
    sf::Vector2f viewVector = sf::vector2FromAngle(camera_yaw);
    float depth_cutoff_back = camera_position.z * -tanf((90+camera_pitch + camera_fov/2.0) / 180.0f * M_PI);
    float depth_cutoff_front = camera_position.z * -tanf((90+camera_pitch - camera_fov/2.0) / 180.0f * M_PI);
    if (camera_pitch - camera_fov/2.0 <= 0.0)
        depth_cutoff_front = std::numeric_limits<float>::infinity();
    if (camera_pitch + camera_fov/2.0 >= 180.0)
        depth_cutoff_back = -std::numeric_limits<float>::infinity();
    foreach(SpaceObject, obj, space_object_list)
    {
        float depth = sf::dot(viewVector, obj->getPosition() - sf::Vector2f(camera_position.x, camera_position.y));
        if (depth + obj->getRadius() < depth_cutoff_back)
            continue;
        if (depth - obj->getRadius() > depth_cutoff_front)
            continue;
        if (depth > 0 && obj->getRadius() / depth < 1.0 / 500)
            continue;
        renderList.push_back(obj);
    }
コード例 #8
0
ファイル: Monster.cpp プロジェクト: cnCT/MyCodes
void threes(const Vec2 &point)
{
	point.toString();
	int l,f,u,d;
	l = f = point.x;
	u = d = point.y;
	PVector tmpX;
	PVector tmpY;
	WTF node;
	node.centre = point;
	int countX = 0;
	while(--l > 0)
	{
		if (Map[l][point.y] == Map[point.x][point.y])
		{
			cout<<l<<" l "<<point.y<<endl;
			tmpX.push_back(Vec2(l,point.y));
			++countX;
		}
		else
			break;
	};
	while(++f < xCount)
	{
		if (Map[f][point.y] == Map[point.x][point.y])
		{
			cout<<f<<" f "<<point.y<<endl;
			tmpX.push_back(Vec2(f,point.y));
			++countX;
		}
		else
			break;
	};
	if (countX>=2)
	{
		cout<<"X is THREE"<<endl;
		node.vecX = tmpX;
	}

	int countY = 0;
	while(--u > 0)
	{
		if (Map[point.x][u] == Map[point.x][point.y])
		{
			cout<<point.x<<" u "<<u<<endl;
			tmpY.push_back(Vec2(point.x,u));
			++countY;
		}
		else
			break;
	};
	while(++d < yCount)
	{
		if (Map[point.x][d] == Map[point.x][point.y])
		{
			cout<<point.x<<" d "<<d<<endl;
			tmpY.push_back(Vec2(point.x,d));
			++countY;
		}
		else
			break;
	};
	if (countY>=2)
	{
		cout<<"Y is THREE"<<endl;
		node.vecY = tmpY;
	}
	bool cross = countX>=2&&countY>=2;
	bool five = countX>=4||countY>=4;
	bool four = countX>=3||countY>=3;
	bool three = countX>=2||countY>=2;
	node.p = 0;
	if (countX>=2&&countY>=2)
	{
		node.p |= CROSS;
	}
	if (countX>=4||countY>=4)
	{
		node.p |= FIVE;	
	}
	else if (countX>=3||countY>=3)
	{
		node.p |= FOUR;	
	}
	else if (countX>=2||countY>=2)
	{
		node.p |= THREE;		
	}
	if (node.p!=0)
	{
		cout<<"Yes"<<endl;
		nodes.push_back(node);
	}
}