将数组从一个类传递到另一个类

时间:2017-11-26 15:25:17

标签: c++ arrays allegro

我遇到的问题是,所以我在块类中在游戏中创建了块:

void Block::CreateBlocks() {
int count = 0;
coordinateX[0] = START_FLOOR_X;
coordinateY[0] = START_FLOOR_Y;
width[0] = al_get_bitmap_width(floorbmp);
for (int i = 1; i < MAX_BLOCKS; i++) {
    width[i] = (rand() % MAX_RANDOM_X_SIZE) + MIN_RANDOM_X_SIZE;
    while (width[i] > MAX_RANDOM_X_SIZE) {
        width[i] = (rand() % MAX_RANDOM_X_SIZE) + MIN_RANDOM_X_SIZE;
    }
}
for (int i = 1; i < MAX_BLOCKS; i++) {
            coordinateX[i] = rand() % START_OF_RIGHT_WALL;
            while (coordinateX[i] < WALL_WIDTH || coordinateX[i] + width[i] >= START_OF_RIGHT_WALL) {
                coordinateX[i] = rand() % START_OF_RIGHT_WALL;
            }
        coordinateY[i] = 430 - count * 116;
        count++;
    }

} 现在,我想创建 class Bonus ,在那里我将读取单个块的X,Y位置,然后我将在其上创建 Bonus 。 问题是,我如何阅读这些数组: 奖励等级块类 coordinateX,coordinateY,width

谢谢!

0 个答案:

没有答案