Beispiel #1
0
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;
		switch(i)
		{
		case 0: s="sprites/tile2d/player/play_0"; break;
		case 1: s="sprites/tile2d/player/play_1"; break;
		case 2: s="sprites/tile2d/player/play_2"; break;
		case 3: s="sprites/tile2d/player/play_3"; break;
		}
	}else
	{
		s="sprites/tile2d/player/play_idle1";
	}
	
	tex=LBXGL_Texture_LoadImage(s);
	LBXGL_Shader_BindTexture(tex);

	x=v2x(tile2d_player->org);
	y=v2y(tile2d_player->org);

//	x=0; y=5;

	if(v2x(tile2d_player->vel)>=0)
	{
		LBXGL_Shader_Begin(PDGL_QUADS);
		LBXGL_Shader_TexCoord2f(1, 0);
		LBXGL_Shader_Vertex3f(x, 0, y);

		LBXGL_Shader_TexCoord2f(0, 0);
		LBXGL_Shader_Vertex3f(x+2, 0, y);

		LBXGL_Shader_TexCoord2f(0, 1);
		LBXGL_Shader_Vertex3f(x+2, 0, y+2);

		LBXGL_Shader_TexCoord2f(1, 1);
		LBXGL_Shader_Vertex3f(x, 0, y+2);
		LBXGL_Shader_End();
	}else
	{
		LBXGL_Shader_Begin(PDGL_QUADS);
		LBXGL_Shader_TexCoord2f(0, 0);
		LBXGL_Shader_Vertex3f(x, 0, y);

		LBXGL_Shader_TexCoord2f(1, 0);
		LBXGL_Shader_Vertex3f(x+2, 0, y);

		LBXGL_Shader_TexCoord2f(1, 1);
		LBXGL_Shader_Vertex3f(x+2, 0, y+2);

		LBXGL_Shader_TexCoord2f(0, 1);
		LBXGL_Shader_Vertex3f(x, 0, y+2);
		LBXGL_Shader_End();
	}
