Exemplo n.º 1
0
	mesodrop::mesodrop(short o, animation* ani, int own, vector2d pos, vector2d dst, char type, bool pld)
	{
		oid = o;
		anim = ani;
		owner = own;
		pickuptype = type;
		playerdrop = pld;

		fx = static_cast<float>(pos.x());
		fy = static_cast<float>(pos.y());

		updatefht();

		dalpha = 1.0f;
		alpha = 1.0f;
		moved = 0.0f;

		if (pos == dst)
		{
			state = DST_FLOATING;
			vspeed = 0;
			hspeed = 0;
			basey = fy;
		}
		else
		{
			state = DST_DROPPED;
			vspeed = -6.0f;
			hspeed = static_cast<float>(dst.x() - pos.x()) / 16;
		}
	}
buw::vector2d OpenInfraPlatform::Infrastructure::VerticalAlignmentElement2DArc::Rotate(const double angle, const vector2d& v) const
{
	return buw::vector2d(
		std::cos(angle) * v.x() - std::sin(angle) * v.y(),
		std::sin(angle) * v.x() + std::cos(angle) * v.y()
	);
}
Exemplo n.º 3
0
	int32_t Footholdtree::getlwall(vector2d<int32_t> pos) const
	{
		int32_t ret = walls.x();
		vector2d<int32_t> ver = vector2d<int32_t>(pos.y() - 80, pos.y() - 20);
		for (map<uint16_t, Foothold>::const_iterator ftit = footholds.begin(); ftit != footholds.end(); ++ftit)
		{
			Foothold fh = ftit->second;
			if (fh.getver().overlaps(ver) && fh.iswall())
			{
				int32_t x = fh.getl();
				if (x > ret && x <= pos.x())
				{
					ret = x;
				}
			}
		}
		return ret;
	}
Exemplo n.º 4
0
		void draw(size_t id, rectangle2d<int16_t> rect, float xscale, 
			float yscale, vector2d<int16_t> center, float alpha) {

			if (!available(id))
				return;

			GLfloat left = center.x() + xscale * (rect.l() - center.x());
			GLfloat right = center.x() + xscale * (rect.r() - center.x());
			GLfloat top = center.y() + yscale * (rect.t() - center.y());
			GLfloat bottom = center.y() + yscale * (rect.b() - center.y());

			glBindTexture(GL_TEXTURE_2D, bitmaps[id]);
			glBegin(GL_QUADS);
			glTexCoord2f(0, 0); glVertex3f(left, top, 0);
			glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
			glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
			glTexCoord2f(1, 0); glVertex3f(right, top, 0);
			glEnd();
		}
Exemplo n.º 5
0
	void imagecache::draw(imgcontext ict, size_t id, D2D1_RECT_F r, float alpha, float xscale, float yscale, vector2d center)
	{
		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(xscale, yscale),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));

		draw(ict, id, r, alpha);

		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(1.0f, 1.0f),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));
	}
Exemplo n.º 6
0
	float footholdtree::getgroundbelow(vector2d pos)
	{
		foothold ret;
		float ycomp = 65536;
		pos = pos - vector2d(0, 5);
		for (map<short, foothold>::iterator ftit = footholds.begin(); ftit != footholds.end(); ftit++)
		{
			if (ftit->second.horizontal.contains(pos.x()))
			{
				float y;
				if (ftit->second.isfloor())
				{
					y = static_cast<float>(ftit->second.vertical.x());
				}
				else
				{
					float step = static_cast<float>((ftit->second.vertical.y() - ftit->second.vertical.x())) / (ftit->second.horizontal.y() - ftit->second.horizontal.x());
					y = static_cast<float>(ftit->second.vertical.x() + (step * (pos.x() - ftit->second.horizontal.x())));
				}

				if (ycomp > y && y > pos.y())
				{
					ret = ftit->second;
					ycomp = y;
				}
			}
		}

		ground = ret;
		return ycomp;
		

		/*int closest = lowestg;
		pos = pos - vector2d(0, 5);

		for (vector<map<short, short>>::iterator pfit = platforms.begin(); pfit != platforms.end(); ++pfit)
		{
			if (pfit->count(pos.x()))
			{
				int py = pfit->at(pos.x());

				if (py <= closest && py >= pos.y())
				{
					closest = py;
				}
			}
		}

		return static_cast<float>(closest);*/
	}
Exemplo n.º 7
0
bool vector2d::operator!=(const vector2d& other)
{
	int i = 0;

	if (afData[0] == other.x())
	{
		i++;
	}
	if (afData[1] == other.y())
	{
		i++;
	}
	return i != 2;
}
Exemplo n.º 8
0
	void BitmapWrapperD2D::draw(rectangle2d<int32_t> rect, float_t xscale, float_t yscale, vector2d<int32_t> center, float_t alpha) const
	{
		ID2D1BitmapRenderTarget* target = Graphics::locator.gettarget();
		if (target)
		{
			bool transform = (xscale != 1.0f) || (yscale != 1.0f);

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(xscale, yscale),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}

			if (source)
			{
				D2D_RECT_F r = D2D1::RectF((FLOAT)rect.l(), (FLOAT)rect.t(), (FLOAT)rect.r(), (FLOAT)rect.b());
				target->DrawBitmap(source, r, alpha);
			}

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(1.0f, 1.0f),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}
		}
	}
