Example #1
0
void psTextAt(struct psGfx *ps, double x, double y, char *text)
/* Output text in current font at given position. */
{
psMoveTo(ps, x, y + ps->fontHeight);
fprintf(ps->f, "(");
psTextOutEscaped(ps, text);
fprintf(ps->f, ") show\n");
}
Example #2
0
void psTextDown(struct psGfx *ps, double x, double y, char *text)
/* Output text going downwards rather than across at position. */
{
psMoveTo(ps, x, y);
fprintf(ps->f, "gsave\n");
fprintf(ps->f, "-90 rotate\n");
fprintf(ps->f, "(%s) show\n", text);
fprintf(ps->f, "grestore\n");
}
Example #3
0
void psTextRight(struct psGfx *ps, double x, double y, 
	double width, double height, 
	char *text)
/* Draw a line of text right justified in box defined by x/y/width/height */
{
y += (height - ps->fontHeight)/2;
psMoveTo(ps, x+width, y + ps->fontHeight);
fprintf(ps->f, "(%s) showBefore\n", text);
}
Example #4
0
void psDrawLine(struct psGfx *ps, double x1, double y1, double x2, double y2)
/* Draw a line from x1/y1 to x2/y2 */
{
FILE *f = ps->f;
fprintf(f, "newpath\n");
psMoveTo(ps, x1, y1);
psXyOut(ps, x2, y2);
fprintf(ps->f, "lineto\n");
fprintf(f, "stroke\n");
}
Example #5
0
void psTextCentered(struct psGfx *ps, double x, double y, 
	double width, double height, 
	char *text)
/* Draw a line of text centered in box defined by x/y/width/height */
{
y += (height - ps->fontHeight)/2;
psMoveTo(ps, x+width/2, y + ps->fontHeight);
fprintf(ps->f, "(");
psTextOutEscaped(ps, text);
fprintf(ps->f, ") showMiddle\n");
}
Example #6
0
void psTextAt(struct psGfx *ps, double x, double y, char *text)
/* Output text in current font at given position. */
{
char c;
psMoveTo(ps, x, y + ps->fontHeight);
fprintf(ps->f, "(");
while ((c = *text++) != 0)
    {
    if (c == ')' || c == '(')
        fprintf(ps->f, "\\");
    fprintf(ps->f, "%c", c);
    }
fprintf(ps->f, ") show\n");
}
Example #7
0
void psFillUnder(struct psGfx *ps, double x1, double y1, 
	double x2, double y2, double bottom)
/* Draw a 4 sided filled figure that has line x1/y1 to x2/y2 at
 * it's top, a horizontal line at bottom at it's bottom,  and
 * vertical lines from the bottom to y1 on the left and bottom to
 * y2 on the right. */
{
FILE *f = ps->f;
fprintf(f, "newpath\n");
psMoveTo(ps, x1, y1);
psLineTo(ps, x2, y2);
psLineTo(ps, x2, bottom);
psLineTo(ps, x1, bottom);
fprintf(f, "closepath\n");
fprintf(f, "fill\n");
}
Example #8
0
void psTextCentered(struct psGfx *ps, double x, double y, 
	double width, double height, 
	char *text)
/* Draw a line of text centered in box defined by x/y/width/height */
{
char c;
y += (height - ps->fontHeight)/2;
psMoveTo(ps, x+width/2, y + ps->fontHeight);
fprintf(ps->f, "(");
while ((c = *text++) != 0)
    {
    if (c == ')' || c == '(')
        fprintf(ps->f, "\\");
    fprintf(ps->f, "%c", c);
    }
fprintf(ps->f, ") showMiddle\n");
}
Example #9
0
void psDrawPoly(struct psGfx *ps, struct psPoly *poly, boolean filled)
/* Draw a possibly filled polygon */
{
FILE *f = ps->f;
struct psPoint *p = poly->ptList;
fprintf(f, "newpath\n");
psMoveTo(ps, p->x, p->y);
for (;;)
    {
    p = p->next;
    psLineTo(ps, p->x, p->y);
    if (p == poly->ptList)
	break;
    }
if (filled)
    {
    fprintf(f, "fill\n");
    }
else
    {
    fprintf(f, "closepath\n");
    fprintf(f, "stroke\n");
    }
}
Example #10
0
void Magic::update(float deltaTime)
{

	if (!isAttacking) return;

	switch(attackType)
	{
		case POINT_TO_POINT_ATTACK:
		{
				device = manager->getCore()->getGraphicDevice();

				tickTime = device->getTimer()->getRealTime();
				subTime = tickTime - beginTime;

				if(subTime < idleTime) //Do nothing
				{
					//Do nothing in idle time
					if(magicLight->isVisible())
						magicLight->setVisible(false);
				}
				else if(subTime < preTime + idleTime) //Make the magic bigger or change color or animated it
				{
					//Scalar

					//magicLight->setScale(newScale);
					if(!magicLight->isVisible())
						magicLight->setVisible(true);

					//Rotate

					//Animation
					magicLight->setPosition(this->vPostition);
				}
				else if(subTime < TTL + preTime + idleTime) //The magic is fired, fly to the enemy
				{
					//! Target is reached
					if( magicLight->getPosition().getDistanceFrom(vTargetPostion) <= speed*deltaTime) 
					{
						isAttacking = false;	
						magicLight->setVisible(false);
						CurrentAction = "End";
						return;
					}

					//! Fly until TTL
					magicLight->setRotation( psfaceTarget(vTargetPostion, magicLight->getPosition()));

					speed += speedDelta;

					//! TODO: Change funtion to define magic's quy dao
					psMoveTo(magicLight, core::vector3df(0.0f, 0.0f, speed*deltaTime));

				}
				else
				{
					isAttacking = false;	
					magicLight->setVisible(false);
				}			
			}

			/////////////////////////////////////////////////////////////////////////////////////////
			/////////////////////////////////////////////////////////////////////////////////////////	
			case NODE_TO_POINT_ATTACK:
			{
				device = manager->getCore()->getGraphicDevice();

				tickTime = device->getTimer()->getRealTime();
				subTime = tickTime - beginTime;

				if(subTime < idleTime) //Do nothing
				{
					//Do nothing in idle time
					if(magicLight->isVisible())
						magicLight->setVisible(false);
				}
				else if(subTime < preTime + idleTime) //Make the magic bigger or change color or animated it
				{
					//Scalar

					//magicLight->setScale(newScale);
					if(!magicLight->isVisible())
						magicLight->setVisible(true);

					//Rotate

					//Animation
					//magicLight->setPosition(targetNode->getAbsolutePosition());
				}
				else if(subTime < TTL + preTime + idleTime) //The magic is fired, fly to the enemy
				{
					//! Target is reached
					if( magicLight->getPosition().getDistanceFrom(vTargetPostion) <= speed*deltaTime) 
					{
						isAttacking = false;	
						magicLight->setVisible(false);
						CurrentAction = "End";
						return;
					}

					//! Fly until TTL
					magicLight->setRotation( psfaceTarget(vTargetPostion, magicLight->getPosition()));

					speed += speedDelta;

					//! TODO: Change funtion to define magic's quy dao
					psMoveTo(magicLight, core::vector3df(0.0f, 0.0f, speed*deltaTime));

				}
				else
				{
					isAttacking = false;	
					magicLight->setVisible(false);
				}		

			}
	}
	
}