Пример #1
1
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
	ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK); //ウィンドウモード変更と初期化と裏画面設定

	init();
	load();
	sound();

	while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0 && gpUpdateKey() == 0){
		//ClsDrawScreen();

		
		if (Key[KEY_INPUT_RIGHT] >= 1){ // 右キーが押されていたら
			x = x + 5;                       // 右へ移動
		}
		if (Key[KEY_INPUT_DOWN] >= 1){ // 下キーが押されていたら
			y = y + 5;                       // 下へ移動
		}
		if (Key[KEY_INPUT_LEFT] >= 1){ // 左キーが押されていたら
			x = x - 5;                       // 左へ移動
		}
		if (Key[KEY_INPUT_UP] >= 1){ // 上キーが押されていたら
			y = y - 5;                      // 上へ移動
		}

		switch (Menucount){
		case 1:Menu(); break;
		case 2:Easy(); break;
		case 3:Normal(); break;
		case 4:Hard(); break;
		case 5:Result(); break;
		case 6:Help(); break;
		}

		PlaySoundMem(gamemusic, DX_PLAYTYPE_BACK, FALSE);
		

		Update();	//更新
		FPSDraw();	//描画
		Wait();		//待機

		if (Key[KEY_INPUT_ESCAPE] == 1)
		DxLib_End(); // DXライブラリ終了処理
	}
	DxLib_End(); // DXライブラリ終了処理
	return 0;
}
Пример #2
1
// Función para devolver la ip y el puerto asociado a un usuario
	int lee(char usuario[]){
		FILE *archivo;
		char caracteres[30];
              
		int i=0;
        archivo = fopen("listaContactos.txt","r");  // Se trata de abrir un archivo
        			
			if (archivo != NULL) {  // Si el archivo existe:
			existe = 0;
			while (feof(archivo) == 0)  // Recorre el archivo buscando el usuario solicitado
			{
					fgets(caracteres,30,archivo);
					if(((Comparar(usuario,caracteres))==1)||(i>0)){
						if(i==1)strcpy(ip,caracteres);           // Si se encuentra se copia la información correspondiente
						if(i==2){strcpy(puerto,caracteres);      // el las variables globales para poder ser usadas por el socket
						i=0;
						existe = 1;   // Uso de manejo de IP y de usuarios no agregados
						break;}
						
						i++;
						}
						
			}
		
	}
        if (existe != 1) {  // Si no existe permite al usuario comunicarse con el contacto solo si conoce su ip
        printf("\033[33m El contacto no se encuentra, \n si conoce su IP y puerto digite 1, \n si no lo conoce digite 0\n");
        int opcion;
        scanf("%i", &opcion);
        if (opcion == 1){ // Si el usuario conoce el puerto y la ip entonces puede conectarse
 			printf("Escriba el ip:");
			scanf(" %s",ip);
			printf("Escriba el puerto:");
			scanf(" %s",puerto);
        }
        else { // Si no lo envia al menu principal
			system("clear");
			Menu ();
		}}
        
        if (archivo != NULL) 
        fclose(archivo);
        return 0;
	 
	 }