#endif

	LBXGL_Shader_BindTexture(-1);
	pdglDisableTexture2D();
}
Beispiel #2
0
void
init( 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 );
    glVertexAttribPointer( loc, 2, GL_FLOAT, GL_FALSE, 0,
                           BUFFER_OFFSET(0) );

    GLuint loc2 = glGetAttribLocation(program, "vColor");
    glEnableVertexAttribArray(loc2);
    glVertexAttribPointer(loc2, 3, GL_FLOAT, GL_FALSE, 0,
			  BUFFER_OFFSET(sizeof(points)));

    glutSetWindow(mainWindow);
    glClearColor( 0, 0, 0, 0 ); // black background

    glutSetWindow(subWindow);
    glClearColor(1, 1, 1, 1);
    
    glutSetWindow(secondWindow);
    glClearColor( 0, 0, 0, 0 ); // black background
}
Beispiel #3
0
float normal2::angle( const normal2& n ) const
{
    float fdot = vec2(_x,_y).dot( vec2(n._x , n._y) );
    float res = acos(fdot);
    return res;
}
Beispiel #4
0
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;

	if(jumping) {
		friction = 0.99f;
	}

	if(leanmodifier < 0 && lastDir == 1) {
		al_play_sample(skateSound, 0.8f, -1.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, NULL);
	}

	if(leanmodifier > 0 && lastDir == -1) {
		al_play_sample(skateSound, 0.8f, 1.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, NULL);
	}

	if(leanmodifier < 0) {
		lastDir = -1;
	}

	if(leanmodifier > 0) {
		lastDir = 1;
	}

	lean += leanmodifier;

	if((leanmodifier > 0.0f && lean < 0.3f) || (leanmodifier < 0.0f && lean > -0.3f)) {
		float absLean = (0.75f+0.25f*frontMultiplierStop*length(velocity))*lean*lean;

		//Allow acceleration backwards if holding S.
		if(holdingBack) {
			absLean *= -SPEED_BACKWARDS_MULTIPLIER;
		}

		velocity += vec2(cosAngle*SPEED*absLean, sinAngle*SPEED*absLean);
	}

	//Carving:
	//float carvingAngle = moveAngle+lean*0.01f;
	float carvingAngle = moveAngle + PI/2;
	float carvingSpeed = length(velocity)*lean*SPEED_CARVING*frontMultiplier;

	float deadzoneFrontMultiplier = frontMultiplier;

	if(deadzoneFrontMultiplier > 0.9f) {
		deadzoneFrontMultiplier = 1.0f;
	}

	float dLean = abs(leanmodifier*sin(lean*5.2f));

	//Print("l: ", dLean*abs(sin(lean*5.2f)));

	velocity += vec2(cos(carvingAngle)*carvingSpeed+deadzoneFrontMultiplier*cosAngle*abs(carvingSpeed)/4.0f, sin(carvingAngle)*carvingSpeed+deadzoneFrontMultiplier*sinAngle*abs(carvingSpeed)/4.0f);

	lean *= LEAN_DRAG;

	tilt = 0.5*lean;

	velocity *= friction;

	height += HEIGHT_ACCELERATE_AMMOUNT*frictionmodifier*frontMultiplier;

	height *= HEIGHT_DRAG;

	leanmodifier = 0.0f;
	frictionmodifier = 0.0f;

	holdingBack = false;

	velocity.x -= currentWeapon->kb*cosAngle;
	velocity.y -= currentWeapon->kb*sinAngle;

	position.x += velocity.x;
	position.y += velocity.y;
	position.z = height + jumpHeight + abs(tilt) - CHARACTER_HEIGHT;



	if(passingOut) {
		displayHealthTimer = 9999;

		loseTimer -= TIME_STEP;

		position.z += ((LOSE_TIME-loseTimer)/LOSE_TIME)*2.0f;

		if(loseTimer <= 0 && !gameOver) {
			gameOver = true;
			Print("Game over!");
		}
	}



	firing = currentWeapon->firing;

	currentWeapon->update();

	wantsToJump = false;
	holdingLeft = false;
	holdingRight = false;

	leanmodifier = 0.0f;

	time += TIME_STEP;

	healthCD -= TIME_STEP;
}
Beispiel #5
0
vec2 Player::getPos() {
	return vec2(position.x, position.y);
}
Beispiel #6
0
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];
	}
}
Beispiel #7
0
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;
}
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;
		}
	}
}
Beispiel #9
0
void Player::update(float dt)
{
    Character::update(dt);
    System::camera->setPosition(vec2(getPosition().x / -GlobalData::tilesize,
                                     getPosition().y / GlobalData::tilesize) * 10.f);
}
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;
}
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
					}
				}
					
			}

			// if we Hit anything, we have to wait for the reload
			if(Hits)
				m_ReloadTimer = Server()->TickSpeed()/3;

		} break;

		case WEAPON_GUN:
		{
			CProjectile *pProj = new CProjectile(GameWorld(), WEAPON_GUN,
				m_pPlayer->GetCID(),
				ProjStartPos,
				Direction,
				(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
				1, 0, 0, -1, WEAPON_GUN);

			// pack the Projectile and send it to the client Directly
			CNetObj_Projectile p;
			pProj->FillInfo(&p);

			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
			Msg.AddInt(1);
			for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
				Msg.AddInt(((int *)&p)[i]);

			Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());

			GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
		} break;

		case WEAPON_SHOTGUN:
		{
			int ShotSpread = 2;

			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
			Msg.AddInt(ShotSpread*2+1);

			for(int i = -ShotSpread; i <= ShotSpread; ++i)
			{
				float Spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
				float a = GetAngle(Direction);
				a += Spreading[i+2];
				float v = 1-(absolute(i)/(float)ShotSpread);
				float Speed = mix((float)GameServer()->Tuning()->m_ShotgunSpeeddiff, 1.0f, v);
				CProjectile *pProj = new CProjectile(GameWorld(), WEAPON_SHOTGUN,
					m_pPlayer->GetCID(),
					ProjStartPos,
					vec2(cosf(a), sinf(a))*Speed,
					(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_ShotgunLifetime),
					1, 0, 0, -1, WEAPON_SHOTGUN);

				// pack the Projectile and send it to the client Directly
				CNetObj_Projectile p;
				pProj->FillInfo(&p);

				for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
					Msg.AddInt(((int *)&p)[i]);
			}

			Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());

			GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);
		} break;

		case WEAPON_GRENADE:
		{
			CProjectile *pProj = new CProjectile(GameWorld(), WEAPON_GRENADE,
				m_pPlayer->GetCID(),
				ProjStartPos,
				Direction,
				(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime),
				1, true, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);

			// pack the Projectile and send it to the client Directly
			CNetObj_Projectile p;
			pProj->FillInfo(&p);

			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
			Msg.AddInt(1);
			for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
				Msg.AddInt(((int *)&p)[i]);
			Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());

			GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
		} break;

		case WEAPON_RIFLE:
		{
			new CLaser(GameWorld(), m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID());
			GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
		} break;

		case WEAPON_NINJA:
		{
			// reset Hit objects
			m_NumObjectsHit = 0;

			m_Ninja.m_ActivationDir = Direction;
			m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000;
			m_Ninja.m_OldVelAmount = length(m_Core.m_Vel);

			GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE);
		} break;

	}

	m_AttackTick = Server()->Tick();

	if (!g_Config.m_SvUnlimitedAmmo && m_aWeapons[m_ActiveWeapon].m_Ammo > 0)
		m_aWeapons[m_ActiveWeapon].m_Ammo--;

	if(!m_ReloadTimer)
		m_ReloadTimer = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Firedelay * Server()->TickSpeed() / 1000;
}
Beispiel #12
0
//External operators
    friend vec2 operator-(const vec2& rhs)
    {
        return vec2(rhs) *= -1;
    }
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);
        }

		RightView.HSplitTop(20.0f, &Button, &RightView);
		RightView.HSplitTop(20.0f, &Button, &RightView);

		if(DoButton_CheckBox(&g_Config.m_PlayerColorBody, Localize("Custom colors"), g_Config.m_PlayerUseCustomColor, &Button))
		{
			g_Config.m_PlayerUseCustomColor = g_Config.m_PlayerUseCustomColor?0:1;
			m_NeedSendinfo = true;
		}

		if(g_Config.m_PlayerUseCustomColor)
		{
			int *paColors[2];
			paColors[0] = &g_Config.m_PlayerColorBody;
			paColors[1] = &g_Config.m_PlayerColorFeet;

			const char *paParts[] = {
				Localize("Body"),
				Localize("Feet")};
			const char *paLabels[] = {
				Localize("Hue"),
				Localize("Sat."),
				Localize("Lht.")};
			static int s_aColorSlider[2][3] = {{0}};
			//static float v[2][3] = {{0, 0.5f, 0.25f}, {0, 0.5f, 0.25f}};

			for(int i = 0; i < 2; i++)
			{
				CUIRect Text;
				RightView.HSplitTop(20.0f, &Text, &RightView);
				Text.VSplitLeft(15.0f, 0, &Text);
				UI()->DoLabel(&Text, paParts[i], 14.0f, -1);

				int PrevColor = *paColors[i];
				int Color = 0;
				for(int s = 0; s < 3; s++)
				{
					CUIRect Text;
					RightView.HSplitTop(19.0f, &Button, &RightView);
					Button.VSplitLeft(30.0f, 0, &Button);
					Button.VSplitLeft(70.0f, &Text, &Button);
					Button.VSplitRight(5.0f, &Button, 0);
					Button.HSplitTop(4.0f, 0, &Button);

					float k = ((PrevColor>>((2-s)*8))&0xff)  / 255.0f;
					k = DoScrollbarH(&s_aColorSlider[i][s], &Button, k);
					Color <<= 8;
					Color += clamp((int)(k*255), 0, 255);
					UI()->DoLabel(&Text, paLabels[s], 15.0f, -1);

				}

				if(*paColors[i] != Color)
					m_NeedSendinfo = true;

				*paColors[i] = Color;
				RightView.HSplitTop(5.0f, 0, &RightView);
			}
		}

        MainView.HSplitTop(MainView.h/2, 0, &MainView);

		// render skinselector
		static bool s_InitSkinlist = true;
		static sorted_array<const CSkins::CSkin *> s_paSkinList;
		static float s_ScrollValue = 0;
		if(s_InitSkinlist)
		{
			s_paSkinList.clear();
			for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i)
			{
				const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
				// no special skins
				if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
					continue;
				s_paSkinList.add(s);
			}
			s_InitSkinlist = false;
		}

		int OldSelected = -1;
		UiDoListboxStart(&s_InitSkinlist, &MainView, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue);

		for(int i = 0; i < s_paSkinList.size(); ++i)
		{
			const CSkins::CSkin *s = s_paSkinList[i];
			if(s == 0)
				continue;

			if(str_comp(s->m_aName, g_Config.m_PlayerSkin) == 0)
				OldSelected = i;

			CListboxItem Item = UiDoListboxNextItem(&s_paSkinList[i], OldSelected == i);
			if(Item.m_Visible)
			{
				CTeeRenderInfo Info;
				Info.m_Texture = s->m_OrgTexture;
				Info.m_ColorBody = vec4(1, 1, 1, 1);
				Info.m_ColorFeet = vec4(1, 1, 1, 1);

				if(g_Config.m_PlayerUseCustomColor)
				{
					Info.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);
					Info.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);
					Info.m_Texture = s->m_ColorTexture;
				}

				Info.m_Size = UI()->Scale()*50.0f;
				Item.m_Rect.HSplitTop(5.0f, 0, &Item.m_Rect); // some margin from the top
				RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, 0, vec2(1, 0), vec2(Item.m_Rect.x+Item.m_Rect.w/2, Item.m_Rect.y+Item.m_Rect.h/2));

				if(g_Config.m_Debug)
				{
					vec3 BloodColor = g_Config.m_PlayerUseCustomColor ? m_pClient->m_pSkins->GetColorV3(g_Config.m_PlayerColorBody) : s->m_BloodColor;
					Graphics()->TextureSet(-1);
					Graphics()->QuadsBegin();
					Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f);
					IGraphics::CQuadItem QuadItem(Item.m_Rect.x, Item.m_Rect.y, 12, 12);
					Graphics()->QuadsDrawTL(&QuadItem, 1);
					Graphics()->QuadsEnd();
				}
			}
		}

		const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
		if(OldSelected != NewSelected)
		{
			mem_copy(g_Config.m_PlayerSkin, s_paSkinList[NewSelected]->m_aName, sizeof(g_Config.m_PlayerSkin));
			m_NeedSendinfo = true;
		}
	}
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();

}
Beispiel #15
0
void CScoreboard::RenderScoreboard64(float x, float y, float w, int Team, const char *pTitle)
{
	if(Team == TEAM_SPECTATORS)
		return;

    bool isDDRace = Client()->IsServerType("ddrace");

    float h = 760.0f;
	CUIRect area;
	area.x = x; area.y = y;
	area.w = w; area.h = h;

	Graphics()->BlendNormal();
	Graphics()->TextureSet(-1);

	// render title
	CUIRect rTitle;
	area.HSplitTop(60.0f, &rTitle, &area);
	float TitleFontsize = 40.0f;

    if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
        pTitle = Localize("Game over");
    else
        pTitle = Localize("Score board");

    RenderTools()->DrawUIRect(&rTitle, HexToVec4(g_Config.m_hcContainerHeaderBackgroundColor), CUI::CORNER_T, 10.0f);


	rTitle.Margin(10.0f, &rTitle);

	char aBuf[128] = {0};
    if(m_pClient->m_Snap.m_pGameDataObj)
    {
        int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue;
        str_format(aBuf, sizeof(aBuf), "%d", Score);
    }

	float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
	CUIRect rTitlePoints;
	rTitle.VSplitRight(tw+5.0f, 0x0, &rTitlePoints);
	TextRender()->Text(0, rTitlePoints.x, rTitlePoints.y-5.0f, TitleFontsize, aBuf, -1);

    float LineHeight = 40.0f;
    float TeeSizeMod = 0.4f;
    float Spacing = 0.0f;
    float HeadlineFontsize = 12.0f;
    float FontSize = 14.0f;
    int part = 0;
    CTextCursor Cursor;

    CUIRect parts[4];
    area.VSplitMid(&parts[0], &parts[2]);
    parts[0].VSplitMid(&parts[0], &parts[1]);
    parts[2].VSplitMid(&parts[2], &parts[3]);

    float ScoreOffset, ScoreLength;
    float TeeOffset, TeeLength;
    float NameOffset, NameLength;
    float PingOffset, PingLength;
    float CountryOffset, CountryLength;
    float ClanOffset, ClanLength;

    int nPlayers = 0;
    bool fi = false;
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
	    if (!fi || (i%16) == 0)
	    {
	        if (fi)
                part++;

            x = parts[part].x;
            y = parts[part].y;

	        ScoreOffset = x+10.0f; ScoreLength = 60.0f;
            TeeOffset = parts[part].x+90.0f; TeeLength = 60*TeeSizeMod;
            NameOffset = TeeOffset+TeeLength; NameLength = 200.0f-TeeLength;
            PingOffset = x+390.0f; PingLength = 65.0f;
            CountryOffset = PingOffset-(LineHeight-Spacing-TeeSizeMod); CountryLength = (LineHeight-Spacing-TeeSizeMod*3.0f)*2.0f;
            ClanOffset = x+230.0f; ClanLength = 230.0f-CountryLength;

            // render headlines
            CUIRect rHeadLines, rLabel;
            parts[part].HSplitTop(40.0f, &rHeadLines, &parts[part]);
            RenderTools()->DrawUIRect(&rHeadLines, HexToVec4(g_Config.m_hcListHeaderBackgroundColor), 0, 0.0f);
            rHeadLines.Margin(5.0f,&rHeadLines);

            y += 50.0f;

            rHeadLines.VSplitLeft(80.0f, &rLabel, &rHeadLines);
            TextRender()->Text(0, rLabel.x + 20.0f, rLabel.y, HeadlineFontsize, Localize(isDDRace?"Time":"Score"), -1);

            rHeadLines.VSplitLeft(200.0f, &rLabel, &rHeadLines);
            TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Name"), -1);

            rHeadLines.VSplitLeft(150.0f, &rLabel, &rHeadLines);
            TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Clan"), -1);

            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, "––:––", sizeof(aBuf));
			else
			{
				int Time = abs(pInfo->m_Score);
				str_format(aBuf, sizeof(aBuf), "%02d:%02d", Time/60, Time%60);
			}
		}
		else
			str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 999));

		tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
		TextRender()->SetCursor(&Cursor, ScoreOffset+ScoreLength-tw, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = ScoreLength;
		TextRender()->TextEx(&Cursor, aBuf, -1);

		// avatar
		CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo;
		TeeInfo.m_Size *= TeeSizeMod;
		RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(TeeOffset+TeeLength/2, y+LineHeight/2-3.0f));

		// name
        if (g_Config.m_hcColorClan && m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aClan[0] != 0 && str_comp_nocase(m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aClan) == 0) //H-Client
            TextRender()->TextColor(0.7f, 0.7f, 0.2f, 1.0f);
		TextRender()->SetCursor(&Cursor, NameOffset, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = NameLength;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

		// clan
		tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
		TextRender()->SetCursor(&Cursor, ClanOffset+ClanLength/2-tw/2-5.0f, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = ClanLength;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);

		// country flag
		Graphics()->TextureSet(m_pClient->m_pCountryFlags->GetByCountryCode(m_pClient->m_aClients[pInfo->m_ClientID].m_Country)->m_Texture);
		Graphics()->QuadsBegin();
		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
		IGraphics::CQuadItem QuadItem(CountryOffset, y+(Spacing+TeeSizeMod*5.0f)/2.0f, CountryLength, LineHeight-Spacing-TeeSizeMod*5.0f);
		Graphics()->QuadsDrawTL(&QuadItem, 1);
		Graphics()->QuadsEnd();

		// ping
        //H-Client
        const int maxLatency = 200;
        vec3 Rgb =  HslToRgb(vec3(1.0f, 1.0f, 0.5f));
        if (pInfo->m_Latency <= maxLatency)
            Rgb = HslToRgb(vec3((((maxLatency - pInfo->m_Latency) * 0.35f) / maxLatency), 1.0f, 0.5f));
        TextRender()->TextColor(Rgb.r, Rgb.g, Rgb.b, 1.0f);
        //

		str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 1000));
		tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
		TextRender()->SetCursor(&Cursor, PingOffset+PingLength-tw, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = PingLength;
		TextRender()->TextEx(&Cursor, aBuf, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

		y += LineHeight+Spacing;
	}

	//Title
    char aTitle[128]={0};
    str_format(aTitle, sizeof(aTitle), "%s [%d]", pTitle, nPlayers);
	TextRender()->Text(0, rTitle.x, rTitle.y-5.0f, TitleFontsize, aTitle, -1);
}
Beispiel #16
0
void appl::TestLabel::onReceiveMessage(const ewol::object::Message& _msg) {
    ewol::widget::Sizer::onReceiveMessage(_msg);
    //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
    if (m_testWidget == _msg.getCaller()) {
        APPL_WARNING("Receive Event from tested Button ... : " << _msg );
    }
    if (_msg.getMessage() == l_eventChangeExpendX) {
        if (nullptr!=m_testWidget) {
            if (_msg.getData()=="true") {
                m_testWidget->setExpand(bvec2(true,m_testWidget->getExpand().y()));
            } else {
                m_testWidget->setExpand(bvec2(true,m_testWidget->getExpand().y()));
            }
        }
    } else if (_msg.getMessage() == l_eventChangeExpendY) {
        if (nullptr!=m_testWidget) {
            if (_msg.getData()=="true") {
                m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(),true));
            } else {
                m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(),false));
            }
        }
    } else if (_msg.getMessage() == l_eventChangeFillX) {
        if (nullptr!=m_testWidget) {
            if (_msg.getData()=="true") {
                m_testWidget->setFill(bvec2(true,m_testWidget->getFill().y()));
            } else {
                m_testWidget->setFill(bvec2(false,m_testWidget->getFill().y()));
            }
        }
    } else if (_msg.getMessage() == l_eventChangeFillY) {
        if (nullptr!=m_testWidget) {
            if (_msg.getData()=="true") {
                m_testWidget->setFill(bvec2(m_testWidget->getFill().x(),true));
            } else {
                m_testWidget->setFill(bvec2(m_testWidget->getFill().x(),false));
            }
        }
    } else if (_msg.getMessage() == l_eventChangeMaxSize) {
        if (nullptr!=m_testWidget) {
            if (_msg.getData()=="true") {
                m_testWidget->setMaxSize(vec2(400,9999999999));
            } else {
                m_testWidget->setNoMaxSize();
            }
        }
    } else if (_msg.getMessage() == l_eventChangeLabel) {
        if (nullptr!=m_testWidget) {
            m_labelId++;
            switch(m_labelId)
            {
            default:
                m_labelId=0;
            case 0:
                m_testWidget->setLabel("Basic label");
                break;
            case 1:
                m_testWidget->setLabel("Basic <bold>label</bold>");
                break;
            case 2:
                m_testWidget->setLabel("<center>\n"
                                       "	Un jour Cosette se <b>regarda</b> par hasard dans son miroir et se dit: Tiens! <b>Il lui semblait presque <i>qu'elle était jolie.</i></b> Ceci la jeta dans un trouble singulier. <font color=\"#FF0000\">Jusqu'à ce moment elle <b>n'avait</b> point <i>songé</i> à sa figure.</font> Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide;<br/> Jean Valjean seul disait doucement : <br/> Mais non!<br/>  mais non!<br/>  Quoi qu'il en fut, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n"
                                       "</center>\n");
                break;
            case 3:
                m_testWidget->setLabel("<left>\n"
                                       "	Un jour Cosette se <b>regarda</b> par hasard dans son miroir et se dit: Tiens! <b>Il lui semblait presque <i>qu'elle était jolie.</i></b> Ceci la jeta dans un trouble singulier. <font color=\"#0F0\">Jusqu'à ce moment elle <b>n'avait</b> point <i>songé</i> à sa figure.</font> Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide;<br/> Jean Valjean seul disait doucement :<br/>  Mais non!<br/>  mais non!<br/>  Quoi qu'il en fut, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n"
                                       "</left>\n");
                break;
            case 4:
                m_testWidget->setLabel("<right>\n"
                                       "	Un jour Cosette se <b>regarda</b> par hasard dans son miroir et se dit: Tiens! <b>Il lui semblait presque <i>qu'elle était jolie.</i></b> Ceci la jeta dans un trouble singulier. <font color=\"#00F\">Jusqu'à ce moment elle<b> n'avait</b> point <i>songé</i> à sa figure.</font> Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide;<br/> Jean Valjean seul disait doucement :<br/>  Mais non! <br/> mais non!<br/>  Quoi qu'il en fut, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n"
                                       "</right>\n");
                break;
            case 5:
                m_testWidget->setLabel("<justify>\n"
                                       "	Un jour Cosette se <b>regarda</b> par hasard dans son miroir et se dit: Tiens! <b>Il lui semblait presque <i>qu'elle était jolie.</i></b> Ceci la jeta dans un trouble singulier. <font color=\"#FF0\">Jusqu'à ce moment elle <b>n'avait</b> point <i>songé</i> à sa figure.</font> Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide;<br/> Jean Valjean seul disait doucement :<br/>  Mais non!<br/>  mais non!<br/>  Quoi qu'il en fut, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n"
                                       "</justify>\n");
                break;
            }
        }
    }

    return;
}
Beispiel #17
0
void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const char *pTitle)
{
	if(Team == TEAM_SPECTATORS)
		return;

    float h = 430.0f;

    if(!pTitle)
        h = 760.0f;
	CUIRect area;
	area.x = x; area.y = y;
	area.w = w; area.h = h;

	Graphics()->BlendNormal();
	Graphics()->TextureSet(-1);

	// render title
	CUIRect rTitle;
	area.HSplitTop(60.0f, &rTitle, &area);
	float TitleFontsize = 40.0f;
	if(!pTitle)
	{
		if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
			pTitle = Localize("Game over");
		else
			pTitle = Localize("Score board");

        RenderTools()->DrawUIRect(&rTitle, HexToVec4(g_Config.m_hcContainerHeaderBackgroundColor), CUI::CORNER_T, 10.0f);
	}
	else
	{
	    if (Team == TEAM_RED)
            RenderTools()->DrawUIRect(&rTitle, vec4(1.0f, 0.0f, 0.0f, 0.5f), CUI::CORNER_T, 10.0f);
	    if (Team == TEAM_BLUE)
            RenderTools()->DrawUIRect(&rTitle, vec4(0.0f, 0.0f, 1.0f, 0.5f), CUI::CORNER_T, 10.0f);
	}

	rTitle.Margin(10.0f, &rTitle);

	char aBuf[128] = {0};
	if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS)
	{
		if(m_pClient->m_Snap.m_pGameDataObj)
		{
			int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue;
			str_format(aBuf, sizeof(aBuf), "%d", Score);
		}
	}
	else
	{
		if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW &&
			m_pClient->m_Snap.m_paPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID])
		{
			int Score = m_pClient->m_Snap.m_paPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID]->m_Score;
			str_format(aBuf, sizeof(aBuf), "%d", Score);
		}
		else if(m_pClient->m_Snap.m_pLocalInfo)
		{
			int Score = m_pClient->m_Snap.m_pLocalInfo->m_Score;
			str_format(aBuf, sizeof(aBuf), "%d", Score);
		}
	}
	float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
	CUIRect rTitlePoints;
	rTitle.VSplitRight(tw+5.0f, 0x0, &rTitlePoints);
	TextRender()->Text(0, rTitlePoints.x, rTitlePoints.y-5.0f, TitleFontsize, aBuf, -1);

	// calculate measurements
	x += 10.0f;

    float LineHeight = 40.0f;
    float TeeSizeMod = 0.8f;
    float Spacing = 0.0f;

	float ScoreOffset = x+10.0f, ScoreLength = 60.0f;
	float TeeOffset = area.x+90.0f, TeeLength = 60*TeeSizeMod;
	float NameOffset = TeeOffset+TeeLength, NameLength = 300.0f-TeeLength;
	float PingOffset = x+610.0f, PingLength = 65.0f;
	float CountryOffset = PingOffset-(LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f, CountryLength = (LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f;
	float ClanOffset = x+370.0f, ClanLength = 230.0f-CountryLength;

	// render headlines
	CUIRect rHeadLines, rLabel;
	area.HSplitTop(40.0f, &rHeadLines, &area);
	RenderTools()->DrawUIRect(&rHeadLines, HexToVec4(g_Config.m_hcListHeaderBackgroundColor), 0, 0.0f);
	rHeadLines.Margin(5.0f,&rHeadLines);

	y += 50.0f;
	float HeadlineFontsize = 22.0f;

	rHeadLines.VSplitLeft(90.0f, &rLabel, &rHeadLines);
	TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Score"), -1);

    rHeadLines.VSplitLeft(335.0f, &rLabel, &rHeadLines);
	TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Name"), -1);

    rHeadLines.VSplitLeft(210.0f, &rLabel, &rHeadLines);
	TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Clan"), -1);

    rHeadLines.VSplitLeft(80.0f, &rLabel, &rHeadLines);
	TextRender()->Text(0, rLabel.x, rLabel.y, HeadlineFontsize, Localize("Ping"), -1);

    RenderTools()->DrawUIRect(&area, HexToVec4(g_Config.m_hcContainerBackgroundColor), CUI::CORNER_B, 10.0f);

	// render player entries
	float FontSize = 24.0f;
	CTextCursor Cursor;

	x = area.x;
	y = area.y;

    int nPlayers = 0;
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		// make sure that we render the correct team
		const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByScore[i];
		if(!pInfo || pInfo->m_Team != Team)
			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, w, LineHeight, 0.0f, 0);
			Graphics()->QuadsEnd();
		}

		// score
		str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 999));
		tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
		TextRender()->SetCursor(&Cursor, ScoreOffset+ScoreLength-tw, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = ScoreLength;
		TextRender()->TextEx(&Cursor, aBuf, -1);

		// flag
		if ((m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_FLAGS) &&
			m_pClient->m_Snap.m_pGameDataObj && (m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierRed == pInfo->m_ClientID ||
			m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue == pInfo->m_ClientID))
		{
			Graphics()->BlendNormal();
			Graphics()->TextureSet(g_pData->m_aImages[IMAGE_FLAGS].m_Id);
			Graphics()->QuadsBegin();

			RenderTools()->SelectSprite(pInfo->m_Team==TEAM_RED ? SPRITE_FLAG_BLUE03 : SPRITE_FLAG_RED03, SPRITE_FLAG_FLIP_X);

			float Size = LineHeight;
			IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f+1.0f, Size/2.0f, Size);
			Graphics()->QuadsDrawTL(&QuadItem, 1);
			Graphics()->QuadsEnd();
		}

		// avatar
		CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo;
		TeeInfo.m_Size *= TeeSizeMod;
		RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(TeeOffset+TeeLength/2, y+LineHeight/2+1.0f));

		// name
        if (g_Config.m_hcColorClan && m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aClan[0] != 0 && str_comp_nocase(m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aClan) == 0) //H-Client
            TextRender()->TextColor(0.7f, 0.7f, 0.2f, 1.0f);
		TextRender()->SetCursor(&Cursor, NameOffset, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = NameLength;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

		// clan
		tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
		TextRender()->SetCursor(&Cursor, ClanOffset+ClanLength/2-tw/2-5.0f, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = ClanLength;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);

		// country flag
		Graphics()->TextureSet(m_pClient->m_pCountryFlags->GetByCountryCode(m_pClient->m_aClients[pInfo->m_ClientID].m_Country)->m_Texture);
		Graphics()->QuadsBegin();
		Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
		IGraphics::CQuadItem QuadItem(CountryOffset, y+(Spacing+TeeSizeMod*5.0f)/2.0f, CountryLength, LineHeight-Spacing-TeeSizeMod*5.0f);
		Graphics()->QuadsDrawTL(&QuadItem, 1);
		Graphics()->QuadsEnd();

		// ping
        //H-Client
        const int maxLatency = 200;
        vec3 Rgb =  HslToRgb(vec3(1.0f, 1.0f, 0.5f));
        if (pInfo->m_Latency <= maxLatency)
            Rgb = HslToRgb(vec3((((maxLatency - pInfo->m_Latency) * 0.35f) / maxLatency), 1.0f, 0.5f));
        TextRender()->TextColor(Rgb.r, Rgb.g, Rgb.b, 1.0f);
        //

		str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 1000));
		tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
		TextRender()->SetCursor(&Cursor, PingOffset+PingLength-tw, y+Spacing+3.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = PingLength;
		TextRender()->TextEx(&Cursor, aBuf, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

		y += LineHeight+Spacing;
	}

	//Title
    char aTitle[128]={0};
    str_format(aTitle, sizeof(aTitle), "%s [%d]", pTitle, nPlayers);
	TextRender()->Text(0, rTitle.x, rTitle.y-5.0f, TitleFontsize, aTitle, -1);
}
Beispiel #18
0
void appl::TestLabel::init() {
    ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
    APPL_DEBUG("CREATE " __class__ " ... ");
    std::shared_ptr<ewol::widget::Sizer> mySizerVert2;
    std::shared_ptr<ewol::widget::Sizer> mySizerHori;
    std::shared_ptr<ewol::widget::Button> myButton;

    mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
    if (nullptr == mySizerHori) {
        APPL_DEBUG("Allocation error mySizerHori");
        return;
    }
    subWidgetAdd(mySizerHori);
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setToggleMode(true);
        myButton->setSubWidget(      ewol::widget::Label::create("Expand X (false)"));
        myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand X (true)"));
        myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX);
        mySizerHori->subWidgetAdd(myButton);
    }
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setToggleMode(true);
        myButton->setSubWidget(      ewol::widget::Label::create("Expand Y (false)"));
        myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand Y (true)"));
        myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY);
        mySizerHori->subWidgetAdd(myButton);
    }
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setToggleMode(true);
        myButton->setSubWidget(      ewol::widget::Label::create("Fill X (false)"));
        myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X (true)"));
        myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX);
        mySizerHori->subWidgetAdd(myButton);
    }
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setToggleMode(true);
        myButton->setSubWidget(      ewol::widget::Label::create("Fill Y (false)"));
        myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y (true)"));
        myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY);
        mySizerHori->subWidgetAdd(myButton);
    }
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setToggleMode(true);
        myButton->setSubWidget(      ewol::widget::Label::create("no Max size"));
        myButton->setSubWidgetToggle(ewol::widget::Label::create("maxSize (400,99999999)"));
        myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeMaxSize);
        mySizerHori->subWidgetAdd(myButton);
    }
    myButton = ewol::widget::Button::create();
    if (nullptr != myButton) {
        myButton->setSubWidget(ewol::widget::Label::create("Next Label"));
        myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeLabel);
        mySizerHori->subWidgetAdd(myButton);
    }

    std::shared_ptr<ewol::widget::Spacer> mySpacer = ewol::widget::Spacer::create();
    if (nullptr != mySpacer) {
        mySpacer->setExpand(bvec2(false,false));
        mySpacer->setFill(bvec2(true,false));
        mySpacer->setMinSize(vec2(10,10));
        mySpacer->setColor(etk::Color<>(0xFF, 0x00, 0x00, 0x80));
        subWidgetAdd(mySpacer);
    }

    mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
    if (nullptr == mySizerHori) {
        APPL_DEBUG("Allocation error mySizerHori");
        return;
    }
    subWidgetAdd(mySizerHori);
    mySpacer = ewol::widget::Spacer::create();
    if (nullptr != mySpacer) {
        mySpacer->setExpand(bvec2(false,false));
        mySpacer->setFill(bvec2(false,true));
        mySpacer->setMinSize(vec2(10,10));
        mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0x00, 0x80));
        mySizerHori->subWidgetAdd(mySpacer);
    }

    m_testWidget = ewol::widget::Label::create("Basic label");
    if (nullptr != m_testWidget) {
        m_testWidget->setExpand(bvec2(false,false));
        m_testWidget->setFill(bvec2(false,false));
        //m_testWidget->registerOnEvent(shared_from_this(), ewolEventButtonColorChange);
        mySizerHori->subWidgetAdd(m_testWidget);
    }

    mySpacer = ewol::widget::Spacer::create();
    if (nullptr != mySpacer) {
        mySpacer->setExpand(bvec2(false,false));
        mySpacer->setFill(bvec2(false,true));
        mySpacer->setMinSize(vec2(10,10));
        mySpacer->setColor(etk::Color<>(0x00, 0x00, 0xFF, 0x80));
        mySizerHori->subWidgetAdd(mySpacer);
    }

    mySpacer = ewol::widget::Spacer::create();
    if (nullptr != mySpacer) {
        mySpacer->setExpand(bvec2(false,false));
        mySpacer->setFill(bvec2(true,false));
        mySpacer->setMinSize(vec2(10,10));
        mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0xFF, 0x80));
        subWidgetAdd(mySpacer);
    }
}
void CMenus::RenderSettingsTee(CUIRect MainView)
{
	CUIRect Button, Label;
	MainView.HSplitTop(10.0f, 0, &MainView);

	// skin info
	const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin));
	CTeeRenderInfo OwnSkinInfo;
	if(g_Config.m_PlayerUseCustomColor)
	{
		OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;
		OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);
		OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);
	}
	else
	{
		OwnSkinInfo.m_Texture = pOwnSkin->m_OrgTexture;
		OwnSkinInfo.m_ColorBody = vec4(1.0f, 1.0f, 1.0f, 1.0f);
		OwnSkinInfo.m_ColorFeet = vec4(1.0f, 1.0f, 1.0f, 1.0f);
	}
	OwnSkinInfo.m_Size = 50.0f*UI()->Scale();

	MainView.HSplitTop(20.0f, &Label, &MainView);
	Label.VSplitLeft(230.0f, &Label, 0);
	char aBuf[128];
	str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));
	UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);

	MainView.HSplitTop(50.0f, &Label, &MainView);
	Label.VSplitLeft(230.0f, &Label, 0);
	RenderTools()->DrawUIRect(&Label, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
	RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Label.x+30.0f, Label.y+28.0f));
	Label.HSplitTop(15.0f, 0, &Label);;
	Label.VSplitLeft(70.0f, 0, &Label);
	UI()->DoLabelScaled(&Label, g_Config.m_PlayerSkin, 14.0f, -1, 150.0f);

	// custom colour selector
	MainView.HSplitTop(20.0f, 0, &MainView);
	MainView.HSplitTop(20.0f, &Button, &MainView);
	Button.VSplitLeft(230.0f, &Button, 0);
	if(DoButton_CheckBox(&g_Config.m_PlayerColorBody, Localize("Custom colors"), g_Config.m_PlayerUseCustomColor, &Button))
	{
		g_Config.m_PlayerUseCustomColor = g_Config.m_PlayerUseCustomColor?0:1;
		m_NeedSendinfo = true;
	}

	MainView.HSplitTop(5.0f, 0, &MainView);
	MainView.HSplitTop(82.5f, &Label, &MainView);
	if(g_Config.m_PlayerUseCustomColor)
	{
		CUIRect aRects[2];
		Label.VSplitMid(&aRects[0], &aRects[1]);
		aRects[0].VSplitRight(10.0f, &aRects[0], 0);
		aRects[1].VSplitLeft(10.0f, 0, &aRects[1]);

		int *paColors[2];
		paColors[0] = &g_Config.m_PlayerColorBody;
		paColors[1] = &g_Config.m_PlayerColorFeet;

		const char *paParts[] = {
			Localize("Body"),
			Localize("Feet")};
		const char *paLabels[] = {
			Localize("Hue"),
			Localize("Sat."),
			Localize("Lht.")};
		static int s_aColorSlider[2][3] = {{0}};

		for(int i = 0; i < 2; i++)
		{
			aRects[i].HSplitTop(20.0f, &Label, &aRects[i]);
			UI()->DoLabelScaled(&Label, paParts[i], 14.0f, -1);
			aRects[i].VSplitLeft(20.0f, 0, &aRects[i]);
			aRects[i].HSplitTop(2.5f, 0, &aRects[i]);

			int PrevColor = *paColors[i];
			int Color = 0;
			for(int s = 0; s < 3; s++)
			{
				aRects[i].HSplitTop(20.0f, &Label, &aRects[i]);
				Label.VSplitLeft(100.0f, &Label, &Button);
				Button.HMargin(2.0f, &Button);

				float k = ((PrevColor>>((2-s)*8))&0xff) / 255.0f;
				k = DoScrollbarH(&s_aColorSlider[i][s], &Button, k);
				Color <<= 8;
				Color += clamp((int)(k*255), 0, 255);
				UI()->DoLabelScaled(&Label, paLabels[s], 14.0f, -1);
			}

			if(PrevColor != Color)
				m_NeedSendinfo = true;

			*paColors[i] = Color;
		}
	}
