您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vec2函数代码示例

51自学网 2021-06-03 09:35:41
  C++
这篇教程C++ vec2函数代码示例写得很实用,希望能帮到您。

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

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

示例1: Tile2D_DrawWorld

BT2D_API void Tile2D_DrawWorld(){	Tile2D_Entity *tmp;	char *s, *s0, *s1;	int tex;	float x, y;	int i, j;	LBXGL_Sprite_SetCameraOrgRot(bt2d_cam->org, bt2d_cam->rot);	glEnable(GL_ALPHA_TEST);	tex=LBXGL_Texture_LoadImage("textures/voxel/dirt");	LBXGL_Shader_BindTexture(tex);		s0=NULL;//	LBXGL_Shader_Begin(PDGL_QUADS);	for(i=0; i<tile2d_map_xs; i++)	{		for(j=0; j<tile2d_map_ys; j++)		{			x=i-(tile2d_map_xs/2);			y=j-(tile2d_map_ys/2);					s1=Tile2D_TexNameForColor(tile2d_map+(j*tile2d_map_xs+i)*4);			if(s1!=s0)			{				if(s0)				{					LBXGL_Shader_End();				}								if(s1)				{					tex=LBXGL_Texture_LoadImage(s1);					LBXGL_Shader_BindTexture(tex);					LBXGL_Shader_Begin(PDGL_QUADS);				}								s0=s1;			}					if(!s0)				continue;						LBXGL_Shader_TexCoord2f(0, 0);			LBXGL_Shader_Vertex3f(x, 0, y);			LBXGL_Shader_TexCoord2f(1, 0);			LBXGL_Shader_Vertex3f(x+1, 0, y);			LBXGL_Shader_TexCoord2f(1, 1);			LBXGL_Shader_Vertex3f(x+1, 0, y+1);			LBXGL_Shader_TexCoord2f(0, 1);			LBXGL_Shader_Vertex3f(x, 0, y+1);		}	}	if(s0)		LBXGL_Shader_End();	Tile2D_DrawEntities();#if 0	if(tile2d_player->impulse&BT_IMPULSE_FIRE)	{		i=((int)floor(bt2d_state->time_f*8))&1;		switch(i)		{		case 0: s="sprites/tile2d/player/play_fire1"; break;		case 1: s="sprites/tile2d/player/play_fire2"; break;		}#if 0		i=((int)floor(bt2d_state->time_f*16))&15;		if(!i)		{			tmp=Tile2D_SpawnEntity_Bullet(				v2add(tile2d_player->org, vec2(0, 1.0)),				vec2(10, 0));			tmp->next=tile2d_entity;			tile2d_entity=tmp;		}#endif	}else if(fabs(v2y(tile2d_player->vel))>1.0)	{		i=((int)floor(bt2d_state->time_f*8))&1;		switch(i)		{		case 0: s="sprites/tile2d/player/play_fly1"; break;		case 1: s="sprites/tile2d/player/play_fly2"; break;		}	}else if((fabs(v2x(tile2d_player->vel))>=0.2) &&		(fabs(v2x(tile2d_player->vel))>fabs(v2y(tile2d_player->vel))))	{		if(fabs(v2x(tile2d_player->vel))>=2.0)			{ i=((int)floor(bt2d_state->time_f*8))&3; }		else			{ i=((int)floor(bt2d_state->time_f*4))&3; }//		i=((int)floor(bt2d_state->time_f*v2len(tile2d_player->vel)))&3;//.........这里部分代码省略.........
开发者ID:cr88192,项目名称:bgbtech_engine,代码行数:101,


示例2: init

voidinit( void ){      pointCount = 0;    GLfloat rad45 = DegreesToRadians * 45;        color3 base_colors[5] = {	color3(1.0, 1.0, 1.0),	color3(0.0, 0.0, 0.0),	color3(1.0, 0.0, 0.0),	color3(0.0, 1.0, 0.0),	color3(0.0, 0.0, 1.0),    };    //This paints the squares     vec2 squareBase = vec2(cos(rad45), sin(rad45));    GLfloat size = .85;        //make 6 squares    for(int i = 0; i < 6; i ++) {        color3 color = base_colors[1]; 	if(i % 2 == 0) {	    color = squareColor;	}        points[pointCount] = vec2((squareBase.x * size), ((squareBase.y * size) - .3));        colors[pointCount] = color;	pointCount++;        points[pointCount] = vec2(-(squareBase.x * size), ((squareBase.y * size) - .3));        colors[pointCount] = color;	pointCount++;        points[pointCount] = vec2((squareBase.x * size), -((squareBase.y * size) + .3));        colors[pointCount] = color;	pointCount++;        points[pointCount] = vec2(-(squareBase.x * size), -((squareBase.y * size) + .3));        colors[pointCount] = color;	pointCount++;		size = size - .15;    }         //Ellipse    GLfloat rad360 = DegreesToRadians * 360;    GLfloat rad6 = DegreesToRadians * 6;    GLfloat radius = .9;    GLfloat h2 = 0;    GLfloat k2 = 0;    for(GLfloat i = 0.0; i < rad360; i= i + rad6) {	points[pointCount] = vec2(( h2+(radius*cos(i)) ), ( k2+(radius*sin(i) )) * .6 );        colors[pointCount] = base_colors[2];	pointCount++;    }    //Circle    //rad360 is 2pi    radius = .4;    GLfloat h1 = 0.5;    GLfloat k1 = 0;    //make circle1    for(GLfloat i = 0.0; i < rad360; i= i + rad6) {	points[pointCount] = vec2(( h1+(radius*cos(i)) ), ( k1+(radius*sin(i) )));        colors[pointCount] = magicColor;//base_colors[2];	pointCount++;    }       GLfloat rad90 = DegreesToRadians * 90;    GLfloat rad120 = DegreesToRadians * 120;    radius = .5;    h1 = -0.5;    k1 = 0;    //make triangle    for(GLfloat i = rad90; i < rad360+rad90; i= i + rad120) {	points[pointCount] = vec2(( h1+(radius*cos(i)) ), ( k1+(radius*sin(i) )));        colors[pointCount] = magicColor;	pointCount++;    }    // Create a vertex array object    GLuint vao[1];    glGenVertexArrays( 1, vao );    glBindVertexArray( vao[0] );        // Create and initialize a buffer object    GLuint buffer;    glGenBuffers( 1, &buffer );    glBindBuffer( GL_ARRAY_BUFFER, buffer );    glBufferData( GL_ARRAY_BUFFER, sizeof(points) + sizeof(colors), NULL, GL_STATIC_DRAW );    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(points), points);    glBufferSubData(GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors);    // Load shaders and use the resulting shader program    GLuint program =  InitShader( "vshader21.glsl", "fshader21.glsl" );    glUseProgram( program );    //glLinkProgram(program);    // Initialize the vertex position attribute from the vertex shader    GLuint loc = glGetAttribLocation( program, "vPosition" );    glEnableVertexAttribArray( loc );//.........这里部分代码省略.........
开发者ID:steveacalabro,项目名称:CS432A3,代码行数:101,


示例3: vec2

float normal2::angle( const normal2& n ) const{    float fdot = vec2(_x,_y).dot( vec2(n._x , n._y) );    float res = acos(fdot);    return res;}
开发者ID:yjfcool,项目名称:gbmath,代码行数:6,


示例4: random

void Player::update() {	if(displayHealthTimer >= 0) {		displayHealthTimer -= TIME_STEP;	}	if(invurnabilityTimeout >= 0) {		invurnabilityTimeout -= TIME_STEP;	}	currentWeapon->setPhase(lean*5.0f + random(0.03f*length(velocity)));	//Weapon switching	if(weaponSwitchTimeout > 0) {		weaponSwitchTimeout -= TIME_STEP;		if(currentWeaponIndex != nextWeaponIndex && weaponSwitchTimeout < WEAPON_SWITCH_TIME/2.0f) {			currentWeaponIndex = nextWeaponIndex;			currentWeapon = weaponList[currentWeaponIndex];			//Make sure the next weapon cannot be fired.			currentWeapon->setSwitching(true);		}		currentWeapon->setSwitchRatio(abs((weaponSwitchTimeout-WEAPON_SWITCH_TIME/2.0f)/(WEAPON_SWITCH_TIME/2.0f)));		if(weaponSwitchTimeout <= 0) {			currentWeapon->setSwitching(false);		}	}	//Player movement	float moveAngle = atan2(velocity.y, velocity.x);	float forwardAngle = angle-moveAngle;	float frontMultiplier = cos(forwardAngle);	float frontMultiplierStop = frontMultiplier;	float sinAngle = sin(angle);	float cosAngle = cos(angle);	if(frontMultiplierStop < 0) {		frontMultiplierStop = 0;	}	//Jumping	float jumpHeight = 0.0f;	if(wantsToJump && holdingLeft) {		vec2 direction = normalize(vec2(-sinAngle, cosAngle));		float push = length(velocity) == 0 ? 0 : JUMP_PUSH - 2*JUMP_PUSH*(dot(normalize(velocity), direction));		if(push < 0) {			push = 0;		}		velocity += direction*push;		jumpPhase = PI;		jumpDTime = JUMP_DTIME;		airHeight = JUMP_HEIGHT;	}	else if(wantsToJump && holdingRight) {		vec2 direction = normalize(vec2(sinAngle, -cosAngle));		float push = JUMP_PUSH - 2*JUMP_PUSH*(dot(normalize(velocity), direction));		if(push < 0) {			push = 0;		}		velocity += direction*push;		jumpPhase = PI;		jumpDTime = JUMP_DTIME;		airHeight = JUMP_HEIGHT;	}	else if(wantsToJump) {		jumpPhase = PI;		jumpDTime = JUMP_DTIME;		airHeight = JUMP_HEIGHT;	}	jumping = jumpPhase > 0;	if(jumping) {		jumpPhase -= jumpDTime;		jumpHeight = -sin(jumpPhase)*airHeight;	}	//Ground movement	float friction = FRICTION_BASE + frictionmodifier*frontMultiplier;//.........这里部分代码省略.........
开发者ID:Cheeseness,项目名称:FLAT,代码行数:101,


示例5: vec2

vec2 Player::getPos() {	return vec2(position.x, position.y);}
开发者ID:Cheeseness,项目名称:FLAT,代码行数:3,


示例6: vec2

void Skid::update(Car& car, float dt){	SkidType types[4] {none, none, none, none};	for (int n = 0; n < 4; n++)	{		wett_timer[n] -= dt;		if (car.on_grass[n])		{			wett_timer[n] = wett_time;			if (car.skid_factor > 0.2f)				types[n] = grass;		}		else			if (car.skid_factor > 0.2f)				types[n] = asphalt;		if (types[n] == none && wett_timer[n] > 0)			types[n] = wett;	}	skid_timer += dt;	bool timer_update = false;	if (skid_timer > skid_update_rate)	{		timer_update = true;		skid_timer = 0;	}	for (int n = 0; n < 4; n++)	{		bool force_update = false;		if (types[n] != last_type[n])			force_update == true;		if (force_update || timer_update)		{			if (last_type[n] == none && types[n] == none)			{				skid_pos[n] = car.wheelPos[n];				continue;			}			if (last_type[n] == none)				last_type[n] = types[n];			vec2 dir = car.wheelPos[n] - skid_pos[n];			float len = glm::length(dir);			if (len < 40 && force_update != true)				continue;			if (len > 500)				continue;			skids[skid_current].init(&textures[last_type[n]], skid_pos[n], dir, vec2(len, 1));			if (skid_counter < max_skids)				skid_counter++;			skid_current++;			skid_current = skid_current % max_skids;			skid_pos[n] = car.wheelPos[n];		}		if(types[n] == none)			skid_pos[n] = car.wheelPos[n];		last_type[n] = types[n];	}}
开发者ID:LarssonEmil,项目名称:ThesisRacing,代码行数:74,


示例7: vec2

bool Game::initMenu(){	vec2 windowSize = vec2(300.0f, 240.0f);	menuWindow = new Arya::Window(vec2(0.0f, 0.0f), windowSize * -0.5f, windowSize, 			TextureManager::shared().getTexture("white"), Arya::WINDOW_DRAGGABLE, "Menu",			vec4(0.1f, 0.1f, 0.1f, 1.0f));	Arya::Button* localButton;	Arya::Button* onlineButton;	Arya::Button* mapEditButton;	Arya::Button* settingsButton;	Arya::Button* quitButton;	Arya::Font* f = Arya::FontManager::shared().getFont("DejaVuSans-Bold.ttf");	Texture* t = TextureManager::shared().getTexture("white");	localButton = new Arya::Button(			vec2(-1.0, 1.0), vec2(10.0f, -60.0f), vec2(280.0f, 30.0f),			t, f, "Local", "localButton",		    this, false, vec4(0.5f, 0.5f, 0.5f, 1.0f)			);	menuWindow->addChild(localButton);	onlineButton = new Arya::Button(			vec2(-1.0, 1.0), vec2(10.0f, -100.0f), vec2(280.0f, 30.0f),			t, f, "Online", "onlineButton",		    this, false, vec4(0.5f, 0.5f, 0.5f, 1.0f)			);	menuWindow->addChild(onlineButton);	mapEditButton = new Arya::Button(			vec2(-1.0, 1.0), vec2(10.0f, -140.0f), vec2(280.0f, 30.0f),			t, f, "Map Editor", "mapEditButton",		    this, false, vec4(0.5f, 0.5f, 0.5f, 1.0f)			);	menuWindow->addChild(mapEditButton);	settingsButton = new Arya::Button(			vec2(-1.0, 1.0), vec2(10.0f, -180.0f), vec2(280.0f, 30.0f),			t, f, "Settings", "settingsButton",		    this, false, vec4(0.5f, 0.5f, 0.5f, 1.0f)			);	menuWindow->addChild(settingsButton);	quitButton = new Arya::Button(			vec2(-1.0, 1.0), vec2(10.0f, -220.0f), vec2(280.0f, 30.0f),			t, f, "Exit Game", "quitButton",		    this, false, vec4(0.5f, 0.5f, 0.5f, 1.0f)			);	menuWindow->addChild(quitButton);	Arya::Interface::shared().makeActive(menuWindow);	return true;}
开发者ID:eriklumens,项目名称:Arya,代码行数:55,


示例8: GameServer

void CCharacter::TickDefered(){	// advance the dummy	{		CWorldCore TempWorld;		m_ReckoningCore.Init(&TempWorld, GameServer()->Collision());		m_ReckoningCore.Tick(false);		m_ReckoningCore.Move();		m_ReckoningCore.Quantize();	}	//lastsentcore	vec2 StartPos = m_Core.m_Pos;	vec2 StartVel = m_Core.m_Vel;	bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));	m_Core.Move();	bool StuckAfterMove = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));	m_Core.Quantize();	bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));	m_Pos = m_Core.m_Pos;	if(!StuckBefore && (StuckAfterMove || StuckAfterQuant))	{		// Hackish solution to get rid of strict-aliasing warning		union		{			float f;			unsigned u;		}StartPosX, StartPosY, StartVelX, StartVelY;		StartPosX.f = StartPos.x;		StartPosY.f = StartPos.y;		StartVelX.f = StartVel.x;		StartVelY.f = StartVel.y;		char aBuf[256];		str_format(aBuf, sizeof(aBuf), "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",			StuckBefore,			StuckAfterMove,			StuckAfterQuant,			StartPos.x, StartPos.y,			StartVel.x, StartVel.y,			StartPosX.u, StartPosY.u,			StartVelX.u, StartVelY.u);		GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);	}	int Events = m_Core.m_TriggeredEvents;	int Mask = CmaskAllExceptOne(m_pPlayer->GetCID());	if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Mask);	if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, CmaskAll());	if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Mask);	if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask);	if(m_pPlayer->GetTeam() == TEAM_SPECTATORS)	{		m_Pos.x = m_Input.m_TargetX;		m_Pos.y = m_Input.m_TargetY;	}	IServer::CClientInfo CltInfo;	Server()->GetClientInfo(m_pPlayer->GetCID(), &CltInfo);	// update the m_SendCore if needed	{		CNetObj_Character Predicted;		CNetObj_Character Current;		mem_zero(&Predicted, sizeof(Predicted));		mem_zero(&Current, sizeof(Current));		m_ReckoningCore.Write(&Predicted);		m_Core.Write(&Current);		// only allow dead reackoning for a top of 3 seconds		if(m_ReckoningTick+Server()->TickSpeed()*3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0				|| (m_Core.m_Frozen > 0 && !(Server()->Tick()&1)))		{			m_ReckoningTick = Server()->Tick();			m_SendCore = m_Core;			m_ReckoningCore = m_Core;		}	}}
开发者ID:TsFreddie,项目名称:teeworlds-solofng,代码行数:86,


示例9: update

void Player::update(float dt){    Character::update(dt);    System::camera->setPosition(vec2(getPosition().x / -GlobalData::tilesize,                                     getPosition().y / GlobalData::tilesize) * 10.f);}
开发者ID:Rasie1,项目名称:glowy2d,代码行数:6,


示例10: TakeNinja

void CCharacter::HandleNinja(){	if(m_ActiveWeapon != WEAPON_NINJA)		return;	if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))	{		// time's up, return		TakeNinja();		return;	}	// force ninja Weapon	SetWeapon(WEAPON_NINJA);	m_Ninja.m_CurrentMoveTime--;	if (m_Ninja.m_CurrentMoveTime == 0)	{		// reset velocity		m_Core.m_Vel = m_Ninja.m_ActivationDir*m_Ninja.m_OldVelAmount;	}	if (m_Ninja.m_CurrentMoveTime > 0)	{		// Set velocity		m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;		vec2 OldPos = m_Pos;		GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f);		// reset velocity so the client doesn't predict stuff		m_Core.m_Vel = vec2(0.f, 0.f);		// check if we Hit anything along the way		{			CCharacter *aEnts[MAX_CLIENTS];			vec2 Dir = m_Pos - OldPos;			float Radius = m_ProximityRadius * 2.0f;			vec2 Center = OldPos + Dir * 0.5f;			int Num = GameServer()->m_World.FindEntities(Center, Radius, (CEntity**)aEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);			for (int i = 0; i < Num; ++i)			{				if (aEnts[i] == this)					continue;				// make sure we haven't Hit this object before				bool bAlreadyHit = false;				for (int j = 0; j < m_NumObjectsHit; j++)				{					if (m_apHitObjects[j] == aEnts[i])						bAlreadyHit = true;				}				if (bAlreadyHit)					continue;				// check so we are sufficiently close				if (distance(aEnts[i]->m_Pos, m_Pos) > (m_ProximityRadius * 2.0f))					continue;				// Hit a player, give him damage and stuffs...				GameServer()->CreateSound(aEnts[i]->m_Pos, SOUND_NINJA_HIT);				// set his velocity to fast upward (for now)				if(m_NumObjectsHit < 10)					m_apHitObjects[m_NumObjectsHit++] = aEnts[i];				aEnts[i]->TakeDamage(vec2(0, -10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);			}		}		return;	}	return;}
开发者ID:TsFreddie,项目名称:teeworlds-solofng,代码行数:75,


示例11: DoWeaponSwitch

void CCharacter::FireWeapon(){	if(m_ReloadTimer != 0)		return;	DoWeaponSwitch();	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));	bool FullAuto = false;	if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE || (m_ActiveWeapon == WEAPON_HAMMER && g_Config.m_SvSuperHammer))		FullAuto = true;	// check if we gonna fire	bool WillFire = false;	if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)		WillFire = true;	if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)		WillFire = true;	if (!g_Config.m_SvNinja && m_ActiveWeapon == WEAPON_NINJA)		WillFire = false;	if(!WillFire)		return;	// check for ammo	if(!m_aWeapons[m_ActiveWeapon].m_Ammo)	{		// 125ms is a magical limit of how fast a human can click		m_ReloadTimer = 125 * Server()->TickSpeed() / 1000;		GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO);		return;	}	vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;	switch(m_ActiveWeapon)	{		case WEAPON_HAMMER:		{			// reset objects Hit			m_NumObjectsHit = 0;			GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);			CCharacter *apEnts[MAX_CLIENTS];			int Hits = 0;			int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts,														MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);			for (int i = 0; i < Num; ++i)			{				CCharacter *pTarget = apEnts[i];				if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL))					continue;				// set his velocity to fast upward (for now)				if(length(pTarget->m_Pos-ProjStartPos) > 0.0f)					GameServer()->CreateHammerHit(pTarget->m_Pos-normalize(pTarget->m_Pos-ProjStartPos)*m_ProximityRadius*0.5f);				else					GameServer()->CreateHammerHit(ProjStartPos);				vec2 Dir;				if (length(pTarget->m_Pos - m_Pos) > 0.0f)					Dir = normalize(pTarget->m_Pos - m_Pos);				else					Dir = vec2(0.f, -1.f);				bool MeltHit = GameServer()->m_pController->IsTeamplay() && pTarget->GetPlayer()->GetTeam() == GetPlayer()->GetTeam() && pTarget->GetFreezeTicks() > 0;				vec2 Force = (vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f);				if (!MeltHit)				{					Force.x *= g_Config.m_SvHammerScaleX*0.01f;					Force.y *= g_Config.m_SvHammerScaleY*0.01f;				}				else				{					Force.x *= g_Config.m_SvMeltHammerScaleX*0.01f;					Force.y *= g_Config.m_SvMeltHammerScaleY*0.01f;				}				pTarget->TakeDamage(Force, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon);				Hits++;				pTarget->m_HammeredBy = GetPlayer()->GetCID();				if (MeltHit)				{					pTarget->Freeze(pTarget->GetFreezeTicks() - g_Config.m_SvHammerMelt * Server()->TickSpeed());					if (pTarget->GetFreezeTicks() <= 0)					{						pTarget->m_MoltenBy = m_pPlayer->GetCID();						pTarget->m_MoltenAt = -1; // we don't want the unfreezability to take effect when being molten by hammer					}				}								}//.........这里部分代码省略.........
开发者ID:TsFreddie,项目名称:teeworlds-solofng,代码行数:101,


示例12: vec2

//External operators    friend vec2 operator-(const vec2& rhs)    {        return vec2(rhs) *= -1;    }
开发者ID:azorej,项目名称:zeptotest,代码行数:5,


示例13: str_format

void CMenus::RenderSettingsPlayer(CUIRect MainView){	CUIRect Button;	CUIRect LeftView, RightView;	MainView.VSplitLeft(MainView.w/2, &LeftView, &RightView);    LeftView.HSplitTop(20.0f, &Button, &LeftView);	// render settings	{		char aBuf[128];		LeftView.HSplitTop(20.0f, &Button, &LeftView);		str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));		UI()->DoLabel(&Button, aBuf, 14.0, -1);		Button.VSplitLeft(80.0f, 0, &Button);		Button.VSplitLeft(180.0f, &Button, 0);		static float Offset = 0.0f;		if(DoEditBox(g_Config.m_PlayerName, &Button, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 14.0f, &Offset))			m_NeedSendinfo = true;		// extra spacing		LeftView.HSplitTop(10.0f, 0, &LeftView);		static int s_DynamicCameraButton = 0;		LeftView.HSplitTop(20.0f, &Button, &LeftView);		if(DoButton_CheckBox(&s_DynamicCameraButton, Localize("Dynamic Camera"), g_Config.m_ClMouseDeadzone != 0, &Button))		{			if(g_Config.m_ClMouseDeadzone)			{				g_Config.m_ClMouseFollowfactor = 0;				g_Config.m_ClMouseMaxDistance = 400;				g_Config.m_ClMouseDeadzone = 0;			}			else			{				g_Config.m_ClMouseFollowfactor = 60;				g_Config.m_ClMouseMaxDistance = 1000;				g_Config.m_ClMouseDeadzone = 300;			}		}		LeftView.HSplitTop(20.0f, &Button, &LeftView);		if(DoButton_CheckBox(&g_Config.m_ClAutoswitchWeapons, Localize("Switch weapon on pickup"), g_Config.m_ClAutoswitchWeapons, &Button))			g_Config.m_ClAutoswitchWeapons ^= 1;		LeftView.HSplitTop(20.0f, &Button, &LeftView);		if(DoButton_CheckBox(&g_Config.m_ClNameplates, Localize("Show name plates"), g_Config.m_ClNameplates, &Button))			g_Config.m_ClNameplates ^= 1;		//if(config.cl_nameplates)		{			LeftView.HSplitTop(20.0f, &Button, &LeftView);			Button.VSplitLeft(15.0f, 0, &Button);			if(DoButton_CheckBox(&g_Config.m_ClNameplatesAlways, Localize("Always show name plates"), g_Config.m_ClNameplatesAlways, &Button))				g_Config.m_ClNameplatesAlways ^= 1;		}        {            const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(max(0, m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin)));            CTeeRenderInfo OwnSkinInfo;            OwnSkinInfo.m_Texture = pOwnSkin->m_OrgTexture;            OwnSkinInfo.m_ColorBody = vec4(1, 1, 1, 1);            OwnSkinInfo.m_ColorFeet = vec4(1, 1, 1, 1);            if(g_Config.m_PlayerUseCustomColor)            {                OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);                OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);                OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;            }            OwnSkinInfo.m_Size = UI()->Scale()*50.0f;            LeftView.HSplitTop(20.0f, &Button, &LeftView);            LeftView.HSplitTop(20.0f, &Button, &LeftView);            str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));            UI()->DoLabel(&Button, aBuf, 14.0, -1);            CUIRect SkinRect;            LeftView.VSplitLeft(LeftView.w/1.2f, &SkinRect, 0);            SkinRect.HSplitTop(50.0f, &SkinRect, 0);            RenderTools()->DrawUIRect(&SkinRect, vec4(1, 1, 1, 0.25f), CUI::CORNER_ALL, 10.0f);            Button.VSplitLeft(30.0f, 0, &Button);            Button.HSplitTop(50.0f, 0, &Button);            RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Button.x, Button.y));            LeftView.HSplitTop(20.0f, &Button, &LeftView);            Button.HSplitTop(15.0f, 0, &Button);            Button.VSplitLeft(100.0f, 0, &Button);            str_format(aBuf, sizeof(aBuf), "%s", g_Config.m_PlayerSkin);			CTextCursor Cursor;			TextRender()->SetCursor(&Cursor, Button.x, Button.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);			Cursor.m_LineWidth = SkinRect.w-(Button.x-SkinRect.x)-5.0f;			TextRender()->TextEx(&Cursor, aBuf, -1);//.........这里部分代码省略.........
开发者ID:mahmoudsaeed,项目名称:teeworlds,代码行数:101,


示例14: Processor

AxisAlignedCutPlane::AxisAlignedCutPlane()    : Processor()    , volume_("volume")    , imageInport_("imageInport_")    , outport_("outport")    , xSlide_("x", "X Slide")    , ySlide_("y", "Y Slide")    , zSlide_("z", "Z Slide")    , disableTF_("disableTF", "Disable transfer function", false,                 InvalidationLevel::InvalidResources)    , tf_("transferfunction", "Transfer function", TransferFunction(), &volume_)    , sliceShader_("geometryrendering.vert", "axisalignedcutplaneslice.frag", false)    , boundingBoxShader_("geometryrendering.vert", "axisalignedcutplaneboundingbox.frag")    , showBoundingBox_("boundingBox", "Show Bounding Box", true)    , boundingBoxColor_("boundingBoxColor", "Bounding Box Color", vec4(0.0f, 0.0f, 0.0f, 1.0f))	, renderPointSize_("renderPointSize", "Point Size", 1.0f, 0.001f, 15.0f, 0.001f)	, renderLineWidth_("renderLineWidth", "Line Width", 1.0f, 0.001f, 15.0f, 0.001f)    , nearestInterpolation_("nearestInterpolation", "Use nearest neighbor interpolation", false)    , camera_("camera", "Camera")    , trackball_(&camera_) {    addPort(volume_);    addPort(imageInport_);    addPort(outport_);    addProperty(xSlide_);    addProperty(ySlide_);    addProperty(zSlide_);    addProperty(disableTF_);    addProperty(tf_);    addProperty(showBoundingBox_);	addProperty(boundingBoxColor_);	addProperty(renderPointSize_);	addProperty(renderLineWidth_);    addProperty(camera_);    addProperty(trackball_);    imageInport_.setOptional(true);    tf_.get().clearPoints();    tf_.get().addPoint(vec2(0.0f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f));    tf_.get().addPoint(vec2(1.0f, 1.0f), vec4(1.0f, 1.0f, 1.0f, 1.0f));    tf_.setCurrentStateAsDefault();    xSlide_.onChange([&]() {        if (volume_.hasData()) xSlide_.createDrawer(volume_.getData());    });    ySlide_.onChange([&]() {        if (volume_.hasData()) ySlide_.createDrawer(volume_.getData());    });    zSlide_.onChange([&]() {        if (volume_.hasData()) zSlide_.createDrawer(volume_.getData());    });    volume_.onChange([&]() {        if (!volume_.hasData()) return;        auto vol = volume_.getData();        xSlide_.onVolumeChange(vol);        ySlide_.onVolumeChange(vol);        zSlide_.onVolumeChange(vol);        if (!boundingBoxMesh_) {            createBoundingBox();        }        boundingBoxMesh_->setModelMatrix(vol->getModelMatrix());        boundingBoxMesh_->setWorldMatrix(vol->getWorldMatrix());    });    boundingBoxColor_.setSemantics(PropertySemantics::Color);    setAllPropertiesCurrentStateAsDefault();    createBoundingBox();}
开发者ID:ResearchDaniel,项目名称:inviwo,代码行数:75,


示例15: Client

//.........这里部分代码省略.........            rHeadLines.VSplitLeft(80.0f, &rLabel, &rHeadLines);            TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Ping"), -1);            int corner = 0;            if (part==0) corner = CUI::CORNER_BL;            else if (part==3) corner = CUI::CORNER_BR;            vec4 baColor = HexToVec4(g_Config.m_hcContainerBackgroundColor);            RenderTools()->DrawUIRect(&parts[part], vec4(baColor.r, baColor.g, baColor.b, part%2==0?0.5f:0.65f), corner, 10.0f);            fi = true;	    }		// make sure that we render the correct team		const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByDDTeam[i];		if(!pInfo)			continue;        nPlayers++;		// background so it's easy to find the local player or the followed one in spectator mode		if(pInfo->m_Local || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID))		{			Graphics()->TextureSet(-1);			Graphics()->QuadsBegin();			Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);			RenderTools()->DrawRoundRectExt(x, y, parts[part].w, LineHeight, 0.0f, 0);			Graphics()->QuadsEnd();		}		// score		if(isDDRace)		{			if (pInfo->m_Score == -9999)				str_copy(aBuf, "
C++ vec2d函数代码示例
C++ vec1函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。