예제 #1
0
CWormmouth::CWormmouth(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CStunnable(pmap, foeID, x, y),
mTurnAround(false),
mTimer(0)
{
	mActionMap[A_WORMMOUTH_MOVE]    = (void (CStunnable::*)()) &CWormmouth::processMoving;
	mActionMap[A_WORMMOUTH_LOOK]    = (void (CStunnable::*)()) &CWormmouth::processLooking;
	mActionMap[A_WORMMOUTH_EAT]     = (void (CStunnable::*)()) &CWormmouth::processEating;
	mActionMap[A_WORMMOUTH_STUNNED] = &CStunnable::processGettingStunned;

	setupGalaxyObjectOnMap(0x26DE, A_WORMMOUTH_MOVE);
	processMove(0, -(1<<CSF));	
	processMove(0, (1<<CSF));	

	xDirection = LEFT;
}
예제 #2
0
/*
 * Listens to key press events from the graphical subsystem,
 * and handles the events appropriately:
 *   - '[n]' moves hero in direction [n],
 *           where n = 1, 2, 3, 4, 6, 7, 8, 9 on the numeric keypad
 *   - '5' on the numeric keypad makes the hero wait one turn
 *   - 'T' teleports hero
 */
void MainWindow::keyPressEvent(QKeyEvent *e)
{
    if (!gameOver) { // only process key presses while game is not over
        Hero hero = gameState.getHero();
        Point pt = hero.asPoint();
        bool actionTaken = false;
        bool waiting = false;

        if (e->modifiers() == Qt::KeypadModifier) {
            switch (e->key()) {
            case Qt::Key_1:
                actionTaken = tryMove(hero, Point{pt.x - 1, pt.y + 1});
                break;
            case Qt::Key_2:
                actionTaken = tryMove(hero, Point{pt.x, pt.y + 1});
                break;
            case Qt::Key_3:
                actionTaken = tryMove(hero, Point{pt.x + 1, pt.y + 1});
                break;
            case Qt::Key_4:
                actionTaken = tryMove(hero, Point{pt.x - 1, pt.y});
                break;
            case Qt::Key_6:
                actionTaken = tryMove(hero, Point{pt.x + 1, pt.y});
                break;
            case Qt::Key_7:
                actionTaken = tryMove(hero, Point{pt.x - 1, pt.y - 1});
                break;
            case Qt::Key_8:
                actionTaken = tryMove(hero, Point{pt.x, pt.y - 1});
                break;
            case Qt::Key_9:
                actionTaken = tryMove(hero, Point{pt.x + 1, pt.y - 1});
                break;
            case Qt::Key_5:
                actionTaken = true;
                waiting = true;
                break;
            default:
                QWidget::keyPressEvent(e);
            }
        } else {
            switch (e->key()) {
            case Qt::Key_T:
                gameState.teleportHero();
                actionTaken = true;
                break;
            default:
                QWidget::keyPressEvent(e);
            }
        }

        if (actionTaken) { // process results of viable move
            processMove(waiting);
        }
    } else {  // game is over - do not process key press
        QWidget::keyPressEvent(e);
    }
}
예제 #3
0
CArachnut::CArachnut(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
    CGalaxySpriteObject(pmap, foeID, x, y)
{
    setupGalaxyObjectOnMap( 0x2378, A_ARACHNUT_WALK );
    xDirection = LEFT;

    CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
    performCollisions();
    processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
    processActionRoutine();
}
예제 #4
0
CMadMushroom::CMadMushroom(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y),
jumpcounter(0)
{
	setupGalaxyObjectOnMap(0x20E4, A_MUSHROOM_BOUNCE);

	CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
	performCollisions();
	processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
	processActionRoutine();
}
예제 #5
0
void CPlayerBase::processEvents()
{
    while(!m_EventCont.empty())
    {
        if( ObjMoveCouple* pObjMove =  m_EventCont.occurredEvent<ObjMoveCouple>())
        {
            auto move = pObjMove->m_Vec;
            processMove(move);
            pObjMove->mSecond.processMove(move);
            m_EventCont.pop_Event();
        }

        if( ObjMoveCouples* pObjMove =  m_EventCont.occurredEvent<ObjMoveCouples>())
        {
            auto move = pObjMove->m_Vec;
            auto playerVec = pObjMove->mCarriedObjVec;

            processMove(move);

            for(auto &player : playerVec)
            {
                if(!player)
                    continue;

                if(!player->m_jumpdownfromobject)
                      player->processMove(move);
            }

            m_EventCont.pop_Event();
        }

        if( ObjMove* pObjMove =  m_EventCont.occurredEvent<ObjMove>())
        {
            processMove(pObjMove->m_Vec);
            m_EventCont.pop_Event();
        }
    }
}
예제 #6
0
CArachnut::CArachnut(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y, 0)
{
	setupGalaxyObjectOnMap( 0x2378, A_ARACHNUT_WALK );
	xDirection = LEFT;

    GsSprite &rSprite = gGraphics.getSprite(mSprVar, mSpriteIdx);
	performCollisions();

    const int xcentering=(rSprite.m_bboxX2-rSprite.m_bboxX1)/2;

    processMove( xcentering, 0 );
	processActionRoutine();
}
CItemEffect::CItemEffect(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, Uint16 l_sprite, item_effect_type ieffect) :
CGalaxySpriteObject(pmap, foeID, x, y, 0)
{
	m_timer = 0;
	sprite = l_sprite-124;
	honorPriority = false;
	solid = false;
	m_ieffect = ieffect;
			
    GsSprite &rSprite = gGraphics.getSprite(mSprVar,sprite);

	int moveup = (1<<CSF)-1;
	moveup -= ((rSprite.getHeight()+1)<<STC);
	m_Pos.y += moveup;
	processMove(0, 1);
}
예제 #8
0
void LocalPrefServer::processCommand(const ServerCommand* _command, int playerNum)
{
	GetLog() << "LocalPrefServer: Processing command of type " << _command->Type() << " from player " << playerNum << endl;
	switch( _command->Type() ) {
		case SCT_SetSettings:
		{
			const SetSettingsCommand* command = static_cast<const SetSettingsCommand*>( _command );
			processSetSettings(command->Settings);
			break;
		}
		case SCT_Bid:
		{
			const BidCommand* command = static_cast<const BidCommand*>( _command );
			processBid(command->Bid, playerNum);
			break;
		}
		case SCT_Drop:
		{
			const DropCommand* command = static_cast<const DropCommand*>(_command);
			processDrop(command->Cards, command->Contract, playerNum);
			break;
		}
		case SCT_Move:
		{
			const MoveCommand* command = static_cast<const MoveCommand*>(_command);
			processMove(command->Move, playerNum);
			break;
		}
		case SCT_StartServer:
		{
			startNewGame();
			break;
		}
		case SCT_PlayMisereResponse:
		{
			const PlayMisereResponseCommand* command = static_cast<const PlayMisereResponseCommand*>(_command);
			processPlayMisereResponse(command->PlayByMyself ? PMR_PlayByMyself : PMR_HandOverCards, playerNum);
			break;
		}
		default:
			GetLog() << "Warning: unsupported command of type " << _command->Type() << " will be ignoerd." << endl;
			break;
	}
}
예제 #9
0
CBlueBird::CBlueBird(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y, 0),
mTimer(0)
{
	mActionMap[A_EAGLE_HATCHED] = &CBlueBird::processHatched;
	mActionMap[A_EAGLE_WALKING] = &CBlueBird::processWalking;
	mActionMap[A_EAGLE_WALKING+1] = &CBlueBird::processWalking;
	mActionMap[A_EAGLE_FLYING] =  &CBlueBird::processFlying;
	mActionMap[A_EAGLE_STUNNED] = &CBlueBird::processStunned;

	setupGalaxyObjectOnMap( 0x21B6, A_EAGLE_HATCHED );
	xDirection = LEFT;

    GsSprite &rSprite = gGraphics.getSprite(mSprVar,sprite);
	performCollisions();
	processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
	processActionRoutine();

}
예제 #10
0
CBloog::CBloog(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y) :
CStunnable(pmap, foeID, x, y),
mTimer(0)
{

    mHealthPoints = 1;

    const Difficulty diff = g_pBehaviorEngine->mDifficulty;

    if(foeID == 0x04 && diff > HARD)
    {
        // Set the bloog to another color and double his health
        mSprVar = 1;
        mHealthPoints *= 2;
    }
    if(foeID == 0x05 && diff > EXPERT)
    {
        // Set the bloog to another color and increase his health
        mSprVar = 2;
        mHealthPoints *= 3;
    }
    if(foeID == 0x06 && diff > NINJA)
    {
        // Set the bloog to another color and increase his health
        mSprVar = 3;
        mHealthPoints *= 4;
    }


	mActionMap[A_BLOOG_WALK] = (GASOFctr) &CBloog::processWalking;
	mActionMap[A_BLOOG_STUNNED] = (GASOFctr) &CStunnable::processGettingStunned;
	
	setupGalaxyObjectOnMap(0x1EE6, A_BLOOG_WALK);
	
	xDirection = LEFT;

    // Some mods suffer the fact (Keen 8 Dead in Desert) that those foes appear embedded in the floor
    CSprite &rSprite = g_pGfxEngine->getSprite(mSprVar,sprite);
    performCollisions();
    processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
    processActionRoutine();
}
예제 #11
0
LRESULT CAnimMixer::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  CPoint ptCursor(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));

  if (::GetCapture() != m_hWnd)
  {
    m_oldFocusWin = ::GetFocus();
    
    SetCapture();
    SetFocus();

    m_useRuleMouse = ruleMouseSetTarget(m_hWnd);
    sInt buttons, dx, dy;
    ruleMousePoll(buttons, dx, dy); // to clear accumulated deltas

    m_ruleMouseCoord = ptCursor;
  }
  else
  {
    CRect rc;
    GetClientRect(&rc);
    rc.top += 40;
    
    if (!::PtInRect(&rc, ptCursor) && !m_lbDown && !m_mbDown)
    {
      ::ReleaseCapture();
      ::SetFocus(m_oldFocusWin);
      if (ruleMouseGetTarget() == (void *) m_hWnd)
        ruleMouseSetTarget(0);
    }
  }
  
  if (m_lbDown) // Move
    processMove(ptCursor.x, ptCursor.y);

  if (m_mbDown && !m_useRuleMouse) // Scroll
    processScroll(ptCursor.x);

  return 0;
}
예제 #12
0
int undoMove(Tower *source, Tower *dest) {
	verify(source);
	verify(dest);
	return processMove(dest, source);
}
예제 #13
0
short move(Tower *source, Tower *dest) {
	if(source->top != NULL && dest->top != NULL && dest->top->size < source->top->size) {
		return -2; /* dest has smaller disc*/
	}
	return processMove(source, dest);
}
예제 #14
0
bool QUERY_RETRIEVE_SCP_EMULATOR_CLASS::processCommandDataset(DCM_COMMAND_CLASS *command_ptr, DCM_DATASET_CLASS *dataset_ptr)