Beispiel #20
0
void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const char *pTitle)
{
	if(Team == TEAM_SPECTATORS)
		return;

	float h = 760.0f;
	CUIRect Rect = {x, y, w, h};

	// background
	Graphics()->BlendNormal();
	RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 17.0f);

	// render title
	float TitleFontsize = 40.0f;
	if(!pTitle)
	{
		if(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
			pTitle = Localize("Game over");
		else if(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&GAMESTATEFLAG_ROUNDOVER)
			pTitle = Localize("Round over");
		else
			pTitle = Localize("Score board");
	}
	TextRender()->Text(0, x+20.0f, y, TitleFontsize, pTitle, -1);

	char aBuf[128] = {0};
	if(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS)
	{
		int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreRed : m_pClient->m_Snap.m_pGameDataTeam->m_TeamscoreBlue;
		str_format(aBuf, sizeof(aBuf), "%d", Score);
	}
	else
	{
		if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW &&
			m_pClient->m_Snap.m_paPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID])
		{
			int Score = m_pClient->m_Snap.m_paPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID]->m_Score;
			str_format(aBuf, sizeof(aBuf), "%d", Score);
		}
		else if(m_pClient->m_Snap.m_pLocalInfo)
		{
			int Score = m_pClient->m_Snap.m_pLocalInfo->m_Score;
			str_format(aBuf, sizeof(aBuf), "%d", Score);
		}
	}
	float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
	TextRender()->Text(0, x+w-tw-20.0f, y, TitleFontsize, aBuf, -1);

	// calculate measurements
	x += 10.0f;
	float LineHeight = 60.0f;
	float TeeSizeMod = 1.0f;
	float Spacing = 16.0f;
	if(m_pClient->m_GameInfo.m_aTeamSize[Team] > 12)
	{
		LineHeight = 40.0f;
		TeeSizeMod = 0.8f;
		Spacing = 0.0f;
	}
	else if(m_pClient->m_GameInfo.m_aTeamSize[Team] > 8)
	{
		LineHeight = 50.0f;
		TeeSizeMod = 0.9f;
		Spacing = 8.0f;
	}

	float ScoreOffset = x+10.0f, ScoreLength = 60.0f;
	float TeeOffset = ScoreOffset+ScoreLength, TeeLength = 60*TeeSizeMod;
	float NameOffset = TeeOffset+TeeLength, NameLength = 300.0f-TeeLength;
	float PingOffset = x+610.0f, PingLength = 65.0f;
	float CountryOffset = PingOffset-(LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f, CountryLength = (LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f;
	float ClanOffset = x+370.0f, ClanLength = 230.0f-CountryLength;

	// render headlines
	y += 50.0f;
	float HeadlineFontsize = 22.0f;
	TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.7f);
	tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Score"), -1);
	TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y, HeadlineFontsize, Localize("Score"), -1);

	TextRender()->Text(0, NameOffset, y, HeadlineFontsize, Localize("Name"), -1);

	tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Clan"), -1);
	TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y, HeadlineFontsize, Localize("Clan"), -1);

	tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Ping"), -1);
	TextRender()->Text(0, PingOffset+PingLength-tw, y, HeadlineFontsize, Localize("Ping"), -1);
	TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

	// render player entries
	y += HeadlineFontsize*2.0f;
	float FontSize = 24.0f;
	CTextCursor Cursor;

	for(int RenderDead = 0; RenderDead < 2; ++RenderDead)
	{
		float ColorAlpha = RenderDead ? 0.5f : 1.0f;
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, ColorAlpha);
		for(int i = 0; i < MAX_CLIENTS; i++)
		{
			// make sure that we render the correct team
			const CGameClient::CPlayerInfoItem *pInfo = &m_pClient->m_Snap.m_aInfoByScore[i];
			if(!pInfo->m_pPlayerInfo || m_pClient->m_aClients[pInfo->m_ClientID].m_Team != Team || (!RenderDead && (pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)) ||
				(RenderDead && !(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_DEAD)))
				continue;

			// background so it's easy to find the local player or the followed one in spectator mode
			if(m_pClient->m_LocalClientID == pInfo->m_ClientID || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID))
			{
				Rect.x = x;
				Rect.y = y;
				Rect.w = w-20.0f;
				Rect.h = LineHeight;
				RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.25f*ColorAlpha), 15.0f);
			}

			// score
			str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_pPlayerInfo->m_Score, -999, 999));
			tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
			TextRender()->SetCursor(&Cursor, ScoreOffset+ScoreLength-tw, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
			Cursor.m_LineWidth = ScoreLength;
			TextRender()->TextEx(&Cursor, aBuf, -1);

			// flag
			if(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_FLAGS && m_pClient->m_Snap.m_pGameDataFlag &&
				(m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierRed == pInfo->m_ClientID ||
				m_pClient->m_Snap.m_pGameDataFlag->m_FlagCarrierBlue == pInfo->m_ClientID))
			{
				Graphics()->BlendNormal();
				Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
				Graphics()->QuadsBegin();

				RenderTools()->SelectSprite(m_pClient->m_aClients[pInfo->m_ClientID].m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);

				float Size = LineHeight;
				IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f, Size/2.0f, Size);
				Graphics()->QuadsDrawTL(&QuadItem, 1);
				Graphics()->QuadsEnd();
			}

			// avatar
			if(RenderDead)
			{
				Graphics()->BlendNormal();
				Graphics()->TextureSet(g_pData->m_aImages[IMAGE_DEADTEE].m_Id);
				Graphics()->QuadsBegin();
				IGraphics::CQuadItem QuadItem(TeeOffset, y, 64*TeeSizeMod, 64*TeeSizeMod);
				Graphics()->QuadsDrawTL(&QuadItem, 1);
				Graphics()->QuadsEnd();
			}
			else
			{
				CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo;
				TeeInfo.m_Size *= TeeSizeMod;
				RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(TeeOffset+TeeLength/2, y+LineHeight/2));
			}

			// name
			// todo: improve visual player ready state
			if(!(pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_READY))
				TextRender()->TextColor(1.0f, 0.5f, 0.5f, ColorAlpha);
			else if(RenderDead && pInfo->m_pPlayerInfo->m_PlayerFlags&PLAYERFLAG_WATCHING)
				TextRender()->TextColor(1.0f, 1.0f, 0.0f, ColorAlpha);
			TextRender()->SetCursor(&Cursor, NameOffset, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
			Cursor.m_LineWidth = NameLength;
			char aBuf[64];
			str_format(aBuf, sizeof(aBuf), "%2d: %s", pInfo->m_ClientID, g_Config.m_ClShowsocial ? m_pClient->m_aClients[pInfo->m_ClientID].m_aName : "");
			TextRender()->TextEx(&Cursor, aBuf, -1);
			TextRender()->TextColor(1.0f, 1.0f, 1.0f, ColorAlpha);

			// clan
			tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
			TextRender()->SetCursor(&Cursor, ClanOffset+ClanLength/2-tw/2, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
			Cursor.m_LineWidth = ClanLength;
			TextRender()->TextEx(&Cursor, (g_Config.m_ClShowsocial ? m_pClient->m_aClients[pInfo->m_ClientID].m_aClan : Localize("some clan")), -1);

			// country flag
			vec4 Color(1.0f, 1.0f, 1.0f, 0.5f*ColorAlpha);
			m_pClient->m_pCountryFlags->Render(m_pClient->m_aClients[pInfo->m_ClientID].m_Country, &Color,
												CountryOffset, y+(Spacing+TeeSizeMod*5.0f)/2.0f, CountryLength, LineHeight-Spacing-TeeSizeMod*5.0f);

			// ping
			str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_pPlayerInfo->m_Latency, 0, 1000));
			TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.7f);
			tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
			TextRender()->SetCursor(&Cursor, PingOffset+PingLength-tw, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
			Cursor.m_LineWidth = PingLength;
			TextRender()->TextEx(&Cursor, aBuf, -1);
			TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
			y += LineHeight+Spacing;
		}
	}
	TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
