Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <conio.h>
  5. #include <windows.h>
  6.  
  7. using namespace std;
  8.  
  9. ifstream mn("menu.in");
  10. ifstream lipsum("lorem.in");
  11. char menu[11][21];
  12.  
  13. int readmenu()
  14. {
  15. int length=0;
  16. char option[21];
  17. while(mn>>option)
  18. {
  19. strcpy(menu[length], option);
  20. length++;
  21. }
  22. return length;
  23. }
  24.  
  25. int mainmenu(int length)
  26. {
  27.  
  28. int i, cursor=0;
  29. char input;
  30. cursor=length*100;
  31. while(true)
  32. {
  33. system("cls");
  34. for(i=0; i<length; i++)
  35. {
  36. cout<<menu[i];
  37. if(cursor%length==i)
  38. cout<<" <";
  39. cout<<'\n';
  40. }
  41.  
  42. input=getch();
  43. switch (input)
  44. {
  45. case 'w':
  46. cursor--;
  47. break;
  48. case 's':
  49. cursor++;
  50. break;
  51. case 13:
  52. return cursor%length;
  53. break;
  54. }
  55. }
  56.  
  57. }
  58.  
  59. void help()
  60. {
  61. int i=0, words, k=0;
  62. char help[1000][15], a='p';
  63. while(lipsum>>help[i])
  64. i++;
  65. words=i;
  66. for(k=10; k>=0; k--)
  67. strcpy(help[i++], " ");
  68. system("cls");
  69. while(a!=27)
  70. {
  71. if(a=='w' && k>0)
  72. k+=-10;
  73. else if(a=='s' && k+150<words)
  74. k+=10;
  75.  
  76. system("cls");
  77. for(i=1; i<=150; i++)
  78. {
  79. cout<<help[i+k-1]<<" ";
  80. if(i%10==0)
  81. cout<<'\n';
  82. }
  83. a='x';
  84. a=getch();
  85. }
  86. }
  87.  
  88. int main()
  89. {
  90. int game, length;
  91. length=readmenu();
  92. while(game!=length-1)
  93. {
  94. system("cls");
  95. game=mainmenu(length);
  96.  
  97. switch (game)
  98. {
  99. case 0:
  100. help();
  101. /*
  102. break;
  103. case 1:
  104.  
  105. break;
  106. case 2:
  107.  
  108. break;*/
  109. default:
  110. ;
  111. }
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement