Ejemplo n.º 1
0
	bool Mob::isinrange(const rectangle2d<int16_t>& range) const
	{
		if (!active)
			return false;

		rectangle2d<int16_t> bounds = animations.at(stance).getbounds();
		bounds.shift(getposition());
		return range.overlaps(bounds);
	}
Ejemplo n.º 2
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();
		}
Ejemplo n.º 3
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())
					)));
			}
		}
	}