0
OpenGL과 C를 사용하여 2D 비디오 게임을 만들고 있는데 문제가 있습니다. 특정 숫자의 오브젝트를 만들려고합니다. 100이라고 가정 해 봅시다. 임의의 속도와 방향으로 돌아 다니다.하지만 작동하지 않으며 더 나은 방법이 있다고 확신 할 수 있습니다.하지만 알아낼 수는 없습니다.OpenGL - 임의 방향으로 움직이는 물체
는 지금까지 내가 100 번 그려하려는 것은 내 클래스입니다 :
#include "stdafx.h"
#include <math.h>
#ifndef _THING_H
#define _THING_H
class thingClase {
public:
float ypos, xpos, zpos;
float count;
thingClase() {
xpos = rand()%80;
ypos = rand()%80;
zpos = 1;
count = 1;
}
};
thingClase thing[100];
int thingNum = 0;
int thingTotal = 100;
int width = 1;
bool alive;
#endif /* _THING_H */
그리고 내 주요 기능을하는이 포함되어 있습니다 : 그래서
void drawThing() {
for (thingNum = 0; thingNum < thingTotal; thingNum++) {
glPushMatrix();
glTranslated(thing[thingNum].xpos, thing[thingNum].ypos, thing[thingNum].zpos);
glPopMatrix();
}
}