예제 #1
0
파일: world.cpp 프로젝트: prataimun/room
void World::mouseMotion(int x, int y) {
    double zxDeg = (width/2 - x) / 11.0;
    double xyDeg = (height/2 - y) / 11.0;
    if (trackMouse && (zxDeg != 0 || xyDeg != 0 )) {
        victor.rotateHorizontal(zxDeg);
        victor.rotateVertical(xyDeg);
        glutWarpPointer(width/2, height/2);
        movePerson(&victor, width, height);
        glutPostRedisplay();
    }
}
예제 #2
0
파일: main.c 프로젝트: damys/c-lab
int main(int argc, const char * argv[]) {
 
    while (1) {
        system("clear");
        // 1. 根据map数据打印出地图
        showMap();
        
        // 2. 接收输入小人的前进方向
        char dir = enterDirection();
        
        // 3. 根据小人前进的方向,来移动小人或者推箱子
        if(dir == 'q'){
            printf("Game Over ~ ");
            return 0;
        }else{
            movePerson(dir);
        }
    }
    
    return 0;
}
예제 #3
0
파일: world.cpp 프로젝트: prataimun/room
void World::init(int width, int height) {
    this->width = width;
    this->height = height;
    controls['w'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->moveForward(0.1); movePerson(person, width, height);});
    controls['a'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->strafeRight(-0.1); movePerson(person, width, height);});
    controls['s'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->moveForward(-0.1); movePerson(person, width, height);});
    controls['d'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->strafeRight(0.1); movePerson(person, width, height);});
    controls['q'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->ascend(0.1); movePerson(person, width, height);});
    controls['e'] = std::make_pair(nullOperation,
            [] (double passed_time, int width, int height, Person *person)
            {person->ascend(-0.1); movePerson(person, width, height);});
    trackMouse = false;
    lastClock = clock();
}
예제 #4
0
파일: world.cpp 프로젝트: prataimun/room
void World::reshape(int width, int height) {
    this->width = width;
    this->height = height;
    movePerson(&victor, width, height);
}