Пример #3
0
int main()
{
    InitGraphics(800,600);                      // inicjalizuj okno graficzne
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);   // styl tekstu dla calej gry
    if(SaveEmpty() == 1)
        MakePlaceholderSave();

    // DEKLARACJA ZMIENNYCH:
    int X = getmaxx(); // maxymalna szerokosc okna graficznego
    int Y = getmaxy(); // maksymalna wysokosc okna graficznego

    char mainMenu[4][40] = { {"Korwin kontra Lewacy z Marsa"},
                             {"Nowa Gra"},
                             {"Kontynuuj"},
                             {"Wyjdz"} };   // tablica z elementami menu glownego
    int chosen;         // zmienna przechowujaca wybrana opcje
    bool gameOn = 1;    // status programu; doyslnie 1 - dziala, 0 - zakonczony
    int diff_level;     // poziom trudnosci gry


    do
    {
        cleardevice();
        chosen = Menu(mainMenu, 3, X/2, Y/2);

        switch(chosen)
        {
        case 1:
            ChooseDifficulty(&diff_level,X/2,Y/2);
            new_game(diff_level, X, Y, 0);
            break;
        case 2:
            if(SaveEmpty() == 1)
            {
                DisplayNoGameSaved(X/2, Y/2);
            }
            else new_game(diff_level, X, Y, 1);
            break;
        case 3:
            gameOn = 0;
            break;
        }

    }while(gameOn == 1);

}
Пример #4
0
int main(int argc, const char * argv[])
{

    Grafo *Mapa = inicia_Grafo(15, 5);
    
    InsereAresta(Mapa, 0, 0, 1, 1, 'A');
    InsereAresta(Mapa, 1, 1, 2, 1, 'B');
    InsereAresta(Mapa, 2, 2, 3, 1, 'C');
    InsereAresta(Mapa, 3, 3, 0, 1, 'D');
    InsereAresta(Mapa, 4, 4, 0, 1, 'E');
    
    Menu(Mapa);
  
    deleta_Grafo(Mapa);
    
    return 0;
}
Пример #5
0
 int main() {
	int opcion;
	do {
		opcion =  Menu();
		switch(opcion) {
			case 1:
				agregarContacto();
			break;
			case 2:
				//consultarContactos();
				enviarMensaje();
			break;
		 }
	} while (opcion != 0);
	
	return 0;
}
Пример #6
0
// 主函数
int main(int argc, char *argv[])
{
    // 初始化链表及命令
	LinkList head = NULL;
	char cmd = '\0';

    // 初始化链表
	Init(&head);
    
    // 从文件中加载链表
	Load(head);
    
    // 进入到操作菜单
	Menu(&cmd, head);

	return 0;
}
Пример #7
0
void MainGame::Play()
{
	Board coregame;
	int selectNum; // selected menu num

	while (1)
	{
		Clear();
		Menu();

		cin >> selectNum;

		switch (selectNum)
		{
		case 1:
			cout << "Player versus Player Mode" << endl;
			coregame.BeginGame();
			break;

		case 2:
			cout << "Replay Mode" << endl;
			//coregame.ReplayMode();
			TestDraw();
			break;

		case 3:
			cout << "Player versus Computer Mode" << endl;
			TestDraw();
			break;

		case 4:
			cout << "Computer versus Computer Mode" << endl;
			TestDraw();
			break;
		case 5:
			cout << "Exiting the game---" << endl;
			//Sleep(300);
			exit(0);
			break;
		default:
			cout << "Please input a number which is 1~5" << endl;
			break;
		}
	}
}
Пример #8
0
void App::run()
{
	m_order.GetMenuManager(&m_manager);
	while(true)
	{
		system("cls");
		Menu();
		char ch;
		ch = getch();		//#include "conio.h"
		switch(ch)
		{
		case '1':	m_manager.run();		break;
		case '2':	m_order.run();		    break;
		case '3':	return;
		}
		system("pause");
	}
}
Пример #9
0
void AmBankChangeView::SetTrackRef(AmTrackRef trackRef)
{
	mTrackRef = trackRef;
	BMenu*	menu = Menu();
	if (!menu) return;
	if (menu->RemoveItems(0, menu->CountItems(), true) ) return;
	if (!mTrackRef.IsValid() ) return;

	// READ TRACK BLOCK
	#ifdef AM_TRACE_LOCKS
	printf("AmProgramChangeView::SetTrackRef() read lock\n");
	#endif
	const AmSong*	song = mSongRef.ReadLock();
	const AmTrack*	track = song ? song->Track(mTrackRef) : NULL;
	if (track) BuildMenu(track, menu);
	mSongRef.ReadUnlock(song);
	// END READ TRACK BLOCK
}
Пример #10
0
// TESTED: OKAY
// guildabbreviationchange(character, text) copies the text info the guildstones abbreviation field 
// (guildnumber gets calculated from the double clicked guildstones), and notifies editing player about
// the change.
void cGuildStone::ChangeAbbreviation(UOXSOCKET s, char *text)
{
	list<SERIAL>::iterator it;
	for (it = guilds.begin(); it != guilds.end(); ++it)
	{
		cGuildStone* pStone = dynamic_cast<cGuildStone*>(FindItemBySerial(*it));
		if (pStone->abbreviation == text) 
		{
			sysmessage(s,"This abbreviation is already taken by another guild.");
			return;
		}
	}
	this->abbreviation = text;
	char txt[200];
	sprintf(txt, "Your guild has now the abbreviation: %s", this->abbreviation.c_str());
	this->Broadcast(txt);
	Menu(s,2);
}
Пример #11
0
int WDMMenu::Show(const struct discHdr * header)
{
	WDMMenu Menu(header);

	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&Menu);

	int ret = -1;

	while(ret == -1)
	{
		usleep(100);
		ret = Menu.GetChoice();
	}
	mainWindow->SetState(STATE_DEFAULT);

	return ret;
}
Пример #12
0
void
EntryMenuItem::DrawContent()
{
	BView* view = Menu();
	BPoint pos(view->PenLocation());

	if (fSmallIcon == NULL) {
		fSmallIcon = LoadIcon(); // load on demand
	}

	view->MovePenBy(kTextIndent, 0);
	BMenuItem::DrawContent();
	
	if (fSmallIcon) {
		view->SetDrawingMode(B_OP_OVER);
		view->DrawBitmap(fSmallIcon, pos);
	}
}
Пример #13
0
void ArpMenuField::ComputeDimens(ArpDimens& cur_dimens)
{
	BMenu* menu = MenuBar();
	BMenu* popup = Menu();
	
	if( menu ) {
		copy_attrs(menu);
		copy_attrs(popup);
		menu->SetFont(&PV_MenuFont);
		menu->InvalidateLayout();
	}
	
	get_view_dimens(&cur_dimens, this, false);
	
	font_height fhs;
	BasicFont()->GetHeight(&fhs);
	const float fh = fhs.ascent+fhs.descent+fhs.leading;
	float fw = BasicFont()->StringWidth("WWWW");
	
	float pref_w=0;
	if( popup ) {
		int32 num = popup->CountItems();
		for( int32 i=0; i<num; i++ ) {
			BMenuItem* item = popup->ItemAt(i);
			if( item ) {
				const float w=BasicFont()->StringWidth(item->Label());
				ArpD(cdb << ADH << "Dimensions for popup label "
							<< item->Label() << ": " << w << endl);
				if( w > pref_w ) pref_w = w;
			}
		}
	}
	
	cur_dimens.Y().SetTo(0, fh+12, fh+12, fh+12, 0);
	
	float labelWidth = (Label() && *Label())
		? BasicFont()->StringWidth(Label())	+ BasicFont()->StringWidth(" ")
		: 0;
	
	cur_dimens.X().SetTo(labelWidth,
						 (fw < pref_w ? fw : pref_w) + 20,
						 pref_w + 20, pref_w + 20,
						 0);
}
Пример #14
0
void
TWindowMenuItem::DrawContent()
{
	BMenu* menu = Menu();
	menu->PushState();

	BRect frame(Frame());
	BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad);
	//if (fExpanded)
	//	contLoc.x += kHPad;

	if (fID >= 0) {
		menu->SetDrawingMode(B_OP_OVER);

		float width = fBitmap->Bounds().Width();

		if (width > 16)
			contLoc.x -= 8;

		menu->MovePenTo(contLoc);
		menu->DrawBitmapAsync(fBitmap);

		if (width > 16)
			contLoc.x += 8;

		contLoc.x += kIconRect.Width() + kLabelOffset;
	}

	menu->SetDrawingMode(B_OP_COPY);

	contLoc.y = frame.top
		+ ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f;

	menu->MovePenTo(contLoc);

	if (IsSelected())
		menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
	else
		menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));

	BMenuItem::DrawContent();

	menu->PopState();
}
Пример #15
0
void CAppWnd::OnCreate(const CRect& rcClient)
{
	//
	// Create and attach the components.
	//
	m_Accel.LoadRsc(IDR_APPACCEL);
	Accel(&m_Accel);

	m_Menu.LoadRsc(IDR_APPMENU);
	Menu(&m_Menu);

	m_StatusBar.Create(*this, IDC_STATUS_BAR, rcClient);
	StatusBar(&m_StatusBar);

	m_AppDlg.RunModeless(*this);

	// Call base class.
	CDlgFrame::OnCreate(rcClient);
}
Пример #16
0
//---------------------------------------------------------
void CACTIVE_History::On_Mouse_RDown(wxMouseEvent &event)
{
	wxMenu	Menu(_TL("History"));

	CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_CLEAR);
	Menu.AppendSeparator();
	CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_OPTIONS_COLLAPSE);
	CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_OPTIONS_EXPAND);

	if( _Get_Object() && SG_Compare_Version(_Get_Object()->Get_History().Get_Property("saga-version"), "2.1.3") >= 0 )	// new version
	{
		Menu.AppendSeparator();
		CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_TO_MODEL);
	}

	PopupMenu(&Menu, event.GetPosition());

	event.Skip();
}
Пример #17
0
void
TBarMenuTitle::DrawContent()
{
	if (fIcon == NULL)
		return;

	BMenu* menu = Menu();
	BRect frame(Frame());
	BRect iconRect(fIcon->Bounds());

	menu->SetDrawingMode(B_OP_ALPHA);
	iconRect.OffsetTo(frame.LeftTop());

	float widthOffset = rintf((frame.Width() - iconRect.Width()) / 2);
	float heightOffset = rintf((frame.Height() - iconRect.Height()) / 2);
	iconRect.OffsetBy(widthOffset - 1.0f, heightOffset + 2.0f);

	menu->DrawBitmapAsync(fIcon, iconRect);
}
Пример #18
0
int main(void)
{
    initImage();
    initPlace();

    large_font = read_font("font.txt");
    initAudio();
    initAudioNUM();

    int IsEnding = 0;
    showingPlane = START_PLANE;

    while (!IsEnding)
    {
        clearScreen();

        switch (showingPlane)
        {
        case 0:
            start();
            showingPlane = 1;
            break;
        case 1:
            Menu();
            break;
        case 2:
            SinglePlayer();
            break;
        case 3:
            MuitiplePlayers();
            break;
        case 4:
            ShowHelp();
            showingPlane = 1;
            break;
        }

        drawCmdWindow();

    } /* while (IsEnding) */

    return 0;
}
Пример #19
0
void Simulation(int canauxBarriereEntree[][2], int canalBarriereSortie[])
{  
  // Fermeture de canaux en lecture (3 + 1)
  for (unsigned int i = 0; i < NB_BARRIERES_ENTREE; i++)
  {
    close(canauxBarriereEntree[i][0]);
    descEcritureCanauxBarriereEntree[i] = canauxBarriereEntree[i][1];
  }
  close(canalBarriereSortie[0]);
  descEcritureCanalBarriereSortie = canalBarriereSortie[1];
 
  compteurImmatriculation = 0;
  
  // Phase moteur
  for(;;)
  {
    Menu();
  }
}
Пример #20
0
int main()
{
	int id = -1;
	int is_admin = -1;

	LoadDatabase();

	while (!Login(db, &id, &is_admin));

	if (is_admin == 1)
		AdminMenu();
	else
		Menu();

	CloseDatabase();

  	system("pause");
	return 0;
}
Пример #21
0
void MainLoop(void)
{
    int menu_opt;

    for (;;) {
        menu_opt = Menu();

        if (menu_opt == 0)
            NewGame();
        else if (menu_opt == 1)
            GoLevel();
        else if (menu_opt == 2)
            Custom();
        else if (menu_opt == 3)
            Help();
        else if (menu_opt == -1 || menu_opt == 4)
            break;
    }
}
Пример #22
0
void main(){
char * Menup[]={ "  Inicializar Arbol AVL ",
		 "    Insertar Nodo       ",
		 "    Consultar Nodos     ",
		 "    Eliminar Nodos      ",
		 "    Salir a D.O.S.      ",
		};
int opcion;


clrscr();
textbackground(1);textcolor(15);clrscr();
gotoxy(28,2);printf("Programa de Base de Datos");
_setcursortype(_NOCURSOR);
opcion=Menu(Menup,5,28,"      Menu Arbol AVL      ");
//Cuadro( 12, 10, 10, 5, BLACK, BLACK );
//Cuadro( 10, 9, 10, 5, 7, 7 );
getch();
}// FIN
Пример #23
0
void DisplayGuess(int level, int code[], int rightColorRightFeature, int rightColorWrongFeature, int *guessNum)
{
     char selection;
     
     if (rightColorRightFeature != level )
     {    
          printf("\nYour Score:\n");
          printf("\nRight Color, Right Feature: %d",rightColorRightFeature);
          printf("\n\nRight Color, Wrong Feature: %d\n",rightColorWrongFeature);
          system("pause");
          Guess(level,code);
     }
     else
     {
          printf("\n\n!!!!!! CONGRATULATIONS! You have won the game with %d Guesses !!!!!!\n\n",*guessNum - 1);
          outtextxy(365,180, "CONGRATULATIONS! You have won the game");     
          
          do
          {
              fflush(stdin);
              printf("\nWould you like to play again? (Y/N): ");
              scanf("%c",&selection);
              fflush(stdin);
          
              if (selection == 'Y' || selection == 'y')
              {
                   *guessNum = 1;
                   Menu();
              }
              else if (selection == 'N' || selection == 'n')
              {
                   printf("\n");
                   system("pause");
                   exit(1);     
              }
              else
              {
                   printf("\aWARNING: you should enter \'Y\' or \'N\'\n");
              }
          }while (selection != 'Y' && selection != 'y' && selection != 'N' && selection != 'n');
     }
}
Пример #24
0
void		Engine::play()
{
  while (mode != QUIT && engine->hasScreen())
    switch (mode)
      {
      case START:
	Animation();
	break;
      case MENU:
	Menu();
	break;
      case GAME:
	Game();
	break;
      case MENU_GAME:
	MenuInGame();
	break;
      case LOAD:
	LoadSave();
	break;
      case SAVE:
	SaveGame();
	break;
      case NEW_GAME:
	LoadGame();
	break;
      case LAUNCH_GAME:
	NewGame();
	break;
      case OPTION_MENU:
	OptionMenu();
	break;
      case OPTION_GAME:
	MenuInGame();
	break;
      case HIGHSCORE:
	Highscore();
	break;
      default:
	mode = QUIT;
      }
}
Пример #25
0
int main()
{

   FileAttente file;
   bool finProgramme = false;
 
      while (!finProgramme)
      {
         try
         {      
           finProgramme = Menu(file); //menu revoie une booleene qui vérifie la fin          
          }
         catch (exception e)
         {
            cout << e.what() << endl;
            Wait();
         }
     }  
  
}
Пример #26
0
void AmBankChangeView::SetEvent(AmPhraseEvent* container, AmBankChange* bc)
{
	ArpASSERT(container && bc);
	mContainer = container;
	mBankChange = bc;
	if (mCachedBankNumber != int32(mBankChange->BankNumber()) ) {
		BMenu*		m = Menu();
		if (m) {
			int32		count = m->CountItems();
			for (int32 k = 0; k < count; k++) {
				BMenuItem*	item = m->ItemAt(k);
				if (item) {
					if (bc && k == int32(bc->BankNumber() ) ) item->SetMarked(true);
					else item->SetMarked(false);
				}
			}
		}
	}
	mCachedBankNumber = mBankChange->BankNumber();	
}
Пример #27
0
int CStartupInfo::Menu(
    unsigned int flags,
    const char *title,
    const char *helpTopic,
    const CSysStringVector &items,
    int selectedItem)
{
  CRecordVector<FarMenuItem> farMenuItems;
  for(int i = 0; i < items.Size(); i++)
  {
    FarMenuItem item;
    item.Checked = 0;
    item.Separator = 0;
    item.Selected = (i == selectedItem);
    CSysString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1);
    MyStringCopy(item.Text, (const char *)GetOemString(reducedString));
    farMenuItems.Add(item);
  }
  return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size());
}
Пример #28
0
void
TWindowMenuItem::DrawContent()
{
	BMenu* menu = Menu();
	BPoint contentLocation = ContentLocation() + BPoint(kHPad, 0);

	if (fID >= 0) {
		menu->SetDrawingMode(B_OP_OVER);

		float width = fBitmap->Bounds().Width();
		if (width > 16)
			contentLocation.x -= 8;

		float height;
		GetContentSize(NULL, &height);
		contentLocation.y += (height - fBitmap->Bounds().Height()) / 2;

		menu->MovePenTo(contentLocation);
		menu->DrawBitmapAsync(fBitmap);

		if (width > 16)
			contentLocation.x += 8;

		contentLocation.x += kIconRect.Width() + kLabelOffset;
	}
	contentLocation.y = ContentLocation().y + kVPad + fLabelAscent;

	menu->SetDrawingMode(B_OP_COPY);
	menu->MovePenTo(contentLocation);

	if (IsSelected())
		menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
	else
		menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));

	float labelWidth = menu->StringWidth(Label());
	BPoint penLocation = menu->PenLocation();
	float offset = penLocation.x - Frame().left;

	menu->DrawString(Label(labelWidth + offset));
}
Пример #29
0
//Funcion para mostrar todos los contactos
int muestra( ){
	FILE *archivo;//Es un buffer que almacena la dirección del archivo
    char caracteres[30];
    archivo = fopen("listaContactos.txt","r");//Almacena la dirección del archivo
    
    if (archivo == NULL)  {
		 printf("\033[36m Usted aún no ha agregado ningun amigo\n");
		 Menu();
	 }
     
    while (feof(archivo) == 0) {     //Mientras que no sea el final del documento
        fgets(caracteres,30,archivo);//Toma caracter por caracter del archivo y lo almacena en caracteres
        
        if(feof(archivo) == 0)
		printf("\033[33m %s",caracteres);       
        }
        fclose(archivo);//Cierra el documento
        
        return 0;
	 
	 }
Пример #30
0
void AmProgramChangeView::SetTrackRef(AmTrackRef trackRef)
{
	mTrackRef = trackRef;
	BMenu*	menu = Menu();
	if (!menu) return;
	int32			oldIndex = -1;
	BMenuItem*		item = menu->FindMarked();
	if (item) oldIndex = menu->IndexOf(item);
	menu->RemoveItems(0, menu->CountItems(), true);
	if (!mTrackRef.IsValid() ) return;

	// READ TRACK BLOCK
	#ifdef AM_TRACE_LOCKS
	printf("AmProgramChangeView::SetTrackRef() read lock\n");
	#endif
	const AmSong*	song = ReadLock();
	const AmTrack*	track = song ? song->Track( mTrackRef ) : 0;
	if (track) BuildMenu(track, menu, oldIndex);
	ReadUnlock(song);
	// END READ TRACK BLOCK
}