PDA

View Full Version : problem



matej
11-19-2011, 03:31 PM
Hy all i have got problem.
My ship shot very strange, plise help me what i must change and it will shoot normaly
http://www.shrani.si/f/2d/13J/35Uhj9SD/strel.gif
thanks all


That is code:
class metki
{public:
double vx, vy, x, y, r ,strel;
int smer;
// int direction;
metki() {
r = 0.07;
vx=5.55;
vy = 0.55;
// direction = 0;
}
~metki();
void move() {

x=ship->x;
y=ship->y;
smer=ship->direction;
int i=0;
do
{
draw();

// y += cos(smer*PI/180)*0.01;
x+= 0.001;

i++;

// Sleep(10);

//preverjanjeali metek trkne ob ladjo;

double dx = Montazna_ladja->ladx - x;
double dy = Montazna_ladja->lady - y;
double ar = Montazna_ladja->ladr + r;
if(dx*dx + dy*dy < ar*ar)
{

ship->reset();
// Montazna_ladja= new montazna_ladja();
}
//glutPostRedisplay();


}
while(i<750);


/* if (x > (1.0 + r) || x < (-1.0 - r))
x = -x;
if (y > (1.0 + r) || y < (-1.0 - r))
y = -y;

*/
//y+= vy/FPS;
}
void draw() {

glBegin(GL_POLYGON);
glColor3d(0.5, 0.5, 0.5);
glVertex2f(sin((0 + smer)*PI/180)*r+x, cos((0 + smer)*PI/180)*r+y);
glVertex2f(sin((140 + smer)*PI/180)*r+x, cos((140 + smer)*PI/180)*r+y);
glVertex2f(sin((180 + smer)*PI/180)*r/4+x, cos((180 + smer)*PI/180)*r/4+y);
glVertex2f(sin((220 + smer)*PI/180)*r+x, cos((220 + smer)*PI/180)*r+y);
glEnd();
//glClearColor(0, 0, 0, 0);
glBindTexture(GL_TEXTURE_2D,5);

/*
glPushMatrix();
glTranslated(x,y,0);
// glColor1d(1);
glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex2d(-.05,-.05);
glTexCoord2d(1,0); glVertex2d(+.05,-.05);
glTexCoord2d(1,1); glVertex2d(+.05,+.05);
glTexCoord2d(0,1); glVertex2d(-.05,+.05);
glEnd();
glPopMatrix();
glBindTexture(GL_TEXTURE_2D,0);
*/
}

};
metki *Metki;

BionicBytes
11-20-2011, 07:14 AM
i have got problem.

Yes you have. You have a pile of undocumented crap.
Do you seariously expect someone to workout what you are trying to do in your code - with out comments, explaination or useful variable names?

Alfonse Reinheart
11-20-2011, 10:11 AM
To be fair, I'm sure those variable names are more useful in whatever language he natively speaks. But he still needs to explain what this code actually does.

matej
11-20-2011, 11:13 AM
Ok i declarate class metki (bullet) in this class i want draw real bullet but i drow onlly
http://www.shrani.si/f/2d/13J/35Uhj9SD/strel.gif
this..
that is very strange
that is move bullet
do
{
draw();

// y += cos(smer*PI/180)*0.01;
x+= 0.001;

i++;

// Sleep(10);

//preverjanjeali metek trkne ob ladjo;

double dx = Montazna_ladja->ladx - x;
double dy = Montazna_ladja->lady - y;
double ar = Montazna_ladja->ladr + r;
if(dx*dx + dy*dy < ar*ar)
{

ship->reset();
// Montazna_ladja= new montazna_ladja();
}
//glutPostRedisplay();


}
while(i<750);

matej
11-20-2011, 11:15 AM
that is deaw my bullet

void draw() {

glBegin(GL_POLYGON);
glColor3d(0.5, 0.5, 0.5);
glVertex2f(sin((0 + smer)*PI/180)*r+x, cos((0 + smer)*PI/180)*r+y);
glVertex2f(sin((140 + smer)*PI/180)*r+x, cos((140 + smer)*PI/180)*r+y);
glVertex2f(sin((180 + smer)*PI/180)*r/4+x, cos((180 + smer)*PI/180)*r/4+y);
glVertex2f(sin((220 + smer)*PI/180)*r+x, cos((220 + smer)*PI/180)*r+y);
glEnd();
//glClearColor(0, 0, 0, 0);
glBindTexture(GL_TEXTURE_2D,5);