Ejemplo n.º 1
0
CL_Vec2i CL_LineSegment2x<int>::normal() const
{
	CL_LineSegment2f line( CL_Vec2f( (float) p.x, (float) p.y), CL_Vec2f( (float) q.x, (float) q.y) );
	CL_Vec2f n = line.normal();
	CL_Vec2i vec((int) (n.x * 256.0f), (int) (n.y * 256.0f));
	return vec;
}
CL_PixelCommand *CL_SoftwareProgram_Standard::draw_sprite(CL_PixelPipeline *pipeline, const std::vector<CL_Vec4f> &attribute_values)
{
	CL_Vec2f init_points[3] = { transform(attribute_values[0]), transform(attribute_values[1]), transform(attribute_values[2]) };
	CL_Vec4f init_primcolor[3] = { attribute_values[3], attribute_values[4], attribute_values[5] };
	CL_Vec2f init_texcoords[3] = { CL_Vec2f(attribute_values[6]), CL_Vec2f(attribute_values[7]), CL_Vec2f(attribute_values[8]) };
	int init_sampler = (int)attribute_values[9].x;
	return new(pipeline) CL_PixelCommandSprite(init_points, init_primcolor[0], init_texcoords, init_sampler);
}
Ejemplo n.º 3
0
void CL_RenderBatch2D::modelview_changed(const CL_Mat4f &new_modelview)
{
	modelview = new_modelview;
	x_dir = CL_Vec2f(modelview * CL_Vec4f(1.0f, 0.0f, 1.0f, 1.0f));
	y_dir = CL_Vec2f(modelview * CL_Vec4f(0.0f, 1.0f, 1.0f, 1.0f));
	origin = CL_Vec2f(modelview * CL_Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
	x_dir -= origin;
	y_dir -= origin;
}
Ejemplo n.º 4
0
ScrollComponent::ScrollComponent()
{
	SetName("Scroll");
	m_activeFinger = -1;
	m_bIsScrolling = false;
	m_vTotalDisplacementOnCurrentSwipe = CL_Vec2f(0,0);
	m_lastTouchPos = CL_Vec2f(-100,-100);
	m_vecDisplacement = CL_Vec2f(0,0);
}
Ejemplo n.º 5
0
void CL_Draw::line(CL_GraphicContext &gc, float x1, float y1, float x2, float y2, const CL_Colorf &color)
{
	CL_Vec2f positions[2] =
	{
		CL_Vec2f(x1, y1),
		CL_Vec2f(x2, y2)
	};

	CL_PrimitivesArray prim_array(gc);
	prim_array.set_attributes(0, positions);
	prim_array.set_attribute(1, color);
	gc.set_program_object(cl_program_color_only);
	gc.draw_primitives(cl_lines, 2, prim_array);
	gc.reset_program_object();
}
Ejemplo n.º 6
0
void ScrollComponent::OnAdd(Entity *pEnt)
{
	EntityComponent::OnAdd(pEnt);

	//shared with the rest of the entity
	m_vecDisplacement = m_vecChildPos = CL_Vec2f(0,0);
	m_pPos2d = &GetParent()->GetVar("pos2d")->GetVector2();
	m_pSize2d = &GetParent()->GetVar("size2d")->GetVector2();
	//vars in our component namespace
	m_pBoundsRect = &GetVarWithDefault("boundsRect", CL_Rectf(0, 0, 0,0))->GetRect();
	m_pScrollStyle = &GetVarWithDefault("scrollStyle", uint32(STYLE_MOMENTUM))->GetUINT32();
	
	//only used for "momentum style"
	m_pFriction = &GetVarWithDefault("friction", 0.1f)->GetFloat();
	m_pMaxScrollSpeed = &GetVarWithDefault("maxScrollSpeed", float(7))->GetFloat();
	m_pPowerMod = &GetVarWithDefault("powerMod", float(0.15))->GetFloat();
	m_progressVar = GetVar("progress2d");
	m_pEnforceFingerTracking = &GetVarWithDefault("fingerTracking", uint32(0))->GetUINT32();
	m_pSwipeDetectDistance = &GetVarWithDefault("swipeDetectDistance", 25.0f)->GetFloat();
	m_pDontScrollUntilSwipeDetected = &GetVarWithDefault("dontScrollUntilSwipeDetected", uint32(0))->GetUINT32();
	m_pEatAllInput = &GetVarWithDefault("eatAllInput", uint32(0))->GetUINT32();

	GetParent()->GetFunction("OnOverStart")->sig_function.connect(1, boost::bind(&ScrollComponent::OnOverStart, this, _1));
	GetParent()->GetFunction("OnOverEnd")->sig_function.connect(1, boost::bind(&ScrollComponent::OnOverEnd, this, _1));
	GetParent()->GetFunction("OnOverMove")->sig_function.connect(1, boost::bind(&ScrollComponent::OnOverMove, this, _1));
	GetParent()->GetFunction("OnUpdate")->sig_function.connect(1, boost::bind(&ScrollComponent::OnUpdate, this, _1));
	GetFunction("SetProgress")->sig_function.connect(1, boost::bind(&ScrollComponent::SetProgress, this, _1));
}
Ejemplo n.º 7
0
void L_ParticleEffect::Setup(int period_t, int x, int y)
{
	x_pos = x;
	y_pos = y;
	x_pos_offset = 0; //SETH
	y_pos_offset = 0; //SETH

	par_randrot_on = false;
	size_distortion = 0;
	life_distortion = 0;
	follow_shooting = false;

	num_particle_type = 0;

	cumulative_prob = 0;
	total_auto_p = 0;

	istriggered = true;
	period = period_t;
	counter = period;
	life = L_INFINITE_LIFE;
	addit_vector_enabled = false;
	velocity = CL_Vec2f(0,0);

	for (int i=0; i < L_PARTICLE_TYPE_LIMIT; i++)
	{
		fl_particle[i] = NULL;
	}
}
Ejemplo n.º 8
0
void RadialMenu::on_mouse_move(CL_InputEvent &input_event)
{
	CL_Vec2f mouse_offset((float)input_event.mouse_pos.x - center_x, (float)input_event.mouse_pos.y - center_y);
	if(mouse_offset.length() > 25.0f)
	{
		CL_Vec2f origin(CL_Vec2f(0, -1));
		CL_Angle mouse_angle = origin.angle(mouse_offset);

		int degrees = ((int)(mouse_angle.to_degrees() + 22.5f) / 45) * 45;
		selected_angle = CL_Angle::from_degrees((float)degrees);
		if(mouse_offset.x < 0)
			selected_angle = CL_Angle::from_degrees(360.0f) - selected_angle;
		if(selected_angle.to_degrees() >= 360.0f)
			selected_angle = CL_Angle::from_degrees(360.0f) - selected_angle;

		image_pointer.set_angle(selected_angle);

		if(selected_angle >= max_angle)
			selected_index = -1;
		else
			selected_index = (int)selected_angle.to_degrees() / 45;
	}
	else
		selected_index = -1;
}
Ejemplo n.º 9
0
void spaceship::create_path(Node* _to_node)
{
	bool was_walking = false;
	float was_x_ = 0;
	float was_y_ = 0;
	if (current_path_.size() > 0)
	{
		int p = current_path_.size() -1;
		was_walking = true;
		was_x_ = current_path_[p].x;
		was_y_ = current_path_[p].y;
	}
	current_path_.clear();
	current_path_ = g_nodes->aStarNodeVersion(my_node, _to_node);
	if (current_path_.size() == 0 || was_walking)//no encontre camino, es porque es el nodo en el que estoy)
	{
		//we check that we were not walkng there :P
		if (was_walking && current_path_.size() > 0)
		{
			int p = current_path_.size() -1;
			if (was_x_ == current_path_[p].x && was_y_ == current_path_[p].y)
			{
				return;
			}
		}
		current_path_.push_back(CL_Vec2f(my_node->x,my_node->y));
	}
}
Ejemplo n.º 10
0
void Model_Impl::insert_vbo(int vertex_count, const struct aiScene* sc, const struct aiNode* nd)
{
	int i;
	unsigned int n = 0, t;

	bool use_texcoords = !vbo_texcoords.is_null();

	// All meshes assigned to this node
	for (; n < nd->mNumMeshes; ++n)
	{
		const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
		int num_vertex = mesh->mNumFaces * 3;
		if (!num_vertex)
			continue;

		std::vector<CL_Vec3f> normals;
		std::vector<CL_Vec3f> vertices;
		std::vector<CL_Vec2f> tex_coords;

		normals.reserve(num_vertex);
		vertices.reserve(num_vertex);

		if (use_texcoords)
		{
			if (mesh->mTextureCoords == NULL || mesh->mTextureCoords[0] == NULL)
				throw CL_Exception("This example expects texcoords to be set for this object");
			tex_coords.reserve(num_vertex);
		}

		for (t = 0; t < mesh->mNumFaces; ++t)
		{
			const struct aiFace* face = &mesh->mFaces[t];
			if (face->mNumIndices != 3)
					throw CL_Exception("This example only supports triangles");

			for(i = 0; i < face->mNumIndices; i++)
			{
				int index = face->mIndices[i];
				normals.push_back(CL_Vec3f(&mesh->mNormals[index].x));
				vertices.push_back( CL_Vec3f(&mesh->mVertices[index].x));
				if (use_texcoords)
					tex_coords.push_back( CL_Vec2f(&mesh->mTextureCoords[0][index].x));
			}
		}

		vbo_positions.upload_data(vertex_count * sizeof(CL_Vec3f), &vertices[0], num_vertex * sizeof(CL_Vec3f));
		vbo_normals.upload_data(vertex_count * sizeof(CL_Vec3f), &normals[0], num_vertex * sizeof(CL_Vec3f));
		if (use_texcoords)
			vbo_texcoords.upload_data(vertex_count * sizeof(CL_Vec2f), &tex_coords[0], num_vertex * sizeof(CL_Vec2f));

		vertex_count += num_vertex;
	}

	// All children
	for (n = 0; n < nd->mNumChildren; ++n)
	{
		insert_vbo(vertex_count, sc, nd->mChildren[n]);
	}

}
Ejemplo n.º 11
0
void CL_Draw::triangle(CL_GraphicContext &gc, const CL_Pointf &a, const CL_Pointf &b, const CL_Pointf &c, const CL_Colorf &color)
{
	CL_Vec2f positions[3] =
	{
		CL_Vec2f(a.x, a.y),
		CL_Vec2f(b.x, b.y),
		CL_Vec2f(c.x, c.y)
	};

	CL_PrimitivesArray prim_array(gc);
	prim_array.set_attributes(0, positions);
	prim_array.set_attribute(1, color);
	gc.set_program_object(cl_program_color_only);
	gc.draw_primitives(cl_triangles, 3, prim_array);
	gc.reset_program_object();
}
Ejemplo n.º 12
0
void ArcadeInputComponent::OnTrackballModeChanged(Variant *pVar)
{
	if (pVar->GetUINT32() == TRACKBALL_MODE_MENU_SELECTION)
	{
		m_trackball = CL_Vec2f(0,0); //clear whatever was there before
	}
}
Ejemplo n.º 13
0
//testing accelerometer readings. To enable the test, search below for "ACCELTEST"
//Note: You'll need to look at the  debug log to see the output. (For android, run PhoneLog.bat from RTBareBones/android)
void App::OnAccel(VariantList *pVList)
{
	
	if ( int(pVList->m_variant[0].GetFloat()) != MESSAGE_TYPE_GUI_ACCELEROMETER) return;

	CL_Vec3f v = pVList->m_variant[1].GetVector3();

	LogMsg("Accel: %s", PrintVector3(v).c_str());

	v.x = v.x * kFilteringFactor + v.x * (1.0f - kFilteringFactor);
	v.y = v.y * kFilteringFactor + v.y * (1.0f - kFilteringFactor);
	v.z = v.z * kFilteringFactor + v.z * (1.0f - kFilteringFactor);

	// Compute values for the three axes of the acceleromater
	float x = v.x - v.x;
	float y = v.y - v.x;
	float z = v.z - v.x;

	//Compute the intensity of the current acceleration 
	if (sqrt(x * x + y * y + z * z) > 2.0f)
	{
		Entity *pEnt = GetEntityRoot()->GetEntityByName("jumble");
		if (pEnt)
		{
			//GetAudioManager()->Play("audio/click.wav");
            VariantList vList(CL_Vec2f(), pEnt);
			pEnt->GetFunction("OnButtonSelected")->sig_function(&vList);
		}
		LogMsg("Shake!");
	}
}
Ejemplo n.º 14
0
void AdManager::OnRender()
{

#ifdef WIN32
	if (m_bShowingAd)
	{
		//draw a fake rectangle the same size as the real ad will be, this is just for testing, so you get an idea
		//of how big the ad when developing on Windows, and when it will pop up

		CL_Vec2f vRatio = CL_Vec2f(1,1);
		if (GetFakePrimaryScreenSizeX() != 0)
		{
			vRatio.x = (GetScreenSizeXf()/float(GetOriginalScreenSizeX()));
			vRatio.y =(GetScreenSizeYf()/float(GetOriginalScreenSizeY()));
		}
		rtRect r(0,0, (int)(m_vBannerSize.x*vRatio.x),(int)(m_vBannerSize.y*vRatio.y));
		
		//move to bottom
		r.AdjustPosition(0, GetScreenSizeY()-r.GetHeight());

		//center
		r.AdjustPosition( (GetScreenSizeX()-r.GetWidth())/2, 0 );
		
		DrawFilledRect(r, MAKE_RGBA(40,255,40,200));
	}
#endif

}
Ejemplo n.º 15
0
void L_ParticleEffect::create_particle(L_REAL in_x, L_REAL in_y, CL_Vec2f* vec_t)
{
	int chosen = choose_particle();

	L_Particle* par_new;
	L_NEW_PAR( par_new, *fl_particle[chosen] );

	CL_Vec2f vec_t2 = CL_Vec2f(0,0);
	if(addit_vector_enabled == true)
	{
		if(vec_t != NULL)
			vec_t2 = addit_vector + *vec_t;

		else
			vec_t2 = addit_vector;
	}

	else
	{
		if(vec_t != NULL)
			vec_t2 = *vec_t;
	}

	par_new->set_velocity(vec_t2);


	if(follow_shooting)
	{
		par_new->set_rotation(linear_get_radian(*vec_t));
	}

	else if(par_randrot_on)
	{
		par_new->set_rotation2(L_RAND_REAL_2()*L_2PI);
	}

	if(size_distortion != 0)
	{
		par_new->set_size( par_new->get_ref_size()+rand_size() );
	}

	if(life_distortion != 0)
	{
		int distort = rand() % life_distortion + 1;

		if(rand() % 2 == 0)
			distort = -distort;

		par_new->set_life(par_new->get_remaininig_life()+distort);
	}

	par_new->x_pos = in_x;
	par_new->y_pos = in_y;

	par_new->initialize();

	//add to list
	particle_list.push_back(par_new);
}
Ejemplo n.º 16
0
void App::render_gaussian_blur(CL_GraphicContext &gc, float blur_amount, CL_Texture &source_texture, CL_ProgramObject &program_object, float dx, float dy)
{
	int sampleCount = 15;

	float *sampleWeights = new float[sampleCount];
	CL_Vec2f *sampleOffsets = new CL_Vec2f[sampleCount];

	sampleWeights[0] = compute_gaussian(0, blur_amount);
	sampleOffsets[0] = CL_Vec2f(0.0, 0.0);

	float totalWeights = sampleWeights[0];

	for (int i = 0; i < sampleCount / 2; i++)
	{
		float weight = compute_gaussian(i + 1.0f, blur_amount);

		sampleWeights[i * 2 + 1] = weight;
		sampleWeights[i * 2 + 2] = weight;

		totalWeights += weight * 2;

		float sampleOffset = i * 2 + 1.5f;

		CL_Vec2f delta = CL_Vec2f(dx * sampleOffset, dy * sampleOffset);

		sampleOffsets[i * 2 + 1] = delta;
		sampleOffsets[i * 2 + 2] = CL_Vec2f(-delta.x, -delta.y);
	}

	for (int i = 0; i < sampleCount; i++)
	{
		sampleWeights[i] /= totalWeights;
	}

	program_object.set_uniform1i("SourceTexture", 0);
	program_object.set_uniformfv("SampleOffsets", 2, sampleCount, (float *)sampleOffsets);
	program_object.set_uniformfv("SampleWeights", 1, sampleCount, sampleWeights);

	gc.set_texture(0, source_texture);
	gc.set_program_object(program_object, cl_program_matrix_modelview_projection);

	draw_texture(gc, CL_Rectf(0,0,gc.get_width(),gc.get_height()), CL_Colorf::white, CL_Rectf(0.0f, 0.0f, 1.0f, 1.0f));

	gc.reset_program_object();
	gc.reset_texture(0);
}
Ejemplo n.º 17
0
CL_Vec2f GetAlignmentOffset(const CL_Vec2f &vSize, eAlignment alignment)
{
	switch (alignment)
	{

	case ALIGNMENT_UPPER_LEFT:
		return CL_Vec2f(0,0);

	case ALIGNMENT_UPPER_RIGHT:
		return CL_Vec2f(vSize.x,0);

	case ALIGNMENT_CENTER:
		return (vSize/2);
		break;
	case ALIGNMENT_DOWN_CENTER:
		return CL_Vec2f(vSize.x/2,vSize.y);
		break;
	case ALIGNMENT_UPPER_CENTER:
		return CL_Vec2f(vSize.x/2,0);
		break;
	case ALIGNMENT_DOWN_LEFT:
		return CL_Vec2f(0,vSize.y);
		break;
	case ALIGNMENT_LEFT_CENTER:
		return CL_Vec2f(0,vSize.y/2);
		break;
}

	assert(!"Unhandled alignment");
	return CL_Vec2f(0,0);
}
Ejemplo n.º 18
0
void Render::DrawRectangle( const float pX1, const float pY1, const E_TYPE_COLOR color, const float scaleX, const float scaleY )
{
	//m_surf[ color ].Blit( pX1, pY1 );

	TextureImage* img = GetBaseApp()->getAtlasManager()->findImage( RES_TYPE_COLOR_ARRAY[ color ] );

	float imgX = static_cast<float>( img->getX() );
	float imgY = static_cast<float>( img->getY() );
	float imgWidth = static_cast<float>( img->getWidth() );
	float imgHeight = static_cast<float>( img->getHeight() );

	rtRectf r( pX1, pY1, pX1 + imgWidth, pY1 + imgHeight );
	r.Scale( ALIGNMENT_CENTER, CL_Vec2f( scaleX, scaleY ) );
	rtRectf s( imgX, imgY,  imgX + imgWidth , imgY + imgHeight );
	s.Scale( ALIGNMENT_CENTER, CL_Vec2f( scaleX, scaleY ) );

	m_surface.BlitEx( r, s );
}
Ejemplo n.º 19
0
void Cliente::on_evento_juego_agrega_powerup(const CL_NetGameEvent &e)
{
	int i = e.get_argument(0);
	float x = e.get_argument(1);
	float y = e.get_argument(2);

	PowerupTipo tipos[4] = {MEDIKIT,ESCUDO,RAPIDEZ_TANQUE,DISPARO_360};

	mundo->agregarPowerup(tipos[i], CL_Vec2f(x, y));
}
Ejemplo n.º 20
0
void ScrollComponent::SetProgress(VariantList *pVList)
{
	CL_Vec2f vProg = pVList->m_variant[0].GetVector2();
	//LogMsg("Setting progress to %s", PrintVector2(vProg).c_str());
	m_vecChildPos.x = m_pBoundsRect->right - vProg.x * m_pBoundsRect->get_width();
	m_vecChildPos.y = m_pBoundsRect->bottom - vProg.y * m_pBoundsRect->get_height();

	//update it
	SetPosition(CL_Vec2f(0,0), true);
}
Ejemplo n.º 21
0
void ScrollComponent::SetIsScrolling(bool bScrolling)
{
	if (bScrolling == m_bIsScrolling) return; //no change

	m_bIsScrolling = bScrolling;

	if (!m_bIsScrolling)
	{
		m_vTotalDisplacementOnCurrentSwipe = CL_Vec2f(0,0);
	}
}
Ejemplo n.º 22
0
ShaderImpl::ShaderImpl(Shader *p_parent) :
		m_parent(p_parent),
		m_initialized(false),
		m_began(false)
{
	m_boundRect.left = 0;
	m_boundRect.top = 0;
	m_boundRect.right = Stage::getWidth();
	m_boundRect.bottom = Stage::getHeight();

	// build quad verts
	const int w = Gfx::Stage::getWidth();
	const int h = Gfx::Stage::getHeight();

	m_quadVerts = new CL_Vec2f[4];
	m_quadVerts[0] = CL_Vec2f(0, 0);
	m_quadVerts[1] = CL_Vec2f(0, 1);
	m_quadVerts[2] = CL_Vec2f(1, 1);
	m_quadVerts[3] = CL_Vec2f(1, 0);
}
Ejemplo n.º 23
0
CL_Vec2f CL_PixelCanvas::transform(const CL_Vec4f &vertex) const
{
	if (modelview_projection_invalid)
	{
		modelview_projection = projection * modelview;
		modelview_projection_invalid = false;
	}

	CL_Vec4f v = modelview_projection * vertex;
	return CL_Vec2f(v.x, v.y);
}
Ejemplo n.º 24
0
void CL_Draw::gradient_fill(CL_GraphicContext &gc, float x1, float y1, float x2, float y2, const CL_Gradient &gradient)
{
	CL_Vec2f positions[6] =
	{
		CL_Vec2f(x1, y1),
		CL_Vec2f(x2, y1),
		CL_Vec2f(x1, y2),
		CL_Vec2f(x2, y1),
		CL_Vec2f(x1, y2),
		CL_Vec2f(x2, y2)
	};

	#define cl_color_to_color4d(c) c.get_red(), c.get_green(), c.get_blue(), c.get_alpha()

	CL_Vec4f colors[6] =
	{
		CL_Vec4f(cl_color_to_color4d(gradient.top_left)),
		CL_Vec4f(cl_color_to_color4d(gradient.top_right)),
		CL_Vec4f(cl_color_to_color4d(gradient.bottom_left)),
		CL_Vec4f(cl_color_to_color4d(gradient.top_right)),
		CL_Vec4f(cl_color_to_color4d(gradient.bottom_left)),
		CL_Vec4f(cl_color_to_color4d(gradient.bottom_right))
	};

	CL_PrimitivesArray prim_array(gc);
	prim_array.set_attributes(0, positions);
	prim_array.set_attributes(1, colors);
	gc.set_program_object(cl_program_color_only);
	gc.draw_primitives(cl_triangles, 6, prim_array);
	gc.reset_program_object();
}
Ejemplo n.º 25
0
void CL_RenderBatch3D::draw_image(CL_GraphicContext &gc, const CL_Rectf &src, const CL_Rectf &dest, const CL_Colorf &color, const CL_Texture &texture)
{
	int texindex = set_batcher_active(gc, texture);
	vertices[position+0].position = to_position(dest.left, dest.top);
	vertices[position+1].position = to_position(dest.right, dest.top);
	vertices[position+2].position = to_position(dest.left, dest.bottom);
	vertices[position+3].position = to_position(dest.right, dest.top);
	vertices[position+4].position = to_position(dest.right, dest.bottom);
	vertices[position+5].position = to_position(dest.left, dest.bottom);
	float src_left = (src.left)/tex_sizes[texindex].width;
	float src_top = (src.top) / tex_sizes[texindex].height;
	float src_right = (src.right)/tex_sizes[texindex].width;
	float src_bottom = (src.bottom) / tex_sizes[texindex].height;
	vertices[position+0].texcoord = CL_Vec2f(src_left, src_top);
	vertices[position+1].texcoord = CL_Vec2f(src_right, src_top);
	vertices[position+2].texcoord = CL_Vec2f(src_left, src_bottom);
	vertices[position+3].texcoord = CL_Vec2f(src_right, src_top);
	vertices[position+4].texcoord = CL_Vec2f(src_right, src_bottom);
	vertices[position+5].texcoord = CL_Vec2f(src_left, src_bottom);
	for (int i=0; i<6; i++)
	{
		vertices[position+i].color = CL_Vec4f(color.r, color.g, color.b, color.a);
		vertices[position+i].texindex.x = (float)texindex;
	}
	position += 6;
}
Ejemplo n.º 26
0
void Cliente::on_evento_juego_agrega_tanque(const CL_NetGameEvent &e) 
{
	cl_log_event("eventos", "Agrega Tanque");
	float x = e.get_argument(0);  //Obtiene posicion 
	float y = e.get_argument(1);
	int mi_id = e.get_argument(2);
	CL_String nombre = e.get_argument(3);
	int contSubID = e.get_argument(4);
	CL_Vec2f postanque = CL_Vec2f(x,y);
	mundo->quitarTanque(0); //Se quita y se agrega el jugador
	mundo->agregarTanque(mi_id,DEFAULT,nombre,true,false,postanque,0.0f,0.0f);
	mundo->setSubID(contSubID);
}
Ejemplo n.º 27
0
void TextBoxRenderComponent::OnAdd(Entity *pEnt)
{
	EntityComponent::OnAdd(pEnt);

	//shared with the rest of the entity
	
	m_pPos2d = &GetParent()->GetVar("pos2d")->GetVector2();
	m_pSize2d = &GetParent()->GetVarWithDefault("size2d", CL_Vec2f(300,200))->GetVector2();
	m_pEnclosedSize2d = &GetParent()->GetVarWithDefault("enclosedSize2d", CL_Vec2f(0,0))->GetVector2();
	m_pScale2d = &GetParent()->GetVarWithDefault("scale2d", Variant(1.0f, 1.0f))->GetVector2();
	m_pAlignment = &GetParent()->GetVar("alignment")->GetUINT32();
	m_pColor = &GetParent()->GetVarWithDefault("color", Variant(MAKE_RGBA(255,255,255,255)))->GetUINT32();
	m_pColorMod = &GetParent()->GetVarWithDefault("colorMod", Variant(MAKE_RGBA(255,255,255,255)))->GetUINT32();
	m_pAlpha = &GetParent()->GetVarWithDefault("alpha", Variant(1.0f))->GetFloat();
	m_pTimingSystem = &GetParent()->GetVarWithDefault("timingSystem", Variant(uint32(GetBaseApp()->GetActiveTimingSystem())))->GetUINT32();

	//our own stuff
	m_pFontScale = &GetVarWithDefault("fontScale", Variant(1.0f))->GetFloat();
	m_pEffectPower = &GetVarWithDefault("effectPower", Variant(30.0f))->GetFloat();
	m_pStyle = &GetVarWithDefault("style", Variant(uint32(STYLE_NORMAL)))->GetUINT32();
	
	//this controls the alignment of the wrapped text within the text rect, not the text rect itself!
	m_pTextAlignment = &GetVarWithDefault("textAlignment", (uint32)ALIGNMENT_UPPER_LEFT)->GetUINT32();
	GetVar("textAlignment")->GetSigOnChanged()->connect(1, boost::bind(&TextBoxRenderComponent::OnTextAlignmentChanged, this, _1));

	m_pText = &GetVar("text")->GetString(); //local to us
	GetVar("text")->GetSigOnChanged()->connect(1, boost::bind(&TextBoxRenderComponent::OnTextChanged, this, _1));

	m_pFontID = &GetVarWithDefault("font", uint32(FONT_SMALL))->GetUINT32();
	GetVar("font")->GetSigOnChanged()->connect(1, boost::bind(&TextBoxRenderComponent::OnFontChanged, this, _1));

	pEnt->GetVar("scale2d")->GetSigOnChanged()->connect(1, boost::bind(&TextBoxRenderComponent::OnScaleChanged, this, _1));

	//register ourselves to render if the parent does
	pEnt->GetFunction("OnRender")->sig_function.connect(1, boost::bind(&TextBoxRenderComponent::OnRender, this, _1));

	m_pShadowColor = &GetVarWithDefault("shadowColor", Variant(MAKE_RGBA(0,0,0,0)))->GetUINT32();

}
Ejemplo n.º 28
0
void TestApp::test_triangle(void)
{
	CL_Console::write_line(" Header: triangle_math.h");
	CL_Console::write_line("  Class: CL_Triangle");

	CL_Console::write_line("   Function: point_inside()");
	{
		CL_Trianglef triangle( CL_Vec2f(8.0f, 8.0f), CL_Vec2f(12.0f, 12.0f), CL_Vec2f(-1.0f, 14.0f));
		if (!triangle.point_inside(CL_Vec2f(6.0f, 11.0f))) fail();
		if (triangle.point_inside(CL_Vec2f(4.0f, 9.0f))) fail();
		if (triangle.point_inside(CL_Vec2f(10.0f, 9.0f))) fail();
		if (triangle.point_inside(CL_Vec2f(8.0f, 13.0f))) fail();
	}
}
Ejemplo n.º 29
0
void CL_RenderBatch3D::fill(CL_GraphicContext &gc, float x1, float y1, float x2, float y2, const CL_Colorf &color)
{
	int texindex = set_batcher_active(gc);
	vertices[position+0].position = to_position(x1, y1);
	vertices[position+1].position = to_position(x2, y1);
	vertices[position+2].position = to_position(x1, y2);
	vertices[position+3].position = to_position(x2, y1);
	vertices[position+4].position = to_position(x2, y2);
	vertices[position+5].position = to_position(x1, y2);
	for (int i=0; i<6; i++)
	{
		vertices[position+i].color = CL_Vec4f(color.r, color.g, color.b, color.a);
		vertices[position+i].texcoord = CL_Vec2f(0.0f, 0.0f);
		vertices[position+i].texindex.x = (float)texindex;
	}
	position += 6;
}
Ejemplo n.º 30
0
void Cliente::on_evento_juego_jugador_conectado(const CL_NetGameEvent &e)
{	
	//Datos del tanque conectado
	int idtanque = e.get_argument(0);

	if(mundo->getTanqueID(idtanque) == NULL)
	{
		float x = e.get_argument(1);
		float y = e.get_argument(2);
		float angulo = e.get_argument(3);
		float angulotorreta = e.get_argument(4);
		CL_String nombre = e.get_argument(5);

		CL_Vec2f postanque = CL_Vec2f(x,y);
		mundo->agregarTanque(idtanque,DEFAULT,nombre,false,false,postanque,angulo,angulotorreta); //Agrega el tanque nuevo	
	}
}