Exemplo n.º 9
0
	void TextWrapperGL::draw(vector2d<int32_t> pos) const
	{
		const FontsFT* fonts = LocatorGL::getfonts();
		if (false)
		{
			const FT_Face* fontface = fonts->getfont(font);
			if (*fontface)
			{
				float x = static_cast<float>(pos.x());
				float y = static_cast<float>(pos.y());

				//glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

				for (size_t i = 0; i < str.size(); i++)
				{
					int8_t ch = str[i];
					FT_GlyphSlot g = (*fontface)->glyph; 
					
					FT_UInt  glyph_index = FT_Get_Char_Index(*fontface, ch);

					if (FT_Load_Glyph(*fontface, glyph_index, FT_LOAD_DEFAULT) == FT_Err_Ok)
					{
						if (FT_Render_Glyph(g, FT_RENDER_MODE_NORMAL) == FT_Err_Ok)
						{
							glBindTexture(GL_TEXTURE_2D, texture);
							glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g->bitmap.width, g->bitmap.rows, 0, GL_RED, GL_UNSIGNED_BYTE, g->bitmap.buffer);

							x += g->advance.x >> 6;
						}
					}
				}

				/*glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				GLfloat left = pos.x();
				GLfloat right = pos.x() + x;
				GLfloat top = y;
				GLfloat bottom = y + 14;

				glBegin(GL_QUADS);
				glTexCoord2f(0, 0); glVertex3f(left, top, 0);
				glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
				glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
				glTexCoord2f(1, 0); glVertex3f(right, top, 0);
				glEnd();*/
			}
		}
Exemplo n.º 10
0
	foothold footholdtree::getbelow(vector2d pos)
	{
		foothold ret;
		float comp = 65536;
		pos = pos - vector2d(0, 10);

		for (map<short, foothold>::iterator ftit = footholds.begin(); ftit != footholds.end(); ftit++)
		{
			foothold fh = ftit->second;

			if (fh.hcontains(pos.x()))
			{
				float y = fh.resolvex(pos.x());

				if (comp > y && y > pos.y())
				{
					ret = fh;
					comp = y;
				}
			}
		}

		return ret;
	}
Exemplo n.º 11
0
	vector2d vector2d::operator + (vector2d v)
	{
		return vector2d(a + v.x(), b + v.y());
	}
Exemplo n.º 12
0
	void Player::setposition(vector2d<int32_t> pos)
	{
		phobj.fx = static_cast<float>(pos.x());
		phobj.fy = static_cast<float>(pos.y());
	}
Exemplo n.º 13
0
	vector2d vector2d::operator * (vector2d v)
	{
		return vector2d(a * v.x(), b * v.y());
	}
Exemplo n.º 14
0
vector2d vector2d::multiply(const vector2d& other) const
{
	vector2d multiply(afData[0] * other.x(), afData[1] * other.y());
	return multiply;
}
Exemplo n.º 15
0
vector2d vector2d::add(const vector2d& other) const
{
	vector2d add(afData[0] + other.x(), afData[1] + other.y());
	return add;
}
Exemplo n.º 16
0
vector2d vector2d::subtract(const vector2d& other) const
{
	vector2d subtract(afData[0] - other.x(), afData[1] - other.y());
	return subtract;
}
Exemplo n.º 17
0
float vector2d::crossProduct(const vector2d& other) const
{
	float crossProduct = (afData[0] * other.y() - afData[1] * other.x());
	return crossProduct;
}
Exemplo n.º 18
0
float vector2d::dotProduct(const vector2d& other) const
{
	float dotProduct = (afData[0] * other.x()) + (afData[1] * other.y());
	return dotProduct;
}
Exemplo n.º 19
0
void vector2d::set(vector2d vector)
{
	afData[0] = vector.x();
	afData[1] = vector.y();
}
Exemplo n.º 20
0
	vector2d vector2d::operator / (vector2d v)
	{
		int x = (v.x() == 0) ? 1 : v.x();
		int y = (v.y() == 0) ? 1 : v.y();
		return vector2d(a / x, b / y);
	}
Exemplo n.º 21
0
bool vector2d::operator==(const vector2d& other)
{
	return afData[0] == other.x() && afData[1] == other.y();
}
Exemplo n.º 22
0
	vector2d vector2d::operator - (vector2d v)
	{
		return vector2d(a - v.x(), b - v.y());
	}
Exemplo n.º 23
0
	bool vector2d::operator == (vector2d v)
	{
		return a == v.x() && b == v.y();
	}
Exemplo n.º 24
0
	bool vector2d::operator != (vector2d v)
	{
		return a != v.x() || b != v.y();
	}