//  DESCRIPTION     : Process the Storage command and dataset.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	bool result;

	// handle individual commands
	switch(command_ptr->getCommandId())
	{
	case DIMSE_CMD_CFIND_RQ:
		if (dataset_ptr)
		{
			// process the FIND command
			result = processFind(dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_CFIND_RSP, status);
		}
		break;

	case DIMSE_CMD_CMOVE_RQ:
		if (dataset_ptr)
		{
			// process the MOVE command
			result = processMove(dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_CMOVE_RSP, status);
		}
		break;

	case DIMSE_CMD_CGET_RQ:
		if (dataset_ptr)
		{
			// process the GET command
			result = processGet(dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_CGET_RSP, status);
		}
		break;

	default:
		{
			// unknown command
			UINT16 status = DCM_STATUS_UNRECOGNIZED_OPERATION;
			result = sendResponse(command_ptr->getCommandId(), status);
		}
		break;
	}

	// return result
	return result;
}
예제 #15
0
파일: main.c 프로젝트: patrickjcote/wumpus
int main(void) {

        char                mORs, 
                            yesNo;

        struct wmpCaveST    wmpCave[DUODEC + 1];
        struct wmpHntrST    wmpHntr;


        system("clear");

        progSalutatn('S', "Hunt The Wumpus");

        srand((unsigned) time(NULL));
#if DEBUG_MODE
        printf("---------- DEBUG_MODE: ON ---------------\n\n");
#endif

        printf("Welcome to my lair!\n");
        printf("Would you like to play a game (y or n)? ");
        scanf(" %c", &yesNo);
        if (yesNo != 'y') {
                printf("Coward! Begone then.\n");
                goto leave;
        }//if

        while (true) { //user want to play

                printf("Would you like a game description (y or n)> ");
                scanf(" %c", &yesNo);
                if (yesNo == 'y') {
                        wumpusDescription();
                }//if user wants instructions


                initWumpusGame(wmpCave, &wmpHntr);

                printf("\nStart new game.\n");
                printf("-----------------------------------------------\n");

                while (true) { //game is in progress
                        printf("You are in cave %d\n", wmpHntr.hntrCaveSV);
                        printf("There are tunnels to caves %d %d %d\n",
                                        wmpCave[wmpHntr.hntrCaveSV].wmpTunnlsSV[0],
                                        wmpCave[wmpHntr.hntrCaveSV].wmpTunnlsSV[1],
                                        wmpCave[wmpHntr.hntrCaveSV].wmpTunnlsSV[2]);

                        if (pitNearby(wmpCave, &wmpHntr)) {
                                printf("It's drafty here!\n");
                        }//if

                        printf("move (m) or shoot (s)> ");
                        scanf(" %c", &mORs);

                        if (mORs == 'm') {
                                if (processMove(wmpCave, &wmpHntr)) {
                                        continue;
                                }//if hunter did not die

                                else {
                                        break;
                                }//else hunter killed
                        }//if move

                        //------------ Debug: printWorld() on 'p' press --------
#if DEBUG_MODE
                        else if (mORs == 'p'){ printWorld(wmpCave); continue; }	
#endif
                        //------------------------------------------------------

                        else {
                                if (processShoot(wmpCave, &wmpHntr)) {
                                        continue;
                                }//if hunter or wumpus did not die
                                else {
                                        break;
                                }//else either hunter or wumpus died
                        }//else shoot

                }//while game in progress

                printf("\n");
                printf("Would you like to play again? (y or n)> ");
                scanf(" %c", &yesNo);
                if (yesNo == 'y') {
                        continue;
                }//if user want to play again
                else {
                        break;
                }//else user does not want to play again
        }//while user wants to play
leave:			
        printf("\n");
        progSalutatn('E', "Hunt The Wumpus");
        double anyNmbr;
        printf("Enter any number to exit> ");
        scanf("%lf", &anyNmbr);

        system("clear");


}//main()