Beispiel #21
0
void App::drawFrame()
{
  // Update the PFX
  updatePFX(frameTime);

  float clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
  renderer->clear(true, true, false, clearColor);

  // Draw the background
  float maxY = (float)height / (float)width * 100.0f;
  renderer->setup2DMode(-50.0f, 50.0f, maxY, 0.0f);
  renderer->reset();
  ((OpenGLRenderer*)renderer)->setTexture(m_texBackground);
  renderer->apply();
  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(-50.0f, maxY);

    glTexCoord2f(1.0f, 0.0f);
    glVertex2f(50.0f, maxY);

    glTexCoord2f(1.0f, 1.0f);
    glVertex2f(50.0f, 0.0f);

    glTexCoord2f(0.0f, 1.0f);
    glVertex2f(-50.0f, 0.0f);
  glEnd();

  // Draw the traditional blending
  // Setup scissor
  glEnable(GL_SCISSOR_TEST);
  glScissor(0, 0, m_divPos, height);

  // Render each particle one by one, as the blend mode can change per particle
  uint32_t drawCallCount = 0;
  {
    auto drawQuad = [&](const Particle& p) 
    {
      drawCallCount++;
      glBegin(GL_QUADS);
      vec2 offset1 = vec2(cosf(p.m_rotation), sinf(p.m_rotation)) * p.m_size;
      vec2 offset2 = vec2(-offset1.y, offset1.x);

      glTexCoord2f(0.0f, 0.0f);
      glVertex2fv(value_ptr(p.m_position - offset1 - offset2));

      glTexCoord2f(1.0f, 0.0f);
      glVertex2fv(value_ptr(p.m_position + offset1 - offset2));

      glTexCoord2f(1.0f, 1.0f);
      glVertex2fv(value_ptr(p.m_position + offset1 + offset2));

      glTexCoord2f(0.0f, 1.0f);
      glVertex2fv(value_ptr(p.m_position - offset1 + offset2));
      glEnd();
    };

    auto drawAdditiveMode = [&](const Particle& p)
    {
      renderer->reset();
      renderer->setBlendState(m_blendModeAdditve);
      ((OpenGLRenderer*)renderer)->setTexture(m_texAdditve);
      glColor4f(p.m_alpha, p.m_alpha, p.m_alpha, 1.0f);
      renderer->apply();
      drawQuad(p);
    };

    auto drawMultiplyMode = [&](const Particle& p)
    {
      renderer->reset();
      renderer->setBlendState(m_blendModeMultiply);
      ((OpenGLRenderer*)renderer)->setTexture(m_texMultiply);
      glColor4f(p.m_alpha, p.m_alpha, p.m_alpha, 1.0f);
      renderer->apply();
      drawQuad(p);
    };

    auto drawBlendMode = [&](const Particle& p)
    {
      renderer->reset();
      renderer->setBlendState(m_blendModeBlend);
      ((OpenGLRenderer*)renderer)->setTexture(m_texBlend);
      glColor4f(1.0f, 1.0f, 1.0f, p.m_alpha);
      renderer->apply();
      drawQuad(p);
    };

    for (Particle& p : m_particles)
    {
      // Bind the appropiate blend mode and texture
      switch (p.m_type)
      {
      case(ParticleType::Additive):
        drawAdditiveMode(p);
        break;

      case(ParticleType::Multiply):
        drawMultiplyMode(p);
        break;

      case(ParticleType::Blend):
        drawBlendMode(p);
        break;

      case(ParticleType::BlendAddMul):
        drawBlendMode(p);
        drawAdditiveMode(p);
        drawMultiplyMode(p);
        break;
      }
    }
  }

  // Draw the pre-mul alpha
  // Setup scissor
  glScissor(m_divPos, 0, width, height);
  renderer->reset();
  renderer->setBlendState(m_blendModePreMul);
  ((OpenGLRenderer*)renderer)->setTexture(m_texPreMul);
  renderer->apply();

  glBegin(GL_QUADS);
  for (Particle& p : m_particles)
  {
    vec2 offset1 = vec2(cosf(p.m_rotation), sinf(p.m_rotation)) * p.m_size;
    vec2 offset2 = vec2(-offset1.y, offset1.x);

    float texSize = 0.5f;
    float texOffsetX = 0.0f;
    float texOffsetY = 0.0f;
    switch (p.m_type)
    {
    case(ParticleType::Additive):
      texOffsetX = 0.0f;
      texOffsetY = 0.0f;
      break;

    case(ParticleType::Multiply):
      texOffsetX = texSize;
      texOffsetY = 0.0f;
      break;

    case(ParticleType::Blend):
      texOffsetX = 0.0f;
      texOffsetY = texSize;
      break;

    case(ParticleType::BlendAddMul):
      texOffsetX = texSize;
      texOffsetY = texSize;
      break;
    }

    glColor4f(p.m_alpha, p.m_alpha, p.m_alpha, p.m_alpha);

    glTexCoord2f(texOffsetX, texOffsetY);
    glVertex2fv(value_ptr(p.m_position - offset1 - offset2));

    glTexCoord2f(texOffsetX + texSize, texOffsetY);
    glVertex2fv(value_ptr(p.m_position + offset1 - offset2));

    glTexCoord2f(texOffsetX + texSize, texOffsetY + texSize);
    glVertex2fv(value_ptr(p.m_position + offset1 + offset2));

    glTexCoord2f(texOffsetX, texOffsetY + texSize);
    glVertex2fv(value_ptr(p.m_position - offset1 + offset2));
  }
  glEnd();

  // Reset the scissor
  glDisable(GL_SCISSOR_TEST);

  // Draw the dividing line
  renderer->reset();
  renderer->setup2DMode(0, (float)width, 0, (float)height);
  renderer->apply();
  glBegin(GL_QUADS);
    glColor3f(0.5f, 0.5f, 0.5f);
    glVertex2i(m_divPos - 1, 0);
    glVertex2i(m_divPos + 1, 0);
    glVertex2i(m_divPos + 1, height);
    glVertex2i(m_divPos - 1, height);
  glEnd();

  // Draw the draw call counts
  {
    char buffer[100];

    sprintf(buffer, "Draw calls = %d", drawCallCount);
    renderer->drawText("Mixed blend mode", 30.0f, 38.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);
    renderer->drawText(buffer, 30.0f, 68.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);

    renderer->drawText("Pre-multiply", (float)width - 200.0f, 38.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);
    renderer->drawText("Draw calls = 1", (float)width - 200.0f, 68.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);

//#ifdef _DEBUG
//    float xPos = (float)width - 250.0f;
//    sprintf(buffer, "Alloc Count %d", g_allocRequestCount);
//    renderer->drawText(buffer, xPos, 138.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);
//    
//    sprintf(buffer, "Free Count %d", g_allocFreeCount);
//    renderer->drawText(buffer, xPos, 168.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);
//    
//    sprintf(buffer, "Working Count %d", g_allocRequestCount - g_allocFreeCount);
//    renderer->drawText(buffer, xPos, 198.0f, 30, 38, defaultFont, linearClamp, blendSrcAlpha, noDepthTest);
//#endif // _DEBUG
  }
}
Beispiel #22
0
#include "Winner.h"

const vec2 char_ran[37] = { vec2(0.003, 0.022), //a - 0
                      vec2(0.031, 0.048), //b - 1
                      vec2(0.057, 0.077), //c - 2
                      vec2(0.085, 0.108), //d - 3
                      vec2(0.116, 0.131), //e - 4 
                      vec2(0.142, 0.156), //f - 5 
                      vec2(0.165, 0.187), //g - 6
                      vec2(0.198, 0.215), //h - 7
                      vec2(0.225, 0.234), //i - 8
                      vec2(0.240, 0.250), //j - 9
                      vec2(0.260, 0.280), //k - 10
                      vec2(0.287, 0.304), //l - 11
                      vec2(0.311, 0.335), //m - 12
                      vec2(0.345, 0.362), //n - 13
                      vec2(0.372, 0.395), //o - 14
                      vec2(0.404, 0.421), //p - 15
                      vec2(0.427, 0.451), //q - 16
                      vec2(0.459, 0.478), //r - 17
                      vec2(0.488, 0.506), //s - 18
                      vec2(0.512, 0.532), //t - 19
                      vec2(0.538, 0.562), //u - 20
                      vec2(0.565, 0.594), //v - 21
                      vec2(0.594, 0.626), //w - 22
                      vec2(0.632, 0.654), //x - 23
                      vec2(0.659, 0.679), //y - 24
                      vec2(0.685, 0.709), //z - 25
                      vec2(0.712, 0.735), //0 - 26
                      vec2(0.740, 0.758), //1 - 27
                      vec2(0.765, 0.784), //2 - 28
Beispiel #23
0
Player::Player()
{
    gameOver = false;
    passingOut = false;

	time = 0.0f;

	hurtOverlay = DrawableBitmap("gfx/hurt.png");
	hurtOverlay.setPosition(vec2(640, 360));

	healthBitmap = al_load_bitmap("gfx/health.png");

	skateSound = al_load_sample("sfx/skate.ogg");
	painSounds[0] = al_load_sample("sfx/pain1.ogg");
	painSounds[1] = al_load_sample("sfx/pain2.ogg");
	painSounds[2] = al_load_sample("sfx/pain3.ogg");
	deathSound = al_load_sample("sfx/death.ogg");
	pickupSound = al_load_sample("sfx/pickup.ogg");

	lastDir = 0;

	healthpacks = 0;

	healthCD = 0.0f;
	health = 1.0f;
	loseTimer = LOSE_TIME;

	weaponPickup = -1;

	angle = 0.0f;
	tilt = 0.0f;
	position = vec3(0.0f, 0.0f, 0.0f);
	height = 0.0f;

	acceleration = vec2(0.0f, 0.0f);
	velocity = vec2(0.0f, 0.0f);

	frictionmodifier = 0.0f;

	lean = 0.0f;
	leanmodifier = 0.0f;

	holdingBack = false;
	jumping = false;

	//Setup Weapons:

	//PISTOL
	pistol = Weapon("gfx/gun.png", "sfx/gun.ogg");

	pistol.automatic = false;

	pistol.kickback = 0.002f;

	pistol.fireDamage = 0.2f;

	pistol.rounds = 1;
	pistol.spread = 0.4;

	pistol.standardPosition = vec2(960, 640);

	pistol.fireTimerMax = 0.15f;
	pistol.fireAnimationTimerMax = 0.3f;
	pistol.aimTimerMax = 0.7f;

	pistol.angleDuration = 0.8f;
	pistol.angleMultiplier = 0.15f;

	pistol.xKick = 70.0f;
	pistol.yKick = -80.0f;
	pistol.zKick = 0.25f;
	pistol.lingerKick = -30.0f;

	pistol.muzzlePosition = vec2(790, 420);

	pistol.muzzleScale = 1.0f;


	//SHOTGUN
	shotgun = Weapon("gfx/shotgun.png", "sfx/shotgun.ogg");

	shotgun.automatic = true;

	shotgun.kickback = 0.05f;

	shotgun.fireDamage = 0.04f;

	shotgun.rounds = 8;
	shotgun.spread = 1.5f;

	shotgun.standardPosition = vec2(800, 650);

	shotgun.fireTimerMax = 0.6f;
	shotgun.fireAnimationTimerMax = 0.5f;
	shotgun.aimTimerMax = 1.0f;

	shotgun.angleDuration = 1.5f;
	shotgun.angleMultiplier = 0.2f;

	shotgun.xKick = 200.0f;
	shotgun.yKick = 100.0f;
	shotgun.zKick = 0.4f;
	shotgun.lingerKick = 10.0f;

	shotgun.muzzlePosition = vec2(780, 490);

	shotgun.muzzleScale = 1.7f;


	//SMG
	smg = Weapon("gfx/smg.png", "sfx/smg.ogg");

	smg.automatic = true;

	smg.kickback = 0.003f;

	smg.fireDamage = 0.10f;

	smg.rounds = 1;
	smg.spread = 1.0f;

	smg.standardPosition = vec2(810, 610);

	smg.fireTimerMax = 0.1f;
	smg.fireAnimationTimerMax = 0.3f;
	smg.aimTimerMax = 0.4f;

	smg.angleDuration = 0.8f;
	smg.angleMultiplier = 0.1f;

	smg.xKick = 70.0f;
	smg.yKick = -10.0f;
	smg.zKick = 0.3f;
	smg.lingerKick = 10.0f;

	smg.muzzlePosition = vec2(720, 450);

	smg.muzzleScale = 0.7f;


	weaponList[0] = &pistol;
	weaponList[1] = &shotgun;
	weaponList[2] = &smg;

	nextWeaponIndex = 0;
	currentWeaponIndex = 0;
	currentWeapon = &pistol;

	weaponSwitchTimeout = WEAPON_SWITCH_TIME/2.0f;

	holdingJump = false;

	displayHealthTimer = 0.0f;
}
Beispiel #24
0
void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
{
	
	// special messages
	if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE)
	{
		/*
		int num = msg_unpack_int();
		
		for(int k = 0; k < num; k++)
		{
			NETOBJ_PROJECTILE proj;
			for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
				((int *)&proj)[i] = msg_unpack_int();
				
			if(msg_unpack_error())
				return;
				
			if(extraproj_num != MAX_EXTRA_PROJECTILES)
			{
				extraproj_projectiles[extraproj_num] = proj;
				extraproj_num++;
			}
		}
		
		return;*/
	}
	else if(MsgId == NETMSGTYPE_SV_TUNEPARAMS)
	{
		// unpack the new tuning
		CTuningParams NewTuning;
		int *pParams = (int *)&NewTuning;
		for(unsigned i = 0; i < sizeof(CTuningParams)/sizeof(int); i++)
			pParams[i] = pUnpacker->GetInt();

		// check for unpacking errors
		if(pUnpacker->Error())
			return;
		
		m_ServerMode = SERVERMODE_PURE;
			
		// apply new tuning
		m_Tuning = NewTuning;
		return;
	}
	
	void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
	if(!pRawMsg)
	{
		char aBuf[256];
		str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
		Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf);
		return;
	}

	// TODO: this should be done smarter
	for(int i = 0; i < m_All.m_Num; i++)
		m_All.m_paComponents[i]->OnMessage(MsgId, pRawMsg);
	
	if(MsgId == NETMSGTYPE_SV_READYTOENTER)
	{
		Client()->EnterGame();
	}
	else if (MsgId == NETMSGTYPE_SV_EMOTICON)
	{
		CNetMsg_Sv_Emoticon *pMsg = (CNetMsg_Sv_Emoticon *)pRawMsg;

		// apply
		m_aClients[pMsg->m_ClientID].m_Emoticon = pMsg->m_Emoticon;
		m_aClients[pMsg->m_ClientID].m_EmoticonStart = Client()->GameTick();
	}
	else if(MsgId == NETMSGTYPE_SV_SOUNDGLOBAL)
	{
		if(m_SuppressEvents)
			return;
		
		// don't enqueue pseudo-global sounds from demos (created by PlayAndRecord)
		CNetMsg_Sv_SoundGlobal *pMsg = (CNetMsg_Sv_SoundGlobal *)pRawMsg;
		if(pMsg->m_SoundID == SOUND_CTF_DROP || pMsg->m_SoundID == SOUND_CTF_RETURN ||
			pMsg->m_SoundID == SOUND_CTF_CAPTURE || pMsg->m_SoundID == SOUND_CTF_GRAB_EN ||
			pMsg->m_SoundID == SOUND_CTF_GRAB_PL)
			g_GameClient.m_pSounds->Enqueue(pMsg->m_SoundID);
		else
			g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_SoundID, 1.0f, vec2(0,0));
	}		
}
Beispiel #25
0
void CItems::RenderLaser(const struct CNetObj_Laser *pCurrent)
{
	vec2 Pos = vec2(pCurrent->m_X, pCurrent->m_Y);
	vec2 From = vec2(pCurrent->m_FromX, pCurrent->m_FromY);
	vec2 Dir = normalize(Pos-From);

	float Ticks = Client()->GameTick() + Client()->IntraGameTick() - pCurrent->m_StartTick;
	float Ms = (Ticks/50.0f) * 1000.0f;
	float a = Ms / m_pClient->m_Tuning.m_LaserBounceDelay;
	a = clamp(a, 0.0f, 1.0f);
	float Ia = 1-a;

	vec2 Out, Border;

	Graphics()->BlendNormal();
	Graphics()->TextureSet(-1);
	Graphics()->QuadsBegin();

	//vec4 inner_color(0.15f,0.35f,0.75f,1.0f);
	//vec4 outer_color(0.65f,0.85f,1.0f,1.0f);

	// do outline
	vec4 OuterColor(0.075f, 0.075f, 0.25f, 1.0f);
	Graphics()->SetColor(OuterColor.r, OuterColor.g, OuterColor.b, 1.0f);
	Out = vec2(Dir.y, -Dir.x) * (7.0f*Ia);

	IGraphics::CFreeformItem Freeform(
			From.x-Out.x, From.y-Out.y,
			From.x+Out.x, From.y+Out.y,
			Pos.x-Out.x, Pos.y-Out.y,
			Pos.x+Out.x, Pos.y+Out.y);
	Graphics()->QuadsDrawFreeform(&Freeform, 1);

	// do inner
	vec4 InnerColor(0.5f, 0.5f, 1.0f, 1.0f);
	Out = vec2(Dir.y, -Dir.x) * (5.0f*Ia);
	Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); // center

	Freeform = IGraphics::CFreeformItem(
			From.x-Out.x, From.y-Out.y,
			From.x+Out.x, From.y+Out.y,
			Pos.x-Out.x, Pos.y-Out.y,
			Pos.x+Out.x, Pos.y+Out.y);
	Graphics()->QuadsDrawFreeform(&Freeform, 1);

	Graphics()->QuadsEnd();

	// render head
	{
		Graphics()->BlendNormal();
		Graphics()->TextureSet(g_pData->m_aImages[IMAGE_PARTICLES].m_Id);
		Graphics()->QuadsBegin();

		int Sprites[] = {SPRITE_PART_SPLAT01, SPRITE_PART_SPLAT02, SPRITE_PART_SPLAT03};
		RenderTools()->SelectSprite(Sprites[Client()->GameTick()%3]);
		Graphics()->QuadsSetRotation(Client()->GameTick());
		Graphics()->SetColor(OuterColor.r, OuterColor.g, OuterColor.b, 1.0f);
		IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 24, 24);
		Graphics()->QuadsDraw(&QuadItem, 1);
		Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f);
		QuadItem = IGraphics::CQuadItem(Pos.x, Pos.y, 20, 20);
		Graphics()->QuadsDraw(&QuadItem, 1);
		Graphics()->QuadsEnd();
	}

	Graphics()->BlendNormal();
}
Beispiel #26
0
void CGameClient::OnNewSnapshot()
{
	m_NewTick = true;
	
	// clear out the invalid pointers
	mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap));
	m_Snap.m_LocalClientID = -1;

	// secure snapshot
	{
		int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);
		for(int Index = 0; Index < Num; Index++)
		{
			IClient::CSnapItem Item;
			void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, Index, &Item);
			if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0)
			{
				if(g_Config.m_Debug)
				{
					char aBuf[256];
					str_format(aBuf, sizeof(aBuf), "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_ID);
					Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
				}
				Client()->SnapInvalidateItem(IClient::SNAP_CURRENT, Index);
			}
		}
	}
		
	ProcessEvents();

	if(g_Config.m_DbgStress)
	{
		if((Client()->GameTick()%100) == 0)
		{
			char aMessage[64];
			int MsgLen = rand()%(sizeof(aMessage)-1);
			for(int i = 0; i < MsgLen; i++)
				aMessage[i] = 'a'+(rand()%('z'-'a'));
			aMessage[MsgLen] = 0;
				
			CNetMsg_Cl_Say Msg;
			Msg.m_Team = rand()&1;
			Msg.m_pMessage = aMessage;
			Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
		}
	}

	// go trough all the items in the snapshot and gather the info we want
	{
		m_Snap.m_aTeamSize[TEAM_RED] = m_Snap.m_aTeamSize[TEAM_BLUE] = 0;
		
		int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);
		for(int i = 0; i < Num; i++)
		{
			IClient::CSnapItem Item;
			const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item);

			if(Item.m_Type == NETOBJTYPE_CLIENTINFO)
			{
				const CNetObj_ClientInfo *pInfo = (const CNetObj_ClientInfo *)pData;
				int ClientID = Item.m_ID;
				IntsToStr(&pInfo->m_Name0, 4, m_aClients[ClientID].m_aName);
				IntsToStr(&pInfo->m_Clan0, 3, m_aClients[ClientID].m_aClan);
				m_aClients[ClientID].m_Country = GetCountryIndex(pInfo->m_Country);
				IntsToStr(&pInfo->m_Skin0, 6, m_aClients[ClientID].m_aSkinName);
				
				m_aClients[ClientID].m_UseCustomColor = pInfo->m_UseCustomColor;
				m_aClients[ClientID].m_ColorBody = pInfo->m_ColorBody;
				m_aClients[ClientID].m_ColorFeet = pInfo->m_ColorFeet;
				
				// prepare the info
				if(m_aClients[ClientID].m_aSkinName[0] == 'x' || m_aClients[ClientID].m_aSkinName[1] == '_')
					str_copy(m_aClients[ClientID].m_aSkinName, "default", 64);
					
				m_aClients[ClientID].m_SkinInfo.m_ColorBody = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorBody);
				m_aClients[ClientID].m_SkinInfo.m_ColorFeet = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorFeet);
				m_aClients[ClientID].m_SkinInfo.m_Size = 64;
				
				// find new skin
				m_aClients[ClientID].m_SkinID = g_GameClient.m_pSkins->Find(m_aClients[ClientID].m_aSkinName);
				if(m_aClients[ClientID].m_SkinID < 0)
				{
					m_aClients[ClientID].m_SkinID = g_GameClient.m_pSkins->Find("default");
					if(m_aClients[ClientID].m_SkinID < 0)
						m_aClients[ClientID].m_SkinID = 0;
				}
				
				if(m_aClients[ClientID].m_UseCustomColor)
					m_aClients[ClientID].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[ClientID].m_SkinID)->m_ColorTexture;
				else
				{
					m_aClients[ClientID].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[ClientID].m_SkinID)->m_OrgTexture;
					m_aClients[ClientID].m_SkinInfo.m_ColorBody = vec4(1,1,1,1);
					m_aClients[ClientID].m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);
				}

				m_aClients[ClientID].UpdateRenderInfo();
				
			}
			else if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
			{
				const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData;
				
				m_aClients[pInfo->m_ClientID].m_Team = pInfo->m_Team;
				m_aClients[pInfo->m_ClientID].m_Active = true;
				m_Snap.m_paPlayerInfos[pInfo->m_ClientID] = pInfo;
				m_Snap.m_NumPlayers++;
				
				if(pInfo->m_Local)
				{
					m_Snap.m_LocalClientID = Item.m_ID;
					m_Snap.m_pLocalInfo = pInfo;
					
					if(pInfo->m_Team == TEAM_SPECTATORS)
					{
						m_Snap.m_SpecInfo.m_Active = true;
						m_Snap.m_SpecInfo.m_SpectatorID = SPEC_FREEVIEW;
					}
				}
				
				// calculate team-balance
				if(pInfo->m_Team != TEAM_SPECTATORS)
					m_Snap.m_aTeamSize[pInfo->m_Team]++;
				
			}
			else if(Item.m_Type == NETOBJTYPE_CHARACTER)
			{
				const void *pOld = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_CHARACTER, Item.m_ID);
				m_Snap.m_aCharacters[Item.m_ID].m_Cur = *((const CNetObj_Character *)pData);
				if(pOld)
				{
					m_Snap.m_aCharacters[Item.m_ID].m_Active = true;
					m_Snap.m_aCharacters[Item.m_ID].m_Prev = *((const CNetObj_Character *)pOld);

					if(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick)
						Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick());
					if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick)
						Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
				}
			}
			else if(Item.m_Type == NETOBJTYPE_SPECTATORINFO)
			{
				m_Snap.m_pSpectatorInfo = (const CNetObj_SpectatorInfo *)pData;
				m_Snap.m_pPrevSpectatorInfo = (const CNetObj_SpectatorInfo *)Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_SPECTATORINFO, Item.m_ID);

				m_Snap.m_SpecInfo.m_SpectatorID = m_Snap.m_pSpectatorInfo->m_SpectatorID;
			}
			else if(Item.m_Type == NETOBJTYPE_GAMEINFO)
			{
				static bool s_GameOver = 0;
				m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData;
				if(!s_GameOver && m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
					OnGameOver();
				else if(s_GameOver && !(m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
					OnStartGame();
				s_GameOver = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER;
			}
			else if(Item.m_Type == NETOBJTYPE_GAMEDATA)
			{
				m_Snap.m_pGameDataObj = (const CNetObj_GameData *)pData;
				m_Snap.m_GameDataSnapID = Item.m_ID;
			}
			else if(Item.m_Type == NETOBJTYPE_FLAG)
				m_Snap.m_paFlags[Item.m_ID%2] = (const CNetObj_Flag *)pData;
		}
	}
	
	// setup local pointers
	if(m_Snap.m_LocalClientID >= 0)
	{
		CSnapState::CCharacterInfo *c = &m_Snap.m_aCharacters[m_Snap.m_LocalClientID];
		if(c->m_Active)
		{
			m_Snap.m_pLocalCharacter = &c->m_Cur;
			m_Snap.m_pLocalPrevCharacter = &c->m_Prev;
			m_LocalCharacterPos = vec2(m_Snap.m_pLocalCharacter->m_X, m_Snap.m_pLocalCharacter->m_Y);
		}
		else if(Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_CHARACTER, m_Snap.m_LocalClientID))
		{
			// player died
			m_pControls->OnPlayerDeath();
		}
	}
	else
	{
		m_Snap.m_SpecInfo.m_Active = true;
		if(Client()->State() == IClient::STATE_DEMOPLAYBACK && DemoPlayer()->GetDemoType() == IDemoPlayer::DEMOTYPE_SERVER &&
			m_DemoSpecID != SPEC_FREEVIEW && m_Snap.m_aCharacters[m_DemoSpecID].m_Active)
			m_Snap.m_SpecInfo.m_SpectatorID = m_DemoSpecID;
		else
			m_Snap.m_SpecInfo.m_SpectatorID = SPEC_FREEVIEW;
	}

	// clear out unneeded client data
	for(int i = 0; i < MAX_CLIENTS; ++i)
	{
		if(!m_Snap.m_paPlayerInfos[i] && m_aClients[i].m_Active)
			m_aClients[i].Reset();
	}

	// update friend state
	for(int i = 0; i < MAX_CLIENTS; ++i)
	{
		if(i == m_Snap.m_LocalClientID || !m_Snap.m_paPlayerInfos[i] || !Friends()->IsFriend(m_aClients[i].m_aName, m_aClients[i].m_aClan))
			m_aClients[i].m_Friend = false;
		else
			m_aClients[i].m_Friend = true;
	}

	// sort player infos by score
	mem_copy(m_Snap.m_paInfoByScore, m_Snap.m_paPlayerInfos, sizeof(m_Snap.m_paInfoByScore));
	for(int k = 0; k < MAX_CLIENTS-1; k++) // ffs, bubblesort
	{
		for(int i = 0; i < MAX_CLIENTS-k-1; i++)
		{
			if(m_Snap.m_paInfoByScore[i+1] && (!m_Snap.m_paInfoByScore[i] || m_Snap.m_paInfoByScore[i]->m_Score < m_Snap.m_paInfoByScore[i+1]->m_Score))
			{
				const CNetObj_PlayerInfo *pTmp = m_Snap.m_paInfoByScore[i];
				m_Snap.m_paInfoByScore[i] = m_Snap.m_paInfoByScore[i+1];
				m_Snap.m_paInfoByScore[i+1] = pTmp;
			}
		}
	}
	
	CTuningParams StandardTuning;
	CServerInfo CurrentServerInfo;
	Client()->GetServerInfo(&CurrentServerInfo);
	if(CurrentServerInfo.m_aGameType[0] != '0')
	{
		if(str_comp(CurrentServerInfo.m_aGameType, "DM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "TDM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "CTF") != 0)
			m_ServerMode = SERVERMODE_MOD;
		else if(mem_comp(&StandardTuning, &m_Tuning, sizeof(CTuningParams)) == 0)
			m_ServerMode = SERVERMODE_PURE;
		else
			m_ServerMode = SERVERMODE_PUREMOD;
	}

}
Beispiel #27
0
void CMenus::RenderPlayers(CUIRect MainView)
{
	CUIRect Button, ButtonBar, Options, Player;
	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);

	// player options
	MainView.Margin(10.0f, &Options);
	RenderTools()->DrawUIRect(&Options, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
	Options.Margin(10.0f, &Options);
	Options.HSplitTop(50.0f, &Button, &Options);
	UI()->DoLabelScaled(&Button, Localize("Player options"), 34.0f, -1);

	// headline
	Options.HSplitTop(34.0f, &ButtonBar, &Options);
	ButtonBar.VSplitRight(220.0f, &Player, &ButtonBar);
	UI()->DoLabelScaled(&Player, Localize("Player"), 24.0f, -1);

	ButtonBar.HMargin(1.0f, &ButtonBar);
	float Width = ButtonBar.h*2.0f;
	ButtonBar.VSplitLeft(Width, &Button, &ButtonBar);
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIICONS].m_Id);
	Graphics()->QuadsBegin();
	RenderTools()->SelectSprite(SPRITE_GUIICON_MUTE);
	IGraphics::CQuadItem QuadItem(Button.x, Button.y, Button.w, Button.h);
	Graphics()->QuadsDrawTL(&QuadItem, 1);
	Graphics()->QuadsEnd();

	ButtonBar.VSplitLeft(20.0f, 0, &ButtonBar);
	ButtonBar.VSplitLeft(Width, &Button, &ButtonBar);
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIICONS].m_Id);
	Graphics()->QuadsBegin();
	RenderTools()->SelectSprite(SPRITE_GUIICON_FRIEND);
	QuadItem = IGraphics::CQuadItem(Button.x, Button.y, Button.w, Button.h);
	Graphics()->QuadsDrawTL(&QuadItem, 1);
	Graphics()->QuadsEnd();

	// options
	static int s_aPlayerIDs[MAX_CLIENTS][2] = {{0}};
	for(int i = 0, Count = 0; i < MAX_CLIENTS; ++i)
	{
		if(!m_pClient->m_Snap.m_paInfoByTeam[i])
			continue;

		int Index = m_pClient->m_Snap.m_paInfoByTeam[i]->m_ClientID;
		if(Index == m_pClient->m_Snap.m_LocalClientID)
			continue;

		Options.HSplitTop(28.0f, &ButtonBar, &Options);
		if(Count++%2 == 0)
			RenderTools()->DrawUIRect(&ButtonBar, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
		ButtonBar.VSplitRight(220.0f, &Player, &ButtonBar);

		// player info
		Player.VSplitLeft(28.0f, &Button, &Player);
		CTeeRenderInfo Info = m_pClient->m_aClients[Index].m_RenderInfo;
		Info.m_Size = Button.h;
		RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(Button.x+Button.h/2, Button.y+Button.h/2));

		Player.HSplitTop(1.5f, 0, &Player);
		Player.VSplitMid(&Player, &Button);
		CTextCursor Cursor;
		TextRender()->SetCursor(&Cursor, Player.x, Player.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = Player.w;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[Index].m_aName, -1);

		TextRender()->SetCursor(&Cursor, Button.x,Button.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
		Cursor.m_LineWidth = Button.w;
		TextRender()->TextEx(&Cursor, m_pClient->m_aClients[Index].m_aClan, -1);

		// ignore button
		ButtonBar.HMargin(2.0f, &ButtonBar);
		ButtonBar.VSplitLeft(Width, &Button, &ButtonBar);
		Button.VSplitLeft((Width-Button.h)/4.0f, 0, &Button);
		Button.VSplitLeft(Button.h, &Button, 0);
		if(DoButton_Toggle(&s_aPlayerIDs[Index][0], m_pClient->m_aClients[Index].m_ChatIgnore, &Button))
			m_pClient->m_aClients[Index].m_ChatIgnore ^= 1;

		// friend button
		ButtonBar.VSplitLeft(20.0f, &Button, &ButtonBar);
		ButtonBar.VSplitLeft(Width, &Button, &ButtonBar);
		Button.VSplitLeft((Width-Button.h)/4.0f, 0, &Button);
		Button.VSplitLeft(Button.h, &Button, 0);
		if(DoButton_Toggle(&s_aPlayerIDs[Index][1], m_pClient->m_aClients[Index].m_Friend, &Button))
		{
			if(m_pClient->m_aClients[Index].m_Friend)
				m_pClient->Friends()->RemoveFriend(m_pClient->m_aClients[Index].m_aName, m_pClient->m_aClients[Index].m_aClan);
			else
				m_pClient->Friends()->AddFriend(m_pClient->m_aClients[Index].m_aName, m_pClient->m_aClients[Index].m_aClan);
		}
	}

	/*
	CUIRect bars;
	votearea.HSplitTop(10.0f, 0, &votearea);
	votearea.HSplitTop(25.0f + 10.0f*3 + 25.0f, &votearea, &bars);

	RenderTools()->DrawUIRect(&votearea, color_tabbar_active, CUI::CORNER_ALL, 10.0f);

	votearea.VMargin(20.0f, &votearea);
	votearea.HMargin(10.0f, &votearea);

	votearea.HSplitBottom(35.0f, &votearea, &bars);

	if(gameclient.voting->is_voting())
	{
		// do yes button
		votearea.VSplitLeft(50.0f, &button, &votearea);
		static int yes_button = 0;
		if(UI()->DoButton(&yes_button, "Yes", 0, &button, ui_draw_menu_button, 0))
			gameclient.voting->vote(1);

		// do no button
		votearea.VSplitLeft(5.0f, 0, &votearea);
		votearea.VSplitLeft(50.0f, &button, &votearea);
		static int no_button = 0;
		if(UI()->DoButton(&no_button, "No", 0, &button, ui_draw_menu_button, 0))
			gameclient.voting->vote(-1);
		
		// do time left
		votearea.VSplitRight(50.0f, &votearea, &button);
		char buf[256];
		str_format(buf, sizeof(buf), "%d", gameclient.voting->seconds_left());
		UI()->DoLabel(&button, buf, 24.0f, 0);

		// do description and command
		votearea.VSplitLeft(5.0f, 0, &votearea);
		UI()->DoLabel(&votearea, gameclient.voting->vote_description(), 14.0f, -1);
		votearea.HSplitTop(16.0f, 0, &votearea);
		UI()->DoLabel(&votearea, gameclient.voting->vote_command(), 10.0f, -1);

		// do bars
		bars.HSplitTop(10.0f, 0, &bars);
		bars.HMargin(5.0f, &bars);
		
		gameclient.voting->render_bars(bars, true);

	}		
	else
	{
		UI()->DoLabel(&votearea, "No vote in progress", 18.0f, -1);
	}*/
}
Beispiel #28
0
void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const char *title)
{
	//float ystart = y;
	float h = 750.0f;

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.5f);
	draw_round_rect(x-10.f, y-10.f, w, h, 17.0f);
	gfx_quads_end();

	// render title
	if(!title)
	{
		if(gameclient.snap.gameobj->game_over)
			title = "Game Over";
		else
			title = "Score Board";
	}

	float tw = gfx_text_width(0, 48, title, -1);

	if(team == -1)
	{
		gfx_text(0, x+w/2-tw/2, y, 48, title, -1);
	}
	else
	{
		gfx_text(0, x+10, y, 48, title, -1);

		if(gameclient.snap.gameobj)
		{
			char buf[128];
			int score = team ? gameclient.snap.gameobj->teamscore_blue : gameclient.snap.gameobj->teamscore_red;
			str_format(buf, sizeof(buf), "%d", score);
			tw = gfx_text_width(0, 48, buf, -1);
			gfx_text(0, x+w-tw-30, y, 48, buf, -1);
		}
	}

	y += 54.0f;

	// find players
	const NETOBJ_PLAYER_INFO *players[MAX_CLIENTS] = {0};
	int num_players = 0;
	for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++)
	{
		SNAP_ITEM item;
		const void *data = snap_get_item(SNAP_CURRENT, i, &item);

		if(item.type == NETOBJTYPE_PLAYER_INFO)
		{
			const NETOBJ_PLAYER_INFO *info = (const NETOBJ_PLAYER_INFO *)data;
			if(info->team == team)
			{
				players[num_players] = info;
				num_players++;
			}
		}
	}

	// sort players
	for(int k = 0; k < num_players; k++) // ffs, bubblesort
	{
		for(int i = 0; i < num_players-k-1; i++)
		{
			if(players[i]->score < players[i+1]->score)
			{
				const NETOBJ_PLAYER_INFO *tmp = players[i];
				players[i] = players[i+1];
				players[i+1] = tmp;
			}
		}
	}

	// render headlines
	gfx_text(0, x+10, y, 24.0f, "Score", -1);
	gfx_text(0, x+125, y, 24.0f, "Name", -1);
	gfx_text(0, x+w-70, y, 24.0f, "Ping", -1);
	y += 29.0f;

	float font_size = 35.0f;
	float line_height = 50.0f;
	float tee_sizemod = 1.0f;
	float tee_offset = 0.0f;
	
	if(num_players > 13)
	{
		font_size = 30.0f;
		line_height = 40.0f;
		tee_sizemod = 0.8f;
		tee_offset = -5.0f;
	}
	
	// render player scores
	for(int i = 0; i < num_players; i++)
	{
		const NETOBJ_PLAYER_INFO *info = players[i];

		// make sure that we render the correct team

		char buf[128];
		if(info->local)
		{
			// background so it's easy to find the local player
			gfx_texture_set(-1);
			gfx_quads_begin();
			gfx_setcolor(1,1,1,0.25f);
			draw_round_rect(x, y, w-20, line_height*0.95f, 17.0f);
			gfx_quads_end();
		}

		str_format(buf, sizeof(buf), "%4d", info->score);
		gfx_text(0, x+60-gfx_text_width(0, font_size,buf,-1), y, font_size, buf, -1);
		
		if(config.cl_scoreboard_client_id)
		{
			str_format(buf, sizeof(buf), "%d | %s", info->cid, gameclient.clients[info->cid].name);
			gfx_text(0, x+128, y, font_size, buf, -1);
		}
		else
		{
			gfx_text(0, x+128, y, font_size, gameclient.clients[info->cid].name, -1);
		}

		str_format(buf, sizeof(buf), "%4d", info->latency);
		float tw = gfx_text_width(0, font_size, buf, -1);
		gfx_text(0, x+w-tw-35, y, font_size, buf, -1);

		// render avatar
		if((gameclient.snap.flags[0] && gameclient.snap.flags[0]->carried_by == info->cid) ||
			(gameclient.snap.flags[1] && gameclient.snap.flags[1]->carried_by == info->cid))
		{
			gfx_blend_normal();
			if(config.tc_colored_flags)
				gfx_texture_set(data->images[IMAGE_GAME_GRAY].id);
			else
				gfx_texture_set(data->images[IMAGE_GAME].id);
			gfx_quads_begin();

			if(info->team == 0) select_sprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
			else select_sprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
			if(config.tc_colored_flags)
			{
				vec3 col = TeecompUtils::getTeamColor(1-info->team, gameclient.snap.local_info->team, 
					config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method);
				gfx_setcolor(col.r, col.g, col.b, 1.0f);
			}
			
			float size = 64.0f;
			gfx_quads_drawTL(x+55, y-15, size/2, size);
			gfx_quads_end();
		}
		
		TEE_RENDER_INFO teeinfo = gameclient.clients[info->cid].render_info;
		teeinfo.size *= tee_sizemod;
		render_tee(ANIMSTATE::get_idle(), &teeinfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+tee_offset));

		
		y += line_height;
	}
}
Beispiel #29
0
normal2::operator vec2 () const
{
    return vec2(_x,_y);
}
Beispiel #30
0
Tile2D_Entity *Tile2D_SpawnEntity_Bullet(vec2 org, vec2 vel, int style)
{
	Tile2D_Entity *tmp;
	char *s;

	tmp=Tile2D_AllocEntity();
	tmp->org=org;
	tmp->vel=vel;
	tmp->mins=vec2(-0.25, -0.25);
	tmp->maxs=vec2( 0.25,  0.25);
	
	tmp->spr_size=vec2(0.5, 0.5);
	tmp->spr_center=vec2(0.25, 0.25);
	
	tmp->damage=5;
	
	tmp->Draw=Tile2D_DrawEntity_Sprite;
//	tmp->AnimTick=Tile2D_AnimTick_Bear;
	tmp->Update=Tile2D_Update_EntityBullet;

	switch(style)
	{
	case 0:
		s="sprites/plasma/s_plasma_0";
		break;
	case 1:
		s="sprites/plasma/s_plasma2_0";
		break;
	case 2:
		s="sprites/plasma/s_plasma3_0";
		break;
	case 3:
		s="sprites/bfg/s_bfg1_0";
		break;
	case 4:
		s="sprites/plasma/s_plasma_0";
		tmp->spr_size=vec2(1, 1);
		tmp->spr_center=vec2(0.5, 0.5);
		tmp->damage=10;
		break;
	case 5:
		s="sprites/plasma/s_plasma2_0";
		tmp->spr_size=vec2(1, 1);
		tmp->spr_center=vec2(0.5, 0.5);
		tmp->damage=10;
		break;
	case 6:
		s="sprites/plasma/s_plasma3_0";
		tmp->spr_size=vec2(1, 1);
		tmp->spr_center=vec2(0.5, 0.5);
		tmp->damage=10;
		break;
	case 7:
		s="sprites/bfg/s_bfg1_0";
		tmp->spr_size=vec2(1, 1);
		tmp->spr_center=vec2(0.5, 0.5);
		tmp->damage=10;
		break;
	case 8:
		s="sprites/plasma/s_plasma_0";
		tmp->spr_size=vec2(2, 2);
		tmp->spr_center=vec2(1, 1);
		tmp->damage=20;
		break;
	case 9:
		s="sprites/plasma/s_plasma2_0";
		tmp->spr_size=vec2(2, 2);
		tmp->spr_center=vec2(1, 1);
		tmp->damage=20;
		break;
	case 10:
		s="sprites/plasma/s_plasma3_0";
		tmp->spr_size=vec2(2, 2);
		tmp->spr_center=vec2(1, 1);
		tmp->damage=20;
		break;
	case 11:
		s="sprites/bfg/s_bfg1_0";
		tmp->spr_size=vec2(2, 2);
		tmp->spr_center=vec2(1, 1);
		tmp->damage=20;
		break;
	default:
		s="sprites/plasma/s_plasma3_0";
		break;
	}

//	s="sprites/plasma/s_plasma3_0";
	tmp->spr_tex=LBXGL_Texture_LoadImage(s);

	return(tmp);
}