Я должен разработать игру, в которой пользователь стреляет в мяч из пушки. Для этого мне нужно иметь возможность вращать пушку (прямоугольник) и стрелять с разных углов. Не могли бы вы мне помочь?Как повернуть прямоугольник в x11/C
Cheers!
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;
}