コード例 #1
0
void Enemy::setUpHealth(int h)
{

    //create health for each enemy
    health = new Health(h,this);
    connect(health,SIGNAL(die()),this,SLOT(destroyEnemy()));
    connect(health,SIGNAL(die()),this,SLOT(increaseScore()));
}
コード例 #2
0
ファイル: entity.c プロジェクト: TeamJaguar/kittonaut
void doActionIfNotEmpty(DISPLAY *display, GAMESTATE* state, ENTITY *dentity)
{
   switch (dentity->type) {
      /*case DOG:*/
      case SPACESHIPM :
         increaseScore(state, SCOREMAIN);
/*         displayMessageResetGame(display, MAPFILE, state);
*/         state->win = true;
         break;
      case SPACESHIPS :
         increaseScore(state, SCORESPARE);
         break;
   /*   case WATERSPOT :
         decreaseHealth(state, NEGHEALTH);
         break;*/
      default : return;
   }
}
コード例 #3
0
ファイル: game.c プロジェクト: jeremysrand/apple2048
void slideInDirection(tDir dir)
{
    tPos pos;
    tPos destPos;
    int8_t incr;
    tTileValue tileValue;
    bool addNewTile = false;

    if (dir < 0) {
        pos = 0;
        incr = 1;
    } else {
        pos = NUM_TILES - 1;
        incr = -1;
    }

    for ( ; ((pos >= 0) && (pos < NUM_TILES)); pos += incr) {
        if (gTileValues[pos] <= 0)
            continue;
        destPos = nextPosInDir(pos, dir);
        if (destPos == pos)
            continue;
    
        addNewTile = true;

        tileValue = gTileValues[destPos];
        if (tileValue > 0) {
            tileValue++;
            gTileValues[destPos]++;
            gNumEmptyTiles++;
            increaseScore(gValueScores[tileValue]);
            updateMaxTile(tileValue);

            // This is a hack to prevent multiple merges from happening to
            // the same tile in a single turn.  We set the value to a high
            // negative (< -1) and then flip the sign bit later.
            gTileValues[destPos] = -tileValue;
        } else {
            gTileValues[destPos] = gTileValues[pos];
        }
        gTileMoveCallback(pos, destPos, gValueStrings[gTileValues[pos]]);
        gTileValues[pos] = 0; // Empty the old position
    }

    for (pos = 0; pos < NUM_TILES; pos++) {
        tileValue = gTileValues[pos];
        if (tileValue < BLOCKED_TILE_VALUE) {
            gTileValues[pos] = -tileValue;
        }
    }

    if (addNewTile)
        addRandomTile();
}
コード例 #4
0
void StudentWorld::CheckGoodieHittingPlayer(Goodie* ptr)
{
	if (ptr->getX() == m_player->getX() && ptr->getY() == m_player->getY())
	{
		increaseScore(5000);
		playSound(SOUND_GOT_GOODIE);
		if (ptr->goodieType() ==  IID_FREE_SHIP_GOODIE)
			incLives();
		else if (ptr->goodieType() == IID_ENERGY_GOODIE)
			m_player->setEnergy(50);
		else if (ptr->goodieType() == IID_TORPEDO_GOODIE)
			m_player->increaseTorpedoes(5);
		ptr->setAlive(false);
	}
	return;
}
コード例 #5
0
ファイル: blockers.c プロジェクト: bluebit/Blocker
void *create_bomb(void *arg) {
    Block *bomb;
    bomb = (Block *) arg;
    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
    pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
    pthread_mutex_lock(&mutex);
    addThread(pthread_self());
    pthread_mutex_unlock(&mutex);
    while(bomb->row <= bomb->screen_height) {
        if(bomb->row == bomb->screen_height - 1) {
            pthread_mutex_lock(&mutex);
            if(bomb->col >= bomb->block->start && bomb->col <= bomb->block->end) {
                increaseScore();
                displayScore();
            } else {
                flash();
                decreaseScore(score);
                displayScore();
            }
            delete_bomb(bomb);
            pthread_mutex_unlock(&mutex);
            break;
        }
        pthread_mutex_lock(&mutex);
        SET_COLOR_BLUE;
        move(bomb->row, bomb->col);
        delch();
        insch(' ');
        (bomb->row)++;
        SET_COLOR_RED;
        pthread_mutex_unlock(&mutex);
        refresh();
        pthread_testcancel();
        napms(150);
    }

    pthread_mutex_lock(&mutex);
    bomb->cols[bomb->col] = 0;
    removeThread(pthread_self());
    pthread_mutex_unlock(&mutex);

    free(bomb);
    pthread_exit((void *) 0);
}
コード例 #6
0
ファイル: level.cpp プロジェクト: mastergreg/pewpew
void level::insertScoreTag(vector2D pos,int points)
{
    drawableList.push_back(new score_tag(pos,points));
    increaseScore(points);
}