0
我应该开发一个游戏,用户从大炮射出一个球。为此,我需要能够旋转大炮(矩形)并从不同角度拍摄。你可以帮我吗?我该如何在x11/C中旋转一个矩形?
干杯!
typedef struct _Cannon {
\t \t int x, y, w, h;
}Cannon;
typedef struct _Ball{
\t int itx, ity; //size
\t float ix, iy; //position
\t float vx, vy; //velocity
\t float gr; \t //gravity
}Ball;
Cannon cannon = {60, 400, 114, 33};
Ball ball = {
\t 0,0,
\t cannon.x+cannon.w*0.8,cannon.y+cannon.h/5,
\t 17.0, 0,
\t 0.3
\t };
XSetForeground(XApp->getDisplay(), GCAtr->getGC(),
GCAtr->getColor(2));
XFillRectangle(XApp->getDisplay(), XApp->getWindow(), GCAtr->getGC(),cannon.x,cannon.y,cannon.w,cannon.h);
void calculate()
{
\t double dt;
\t dt = XApp->getDifTime();
\t
\t //Calculates the position of the ball
\t ball.vy += ball.gr * dt;
\t ball.iy += ball.vy * dt;
\t ball.ix += ball.vx * dt;
}