Exemplo n.º 1
0
void kpok::drawClick()
{
   int cardsToDraw[5];
   int w;

   drawButton->setEnabled(false);

   if (status == 0) {

      wonLabel->hide();

      cleanFoundCard();
      stopBlinking();
      stopWave();

      setCash(getCash() - cashPerRound);

      for (w=0; w<5;w++) {
         cardsToDraw[w]=0; 
         cardW[w]->setHeld(0);
      }

      for (w=0; w<highestCard;w++) done[w]=0;

      for (w=0;w<5;w++) {
         cards[w]=0;
         cardW[w]->heldLabel->hide();
         cardW[w]->show();
         cardW[w]->paintCard(cards[w],0,0);
      }

      drawCards(cardsToDraw);

      if (cardW[0]->queryHeld())
         drawTimer->start(0, TRUE);
      else
         drawTimer->start(drawDelay, TRUE);

   } else {
      clickToHold->hide();
      for (w=0; w<5;w++) cardsToDraw[w] = cardW[w]->queryHeld();

      for (w=0;w<5;w++) {
         if (!cardsToDraw[w]) {
            cards[w]=0;
            cardW[w]->show();
            cardW[w]->paintCard(cards[w],0,0);
         }
      }

      drawCards(cardsToDraw);


      if (cardW[0]->queryHeld())
         drawTimer->start(0, TRUE);
      else
         drawTimer->start(drawDelay, TRUE);

   }
}
void render(int step)
{
   ResourceManager& rm = ResourceManager::getInstance();

   ALLEGRO_BITMAP *bg = (ALLEGRO_BITMAP *)rm.getData(RES_BACKGROUND);

   if (shakeUpdateCount > 0) {
      shakeUpdateCount -= step;
      if (shakeUpdateCount <= 0) {
         shakeCount++;
         if (shakeCount >= SHAKE_TIMES) {
            shakeCount = 0;
            shakeUpdateCount = 0;
            bgx = bgy = 0;
         }
         else {
            bgx = randf(0.0f, 8.0f);
            bgy = randf(0.0f, 8.0f);
            if (rand() % 2) bgx = -bgx;
            if (rand() % 2) bgy = -bgy;
            shakeUpdateCount = SHAKE_TIME;
         }
      }
   }

   al_draw_scaled_bitmap(bg, 0, 0, 
      al_get_bitmap_width(bg), al_get_bitmap_height(bg), 
      bgx, bgy, BB_W, BB_H, 0);

   std::list<Entity *>::iterator it;
   for (it = entities.begin(); it != entities.end(); it++) {
      Entity *e = *it;
      e->render_four(al_map_rgb(255, 255, 255));
      if (e->isHighlighted()) {
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ONE);
         e->render_four(al_map_rgb(150, 150, 150));
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
      }
   }

   Player *player = (Player *)rm.getData(RES_PLAYER);
   player->render_four(al_map_rgb(255, 255, 255));
   player->render_extra();

   if (waveAngle > 0.0f) {
      renderWave();
      waveAngle -= 0.003f * step;
      if (waveAngle <= 0.0f) {
         stopWave();
      }
   }

   al_flip_display();
}
Exemplo n.º 3
0
void Drop::addWater()
{
	// this instance may be released in onDropChanged() when it bumped
	retain();
	stopWave();
	water ++;
	listener->onDropChanged(this);
	if (water <= 4)
		updateImage();
	release();
}
Exemplo n.º 4
0
void Drop::startWave()
{
	stopWave();
	if (!waveAction)
	{
		CCScaleBy* scale;
		waveAction = CCSequence::create(
			scale = CCScaleBy::create(0.2f, 1.3f),
			scale->reverse(),
			scale = CCScaleBy::create(0.2f, 1.2f),
			scale->reverse(),
			scale = CCScaleBy::create(0.2f, 1.1f),
			scale->reverse(),
			NULL);
		waveAction->retain();
	}
	runAction(waveAction);
}
Exemplo n.º 5
0
void kpok::newGame()
{
  NewGameDlg* newGameDlg;

  // Get a "New Game" dialog.
  lastHandText = "";
  newGameDlg = new NewGameDlg(this);
  newGameDlg->hideReadingFromConfig();

  if (newGameDlg->exec()) {
    stopBlinking();
    stopDrawing();
    stopWave();

    // Delete the old values.
    for (unsigned int i = 0; i < m_numPlayers; i++)
      delete playerBox[i];
    delete[] playerBox;// necessary?

    int numPlayers = newGameDlg->getPlayers();

    // Most things will be done in initPoker.
    initPoker(numPlayers);

    // Set/show the name and money of all players.
    for (unsigned int i = 0; i < m_numPlayers; i++) {
      m_players[i].setName(newGameDlg->name(i));
      playerBox[i]->showName();
      m_players[i].setCash((newGameDlg->money() >= m_game.getMinBet())
			   ? newGameDlg->money() : START_MONEY);
      m_game.setDirty();
    }

    // Show the money for all players and the pot.
    paintCash();

    // Activate the Draw button.
    drawButton->setText(i18n("&Deal"));
    drawButton->setEnabled(true);
  }

  delete newGameDlg;
}
void showWave(int num)
{
   if (waveBitmap)
      stopWave();

   ResourceManager& rm = ResourceManager::getInstance();

   ALLEGRO_FONT *myfont = (ALLEGRO_FONT *)rm.getData(RES_LARGEFONT);
   
   char text[20];
   sprintf(text, "WAVE %d", num);

   int w = al_get_text_width(myfont, text);
   int h = al_get_font_line_height(myfont);

   waveBitmap = al_create_bitmap(w, h);
   ALLEGRO_BITMAP *old_target = al_get_target_bitmap();
   al_set_target_bitmap(waveBitmap);
   al_clear_to_color(al_map_rgba(0, 0, 0, 0));
   al_draw_textf(myfont, al_map_rgb(255, 255, 255), 0, 0, 0, "%s", text);
   al_set_target_bitmap(old_target);

   waveAngle = (ALLEGRO_PI*2);
}
Exemplo n.º 7
0
void kpok::newRound()
{
  bool  onePlayerGame         = false;

  m_game.newRound();

  playerBox[0]->setHeldEnabled(false);

  if (m_numPlayers == 1)
    onePlayerGame = true;

  readOptions(); // maybe some options have changed so check em

  if (m_players[0].getCash() < m_game.getMinBet())
    noMoney();
  else {
    for (unsigned int i = 0; i < m_numPlayers; i++) {
      if (m_players[i].getCash() >= m_game.getMinBet())
	m_game.activatePlayer(&m_players[i]);
      else
	removePlayerFromRound(&m_players[i]);
    }
  }

  if (m_game.getNumActivePlayers() == 1 && m_game.getType() != SinglePlayer)
    switchToOnePlayerRules();

  m_blinkingBox = 0;
  wonLabel->hide();
  stopBlinking();
  stopWave();

  for (int i = 0; i < m_game.getNumActivePlayers(); i++)
    m_game.getActivePlayer(i)->newRound();

  // We are beginning a new round so every card is available.
  drawAllDecks();
  playerBox[0]->showHelds(false);

  // Deal first cards of the round
  bool skip[PokerHandSize];
  for (int i = 0; i < PokerHandSize; i++)
    skip[i] = false;

  for (int i = 0; i < m_game.getNumActivePlayers(); i++)
    drawCards(m_game.getActivePlayer(i), skip);

  if (m_game.getNumActivePlayers() > 1) {
    findHumanPlayer()->changeBet(m_game.getMinBet());
    m_game.bet(m_game.getMinBet());
    betBox->show();
  }
  else {
    m_game.getActivePlayer(0)->changeBet(cashPerRound);
    betBox->hide();
  }

  paintCash();

  drawTimer->start(drawDelay, TRUE);
}