示例#1
0
文件: main.c 项目: dougblack/tetris
/* ===================================
 * MAIN RUN LOOP
 * =================================== */
void mainRunLoop() {
  while(!gameover) 
  {
    /* Get and process input */
    key_poll();		
    if (key_hit(KEY_RIGHT)) 
      keyRight();
    else if (key_hit(KEY_LEFT))
      keyLeft();
    else if (key_hit(KEY_UP)) {
      droppedYet = 1;
      keyHardDrop();
    }
    else if (key_hit(KEY_DOWN))
      keySoftDrop();
    else if (key_hit(KEY_A)) {
      rotatedYet = 1;
      keyRotateRight();
    }
    else if (key_hit(KEY_B)) {
      rotatedYet = 1;
      keyRotateLeft();
    }
    else if (key_hit(KEY_SELECT))
      showMenu();
    else if (key_hit(KEY_START))
      pause();

    waitForVBlank();
    frame++;
    /* Calculate layout of next frame */
    if ((frame % fallSpeed)==0) 
    {
      placed = 0;
      clearTetrimino(keyLastR, keyLastC, keyLastT);
      if (checkBoundBottom(key) != 1) {
        key.r = key.r + 1;
        drawTetrimino(key);
      } else {
        placeKey();
        placed = 1;
      }
    }
    if ((frame % inputSpeed)==0)
    {
      if (placed == 0) {
        clearTetrimino(keyLastR, keyLastC, keyLastT);
        drawTetrimino(key);
      }
      keyLastR = key.r;
      keyLastC = key.c;
      for (int i = 0; i < 16; i++) 
        keyLastT[i] = key.t[i];
      movedYet = 0;
    }
    if ((frame % rotateSpeed)==0)
      rotatedYet = 0;
  }
}
void ShutDownFrame::initConnect() {
    connect(this, SIGNAL(keyLeft()), SLOT(setPreviousChildFocus()));
    connect(this, SIGNAL(keyRight()), SLOT(setNextChildFocus()));
    connect(this, &ShutDownFrame::pressEnterAction, this, &ShutDownFrame::enterKeyPushed);

    connect(m_shutdownButton, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(Shutdown);});
    connect(m_restartButton, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(Restart);});
    connect(m_suspendButton, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(Suspend);});
    connect(m_lockButton, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(Lock);});
    connect(m_logoutButton, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(Logout);});
    connect(m_switchUserBtn, &RoundItemButton::clicked, [this] {emit ShutDownFrameActions(SwitchUser);});
}