//Timer interrupt for the game. void timer_interrupt_handler() { if(!paused) { secondTimer++; alienMarchTimer++; bulletMoveTimer++; controllerTimer++; if(getShipAlive()) shipMoveTimer++; } tankMoveTimer++; //Poll the buttons if(tankMoveTimer >= TANK_SPEED) { handleButton(currentButtonState); handleSwitches(currentSwitchesState); } if(controllerTimer >= POLL_CONTROLLER_TIMER) { controllerTimer = 0; //readController(); } //Advance the aliens and fire bullets if(alienMarchTimer >= ALIEN_MARCH_SPEED) { alienMarch(); if(rand() % BULLET_CHANCE == 0) { fireAlienBullet(); } alienMarchTimer = 0; } //Advance the bullets if(bulletMoveTimer >= BULLET_SPEED) { bulletMove(); bulletMoveTimer = 0; } //Move the saucer if it is active if(getShipActive()&&!getPaused()) { setSound(ufolowpitch_getSound(),ufolowpitch_getNumFrames(), SAUCER_PRIORITY); if(shipMoveTimer >= SHIP_MOVE_MAX_TIMER) { shipMoveTimer = 0; marchShip(); } } //If the saucer is killed flash the score animation if(getMothershipKilled() && saucerFlash == 0) { saucerFlash = 1; } //If the saucer is killed flash the score animation if(saucerFlash > 0) { //Paint score if(secondTimer == HALF_SECOND) { setSound(ufohighpitch_getSound(),ufohighpitch_getNumFrames(), SAUCER_DEATH_PRIORITY); paintShipScore(1); saucerFlash++; } //paint black if(secondTimer == SECOND_TIMER_MAX) { paintShipScore(0); saucerFlash++; } if(saucerFlash >= 7) { paintShipScore(0); saucerFlash = 0; setMothershipKilled(0); if(getShipDirection()) { setShipPos(-SHIP_WIDTH); setShipDirection(1); } else { setShipPos(SCREEN_WIDTH + SHIP_WIDTH); setShipDirection(0); } } } //Spawn the saucer every X seconds if(saucerTime == 10 && !paused) { saucerTime = 0; if(!getShipActive() && saucerFlash == 0) { setShipActive(1); setShipAlive(1); setMothershipKilled(0); } } //Tic the clock one second if(secondTimer >= SECOND_TIMER_MAX) { secondTimer = 0; gameRunTime++; saucerTime++; } }
int GStreamerPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 13) qt_static_metacall(this, _c, _id, _a); _id -= 13; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 13) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 13; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getBrightness(); break; case 1: *reinterpret_cast< int*>(_v) = getContrast(); break; case 2: *reinterpret_cast< int*>(_v) = getHue(); break; case 3: *reinterpret_cast< int*>(_v) = getSaturation(); break; case 4: *reinterpret_cast< bool*>(_v) = getPlaying(); break; case 5: *reinterpret_cast< bool*>(_v) = getPaused(); break; case 6: *reinterpret_cast< bool*>(_v) = getStopped(); break; default: break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setBrightness(*reinterpret_cast< int*>(_v)); break; case 1: setContrast(*reinterpret_cast< int*>(_v)); break; case 2: setHue(*reinterpret_cast< int*>(_v)); break; case 3: setSaturation(*reinterpret_cast< int*>(_v)); break; case 4: setPlaying(*reinterpret_cast< bool*>(_v)); break; case 5: setPaused(*reinterpret_cast< bool*>(_v)); break; case 6: setStopped(*reinterpret_cast< bool*>(_v)); break; default: break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 7) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
void InputManager::poll() { XEvent newEvent; /* If there aren't any X events pending, return. */ if (XPending(dpy) == 0) { return; } XNextEvent(dpy, &newEvent); switch(newEvent.type) { case KeyPress: if (XLookupKeysym(&newEvent.xkey, 0) == XK_q) { std::cout << "Q pressed. Quitting." << std::endl; exit(0); } if (XLookupKeysym(&newEvent.xkey, 0) == XK_p) { std::cout << "P pressed." << std::endl; auto clock = parent->clock(); if (clock->getPaused()) { std::cout << "Setting paused to false." << std::endl; clock->setPaused(false); } else { std::cout << "Setting paused to true." << std::endl; clock->setPaused(true); } } if (XLookupKeysym(&newEvent.xkey, 0) == XK_Return) { std::cout << "You hit enter!" << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_space) { auto objects = parent->getSimWorld()->getObjects(); auto obj = objects[0]->getState(); obj->setVelocity(vec3(velocity*cos(angle),velocity*sin(angle),0)); std::cout << "You hit space!" << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_Up) { angle = clamp(angle+PI/10,-2*PI,2*PI); std::cout << "You hit up!" << angle << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_Down) { angle = clamp(angle-PI/10,-2*PI,2*PI); std::cout << "You hit down!" << angle << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_Left) { velocity = clamp(velocity-1,0,10); std::cout << "You hit left!" << velocity << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_Right) { velocity = clamp(velocity+1,0,10); std::cout << "You hit right!" << velocity << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_1) { std::cout << "You hit 1!" << std::endl; } if (XLookupKeysym(&newEvent.xkey, 0) == XK_BackSpace) { std::cout << "You hit backspace!" << std::endl; } break; case MotionNotify: mousePos = std::make_pair((newEvent.xmotion).x, (newEvent.xmotion).y); break; } }