예제 #1
0
void
Connection::handleChatMessage(DOPE_SMARTPTR<ChatMessage> chatPtr)
{
  // set/check sender global
  if (noPlayer()) {
    // we did not get any player => chat global in any case
    chatPtr->sender="";
    chatPtr->global=true;
  }else if (singlePlayer()) {
    // we got exactly one player => sender is the name of this player
    chatPtr->sender=server.getPlayerName(playerIDs[0]);
  }else{
    // we have more than one player => check if all players are in the same team
    if (singleTeam()) {
      // yes => sender is team name
      chatPtr->sender=server.getPlayersTeamName(playerIDs[0]);
    }else{
      // no => sender is empty / or client name and message is global in any case
      chatPtr->sender="";
      chatPtr->global=true;
    }
  }
  if (chatPtr->global) {
    server.broadcast(*chatPtr);
  }else{
    // non global message and sender is set to either a player or team name
    server.sendChatMessage(*chatPtr);
  }
}
void choices()
{
     unsigned char choice;
     do
     {
     system("CLS");
     cout << "\n1. Single Player" << endl;
     cout << "2. Multi Player" << endl;
     cout << "3. Credits" << endl;
     cout << "4. Exit" << endl;
     cout << "Enter your choice: ";
     choice = getche();
     switch(choice)
     {
                     case '1':
                          singlePlayer();
                          break;
                     case '2':
                          multiPlayer();
                          break;
                     case '3':
                          credits();
                          break;
                     case '4':
                          exit(1);
                          break;
                     default:
                     cout << "\nInvalid Choice!" << endl;
                     system("PAUSE");
     }
     }while(choice != '4');
}
예제 #3
0
파일: main.cpp 프로젝트: henriquesa/pong
void titleScreen() {
	ALLEGRO_BITMAP *title = NULL;
	title = al_load_bitmap("title.bmp");

	bool exit = false;
	while (!exit) {
		al_draw_bitmap(title, 0, 0, 0);
		al_flip_display();

		ALLEGRO_EVENT ev;
		al_wait_for_event(eventQueue, &ev); // Wait for event, be that a new frame or a key press.

		if (ev.type == ALLEGRO_EVENT_KEY_UP) { // If the event was a key being released...
			switch (ev.keyboard.keycode) {
			case ALLEGRO_KEY_1:
				singlePlayer();
				break;
			case ALLEGRO_KEY_2:
				multiPlayer();
				break;
			case ALLEGRO_KEY_3:
				config();
				break;
			}
		}
		if (ev.type == ALLEGRO_EVENT_KEY_DOWN && ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
			exit = true;
	}
	al_destroy_bitmap(title);
}
예제 #4
0
파일: main.cpp 프로젝트: mafo23/tic-tac-toe
int main(int argc, char const *argv[]) {
    int v;
    std::cout << "If you would like to play vs a computer, enter 1, otherwise, enter 2" << std::endl;
    while (!(std::cin >> v && (v == 1 || v == 2))) {
        std::cout << "If you would like to play vs a computer, enter 1, otherwise, enter 2" << std::endl;
        std::cout << "Version is " << v << std::endl;
        std::cin.clear();
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
    if (v == 1) {
        singlePlayer();
    } else {
        twoPlayer();
    }
    return 0;
}
예제 #5
0
/*Main Process */
void main()
{init();
 int n, count=1, c=0;
 while (count<=3)
	{n=getPassword();
	if (n==1)
		{++count;
		cout<<"\nIncorrect password. Try again";
		getch();
		}
	else
		count=4;
	}

 if ((count>3) && (n==1))
	{cout<<"Access Denied";
	exit(0);
	}
 Load();

 int n1, n2, n3,flag;
 char ch;

 flag=0;
 while (flag==0)
	{n1=intro1();
	if (n1==4)
		{flag=1;
			break;}
	else

		{n2=intro2(n1,c);
		{if(n2==4)
			{hlpMenu();
			 getch();}
		else if(n2==3)
			{PlayerStats();
			getch();}
		else if(n2==2)
			multiPlayer();
		else if(n2==1)
			singlePlayer();
		}}
		++c;
	}
	getch();
}
예제 #6
0
void main() {
    int i = 0;
    int j = 0;
    char test[2] = {'2', '\0'};

    systemSetup(&globalData);

#if FRONT_NOT_BACK
    TRISAbits.RA0 = 0;
    ANSELAbits.ANSA0 = 0;

    printMainMenu(&globalData);
#else
    //    TRISDbits.RD4 = 0;
    //    ANSELDbits.ANSD4 = 0;
    //    PORTDbits.RD4 = 1;
#endif



    while (1) {
#if FRONT_NOT_BACK


        // get the updated cards
        if (globalData.runGetUpdatedCards == 1) {
            getUpdatedCards();
            globalData.runGetUpdatedCards = FALSE;
        }
#else
        // move the reader -- if we had one -- to the proper location


        /*
         * run LED driver
         */
        if (globalData.updateLEDFlag) {
            globalData.updateLEDFlag = FALSE;
            updateLEDs();
        }
#endif

        // process pending i2c tasks
        if (globalData.sendI2C == 1) {
            sendBytes(i2cData.dataOut, i2cData.outLength);
            globalData.sendI2C = FALSE;
        }
        if (globalData.gotI2C == 1) {
            processI2C();
            globalData.gotI2C = 0;
        }

#if FRONT_NOT_BACK
        if (!globalData.keyFlag) {
            // Check keystroke
            keypad(&globalData);
        }

        if (globalData.keyFlag && !globalData.displayedKey || globalData.myRequestStatus != 0) {
            globalData.keyFlag = FALSE;
            globalData.displayedKey = TRUE;

            switch (globalData.displayPage) {
                case 0: // main menu
                    processPrintCursor(&globalData, 3, BLUE, WHITE);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to singleplayer
                                globalData.displayPage = 1;
                                printSelectGame(&globalData);
                                break;
                            case 1: // multi
                                globalData.displayPage = 2;
                                printSelectGame(&globalData);
                                break;
                            case 2: // build
                                globalData.displayPage = 3;
                                printBuild(&globalData);
                                break;
                            case 0xFF: // back
                                globalData.displayPage = 0;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                    }
                    break;
                case 1: // display sp game menu
                    processPrintCursor(&globalData, 4, GREEN, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                globalData.displayPage = 4;
                                singlePlayer(&globalData);
                                break;
                            case 1: // go to clue
                                globalData.displayPage = 5;
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                break;
                            case 2: // go to error
                                globalData.displayPage = 6;
                                printBSOD();
                                break;
                            case 3: // go to error
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                globalData.displayPage = 7;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 2: // display mp game menu
                    processPrintCursor(&globalData, 4, GREEN, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                globalData.displayPage = 4;
                                printSelectGame(&globalData);
                                break;
                            case 1: // go to clue
                                globalData.displayPage = 5;
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                break;
                            case 2: // go to error
                                globalData.displayPage = 6;
                                printBSOD();
                                break;
                            case 3: // go to error
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                globalData.displayPage = 7;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 3: // build cards
                    processPrintCursor(&globalData, 4, RED, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                buildCard(&globalData, 0);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 1: // go to clue
                                buildCard(&globalData, 1);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 2: // go to error
                                buildCard(&globalData, 2);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 3: // go to error
                                buildCard(&globalData, 3);
                                clean(BLACK);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 4: // singleplayer monster
                    singlePlayer(&globalData);
                    break;
                case 5: // clue sp
                    break;
                case 6: // bsod
                    break;
                case 7: // in progress, b goes back
                    if (globalData.keyPress == 0x0B) {
                        globalData.displayPage = 0;
                        printMainMenu(&globalData);
                    }
                    break;
            }
        }


        //        if (!globalData.keyFlag) {
        //            keypad(&globalData);
        //        }

        //        mainMenu(&globalData);

        //
        //        if (globalData.keyFlag && !globalData.displayedKey) { // TODO this goes into a display function
        //            globalData.keyFlag = FALSE;
        //            globalData.displayedKey = TRUE;
        //
        ////            processDisplay(globalData);
        //
        //        }


#else
        //Doing an inventory command from the Build card menu
        if (globalData.readCard != 0) {

            //            globalData.getInventory = TRUE;
            //        }
            //        if (globalData.getInventory == TRUE) {
            // get the inventory of cards
            inventoryRFID();

            // Print out each on to the LCD
            for (i = 0; i < readerData.availableUIDs; i++) {
                if (readerData.readUID[i][0] != ',') {
                    // Get rid of commas
                    processUID(readerData.readUID[i]);
                    //                    printrs(0, 24 + 8 * i, BLACK, RED, readerData.readUID[i], 1); // print first UID
                }
            }

            // got inventory, tell frontend
            i2cData.dataOut[0] = CARD_CHANGE;
            i2cData.outLength = 1;
            globalData.sendI2C = TRUE;
            i2cData.transmissionNum = 0; // begin counting slots

            // Tell UID to be quiet - Works but needs to have at least one uid in this state
            // quietRFID(readerData.readUID[0]);

            //            if (readerData.availableUIDs > 0) {
            //
            //                // block 0 high bits being 0x0000 indicates factory card, not custom
            //                // block 0 high bits being 0x0001 indicates custom card
            //                // block 0 low bits indicate the game the card is for. 0x0001 is the monster game
            //                writeRFID(readerData.readUID[0], 0x00, 0x0000, 0x0001); // 7654 3210
            //                writeRFID(readerData.readUID[0], 0x01, 0x0010, 0x0001); // hex 7-5 are for level 0x001 is level 1
            //                // hex 4 is for type 0 1 2 3
            //                // 0x0 fire, 0x1 water, 0x3 earth
            //                // last 4 are monster ID
            //
            //                //writes 8 chars in 2 addresses of memory (0x02 and 0x03 here)
            //                char8RFID(readerData.readUID[0], 0x02, "FIREDUDE");
            //                writeRFID(readerData.readUID[0], 0x04, 0x0003, 0x0201); // Move list by id, has moves 03, 02, and 01
            //                readRFID(readerData.readUID[0], 0x00);
            //                printrs(0, 32, BLACK, RED, readerData.readData, 1); // print 1st block
            //                readRFID(readerData.readUID[0], 0x01);
            //                printrs(0, 40, BLACK, RED, readerData.readData, 1); // print 2nd block
            //                readRFID(readerData.readUID[0], 0x02);
            //                printrs(0, 48, BLACK, RED, readerData.readData, 1); // print 3rd block
            //                readRFID(readerData.readUID[0], 0x03);
            //                printrs(0, 56, BLACK, RED, readerData.readData, 1); // print 4th block
            //                readRFID(readerData.readUID[0], 0x04);
            //                printrs(0, 64, BLACK, RED, readerData.readData, 1); // print 5th block
            //            }
            //
            //
            //            readRFID(readerData.readUID[0], 0x01);
            //            // Print out block on to the LCD
            //            for (j = 0; j < readerData.availableUIDs; j++) {
            //                if (readerData.readUID[j][0] != ',') {
            //                    // Get rid of commas
            //                    printrs(0, 24 + 8 * i + 8 * j, BLACK, RED, readerData.readUID[j], 1); // print first UID
            //                }
            //            }
            //
            //            prints(0, H - 8, BLACK, RED, "Press B to go back.", 1);
            //            // Turn off inventory flag

            //            globalData.getInventory = FALSE;
            globalData.readCard = 0;
        }
#endif
    }
    return;


}