forked from 404name/winter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
模拟笔记本for win7.txt
800 lines (794 loc) · 37.1 KB
/
模拟笔记本for win7.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
/*---------------------------------------------------------
程序: 模拟笔记本电脑 (纯C语言,可直接编译器运行)
作者: 0.0
说明: 1.这个程序本意在模拟电脑的基本功能,重在实现键盘的输入与键盘的控制,模拟开机,输密,打开软件,关闭电脑,所以其他功能暂没开发,不用太失望。
2.不同的编码会有不同的长度显示,但运行出来的效果都是一样的
3.代码规范不到位,见谅。
4.大一上写的,一般写小游戏练手,也琢磨到一些特殊的处理方法,所以对一些功能处理上有一些难理解的地方。
5.emmm,没啥了
---------------------------------------------------------*/
#include <conio.h> //用于getch()
#include <stdio.h>
#include <string.h>
#include <windows.h>
char start[20][500] = { //图形界面
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /~/~/ /"},
{" \\ /~/~/ /"},
{" \\ Microsotf@ ~ ~ __ XP /"},
{" \\ \\ /\\ / - _ _| _ _ _ /_ /"},
{" \\ \\/ \\/ | | | |_| |_| \\/\\/ __/ /"},
{" \\ /"},
{" \\ _____________________ /"},
{" \\ | | /"},
{" \\ +--------------------+ /"},
{" \\ /"},
{" \\ Copyright ΘMicrosoft Corporation Microsoft* /"},
{" \\ __________________________________________________________________________________________/"}};
char password[20][500] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ /"},
{" \\ ------------------------------------------------------------------------------------------------------------------ /"},
{" \\ /"},
{" \\ | /"},
{" \\ | /"},
{" \\ | +--------------------------------------------- /"},
{" \\ /~/~/ | |+-----+ Administrator /"},
{" \\ /~/~/ __XP | || []| 输入密码 /"},
{" \\ \\ /\\ / - _ _| _ ~ ~ /_ | |+-----+ 【| 】ck[→] /"},
{" \\ \\/ \\/ | | | |_| |_| \\/\\/ __/ | +--------------------------------------- /"},
{" \\ | /"},
{" \\ 要开始,请单击您的用户名 | /"},
{" \\ | /"},
{" \\ /"},
{" \\ ---------------------------------------------------------------------------------------- /"},
{" \\ __________________________________________________________________________________________/"}};
char desktop[20][500] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ ----- ----- ----- +----+ +----+ /"},
{" \\ \\ [] \\ \\ \\ \\ \\ | | |ing | /"},
{" \\ ----- ----- ----- +----+ +----+ /"},
{" \\ 小游戏 垃圾桶 计算器 相关 待开发 /"},
{" \\ ----- /"},
{" \\ \\ \\ /"},
{" \\ ----- __ --------------- __ __ /"},
{" \\ IE浏览器__-- --- __ -------_ -------_------____ /"},
{" \\ ____ __--__ -- __ -------_ --- - __ --- __ --------------______ /"},
{" \\__ -------_--__ ------- __ ---------- __ ------ __ ------ __ --- __ ---------____ /"},
{" \\ -------_---__ ------- _---- __ -------_ ---_ -------_ -_ ----------_ -_---_ -_ ------_ -_ /"},
{" \\--__ -- __ ----- __ ------ __ -------_ --- ---- __ -------_ -_ ---------_ -_ ------_ -_ ------ /"},
{" \\ -_--__ ------- _---- __ -------_ ------- __ -------_ -- __ -------_ -_ --------__---_ -_ ------/"},
{" \\ _____________________________________________________________________________________________ /"},
{" \\ 开始 \\ qq2010 | | 12:00 /"},
{" \\ __________________________________________________________________________________________/"}};
char game_hnt[20][500] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ +----------------------------------------------------------------------------------------------------------------+ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ +-------------------------------------------------------------------------------------------+ /"},
{" \\ _____________________________________________________________________________________________ /"},
{" \\ 开始 \\ qq2010 | 汉诺塔自动演示小游戏 | | 12:08 /"},
{" \\ __________________________________________________________________________________________/"}};
char thinking[30][500] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ +----------------------------------------------------------------------------------------------------------------+ /"},
{" \\ 这里是感想: /"},
{" \\ /"},
{" \\ 寒假太颓废了,没劲学习,游戏玩腻,然后开始发呆。安静下来时才有灵感 ,看着笔记本,就想着我也编一个电脑系统吧 /"},
{" \\ /"},
{" \\ 就想把大一上学到的一些东西总着来练练手。。然后发现写电脑系统就是痴人说梦了,我还是写个模拟计算机吧。 /"},
{" \\ /"},
{" \\ 对着自己笔记本的键盘一个一个的还原,然后思考如何体现屏幕,如何移动键盘,如何读取键盘把信息传给我的 /"},
{" \\ /"},
{" \\ 虚拟电脑,如何模拟开机实现基本功能 ,一口气写完真心爽,最后想做互动游戏的,但这斜着的屏幕,emmm /"},
{" \\ /"},
{" \\ 所以最后电脑只能运行汉诺塔,其他功能实现也简单,但还是把时间放在我突然又燃起的学习小火苗上吧/"},
{" \\ +-------------------------------------------------------------------------------------------+ /"},
{" \\ _____________________________________________________________________________________________ /"},
{" \\ 开始 \\ qq2010 | 感想.txt | | 12:15 /"},
{" \\ __________________________________________________________________________________________/"}};
char ending[30][500] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ /"},
{" \\ 正在关机 /"},
{" \\ /"},
{" \\ 请确保你的数据已保存 /"},
{" \\ /"},
{" \\ 0.0 /"},
{" \\ /"},
{" \\ 正在损失数据 /"},
{" \\ /"},
{" \\ 电脑格式化成功 /"},
{" \\ /"},
{" \\ 感谢使用 Xp /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ __________________________________________________________________________________________/"}};
char map[10000][2000] = {
{"+--------------------------------------------------------------------------------------------------------------------------+"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ /"},
{" \\ __________________________________________________________________________________________/"},
{" +------------------------------------------------------------------------------------------+"},
{" | ---- |"},
{" |------------------------------------------------------------------------------------------|"},
{" |+-----+ +---+---+---+---++---+---+---+---++---+---+---+---++---+---+---+ |"},
{" || Esc | | F1| F2| F3| F4|| F5| F6| F7| F8|| F9|F10|F11|F12||Prt|Scr|Pau| ++ ++ ++ ++ |"},
{" |+-----+ +---+---+---+---++---+---+---+---++---+---+---+---++---+---+---+ ++ ++ ++ ++ |"},
{" |+----+---+---+---+---+---+---+---+---+---+---+---+---+-----++---+---+---++---+---+---+---+|"},
{" || `~ | 1!| 2@| 3#| 4$| 5%| 6^| 7&| 8*| 9(| 0)| --| =+| ←--||Ins|Hom|Pgu||Num| / | * | - ||"},
{" |+----++--++--++--++--++--++--++--++--++--++--++--++--++----++---+---+---++---+---+---+---+|"},
{" || Tab | Q | W | E | R | T | Y | U | I | O | P | [{| ]}| \\| ||Del|End|Pgd|| 7 | 8 | 9 | ||"},
{" |+-----++--++--++--++--++--++--++--++--++--++--++--++--+----++---+---+---++---+---+---+ + ||"},
{" || Caps | A | S | D | F | G | H | J | K | L | ;:| \'\"| Enter | | 4 | 5 | 6 | ||"},
{" |+------++--++--++--++--++--++--++--++--++--++--++--+-------+ +---+ +---+---+---+---+|"},
{" || Shift | Z | X | C | V | B | N | M | ,<| .>| /?| Shift | | ↑| | 1 | 2 | 3 | |||"},
{" |+----+--+-+-+--++---+---+---+---+---+---+--++---+---+------++---+---+---++---+---+---+ |||"},
{" || Ctr| win| Alt| ---- | Alt| Fn| Ctrl ||← | ↓| →|| 0ins |.de|←+||"},
{" |+----+----+----+---------------------------+----+---+------++---+---+---++-------+---+---+|"},
{" | +-------------------------------+ |"},
{" | | | |"},
{" | | | |"},
{" | |---------------+---------------| |"},
{" | +---------------+---------------+ |"},
{" +------------------------------------------------------------------------------------------+"}};
//功能数组
int keyboard[20][30] = {
//把键盘看成一个地图让move函数在上面移动返回的数值对应下面的 board_place[120][5]是对应按键的全部信息
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 104, 104, 104, 104},
{0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37},
{0, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58},
{0, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 71, 0, 0, 0, 72, 73, 74, 58},
{0, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 86, 86, 0, 87, 0, 88, 89, 90, 91},
{0, 92, 93, 94, 95, 95, 95, 95, 95, 95, 95, 96, 97, 98, 98, 99, 100, 101, 102, 102, 103, 91},
};
int next[9][2] = {{0}, {0}, {0}, {0}, {0}, {-1, 0}, {0, -1}, {1, 0}, {0, 1}}; //给键盘传给虚拟键盘的键盘控制虚拟电脑用
int computer_map[3][8] = {{0, 0, 0, 0, 0}, {0, 1, 2, 3, 4}, {5, 0, 0, 0, 0}}; //对应的移动操作记录
int computer_map_place[6][2] = {{0}, {2, 9}, {2, 19}, {2, 29}, {2, 40}, {6, 12}};
int cx = 1, cy = 1, tcx = computer_map_place[computer_map[cx][cy]][0], tcy = computer_map_place[computer_map[cx][cy]][1], lcx = cx, lcy = cy;
int board_place[120][5] = { //这是按键的信息 下标依次对应 -返回值 -按下shift下的返回值2 -键盘字符长度 -字符坐标x -y
{0, 0, 0, 0, 0}, //第一项如果是字符那么那就是返回字符 如果是数字1-9那么就是功能按键功能对应如下
{1, 1, 3, 21, 19}, //1-10
{0, 0, 2, 21, 28}, //1返回 4 ~ capslk(大写锁定) 2 ~删除 3确认 4shift 5上 6左 7下 8又 9开机
{0, 0, 2, 21, 32},
{0, 0, 2, 21, 36},
{0, 0, 2, 21, 40},
{0, 0, 2, 21, 45},
{0, 0, 2, 21, 49},
{0, 0, 2, 21, 53},
{0, 0, 2, 21, 57},
{0, 0, 2, 21, 62},
{0, 0, 3, 21, 65}, // 11
{0, 0, 3, 21, 69},
{0, 0, 3, 21, 73},
{0, 0, 3, 21, 78},
{0, 0, 3, 21, 82},
{0, 0, 3, 21, 86},
{'`', '~', 2, 24, 19},
{'1', '!', 2, 24, 24},
{'2', '@', 2, 24, 28},
{'3', '#', 2, 24, 32},
{'4', '$', 2, 24, 36}, // 21
{'5', '%', 2, 24, 40},
{'6', '^', 2, 24, 44},
{'7', '&', 2, 24, 48},
{'8', '*', 2, 24, 52},
{'9', '(', 2, 24, 56},
{'0', ')', 2, 24, 60},
{'-', '_', 2, 24, 64},
{'=', '+', 2, 24, 68},
{2, 2, 4, 24, 72},
{0, 0, 3, 24, 78}, // 31
{0, 0, 3, 24, 82},
{0, 0, 3, 24, 86},
{0, 0, 3, 24, 91},
{'/', '/', 1, 24, 96},
{'*', '*', 1, 24, 100},
{'-', '-', 1, 24, 104},
{0, 0, 3, 26, 19},
{'q', 'Q', 1, 26, 25},
{'w', 'W', 1, 26, 29},
{'e', 'E', 1, 26, 33}, // 41
{'r', 'R', 1, 26, 37},
{'t', 'T', 1, 26, 41},
{'y', 'Y', 1, 26, 45},
{'u', 'U', 1, 26, 49},
{'i', 'I', 1, 26, 53},
{'o', 'O', 1, 26, 57},
{'p', 'P', 1, 26, 61},
{'[', '{', 2, 26, 65},
{']', '}', 2, 26, 69},
{'\\', '|', 2, 26, 73}, // 51
{0, 0, 3, 26, 78},
{0, 0, 3, 26, 82},
{0, 0, 3, 26, 86},
{'7', '7', 1, 26, 92},
{'8', '8', 1, 26, 96},
{'9', '9', 1, 26, 100},
{'+', '+', 1, 27, 104},
{4, 4, 4, 28, 19},
{'a', 'A', 1, 28, 26},
{'s', 'S', 1, 28, 30}, // 61
{'d', 'D', 1, 28, 34},
{'f', 'F', 1, 28, 38},
{'g', 'G', 1, 28, 42},
{'h', 'H', 1, 28, 46},
{'j', 'J', 1, 28, 50},
{'k', 'K', 1, 28, 54},
{'l', 'L', 1, 28, 58},
{';', ':', 2, 28, 62},
{'\'', '\"', 2, 28, 66},
{3, 3, 5, 28, 70}, // 71
{'4', '4', 1, 28, 92},
{'5', '5', 1, 28, 96},
{'6', '6', 1, 28, 100},
{4, 4, 5, 30, 19},
{'z', 'Z', 1, 30, 27},
{'x', 'X', 1, 30, 31},
{'c', 'C', 1, 30, 35},
{'v', 'V', 1, 30, 39},
{'b', 'B', 1, 30, 43},
{'n', 'N', 1, 30, 47}, // 81
{'m', 'M', 1, 30, 51},
{',', '<', 2, 30, 55},
{'.', '>', 2, 30, 59},
{'/', '?', 2, 30, 63},
{4, 4, 5, 30, 69},
{5, 5, 2, 30, 83},
{'1', '1', 1, 30, 92},
{'2', '2', 1, 30, 96},
{'3', '3', 1, 30, 100},
{3, 3, 3, 32, 103}, // 91
{0, 0, 3, 32, 19},
{0, 0, 3, 32, 24},
{0, 0, 3, 32, 29},
{' ', ' ', 4, 32, 45},
{0, 0, 3, 32, 62},
{0, 0, 2, 32, 67},
{0, 0, 4, 32, 71},
{6, 6, 2, 32, 78},
{7, 7, 2, 32, 83},
{8, 8, 2, 32, 87}, // 101
{'0', '0', 4, 32, 93},
{'.', '.', 4, 32, 99},
{9, 9, 4, 18, 99}};
// 程序功能变量
int flag = 0, function, if_shift = 0, if_start = 0, if_input_password = 0, if_into_desktop = 0, if_game = 0; //0表示输入无效,1表示是输入电脑键 2表示是功能键,
char letter;
int x, y, tx, ty, num, lx, ly;
char temp[6] = {"====="};
char put_in_computer[20];
char password_0[20] = {"WHJY"}; // 密码
int put_in_num = 0, if_input = 0, input_x, input_y, input_max;
// 汉诺塔游戏变量
int mid_x = 7, mid_y = 60;
int len, width, left, mid, right, time;
int ttx = 10, tty = 10;
char game_map[80][1000];
int game_next[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; //上0下1左2右3;
int turn[2][3] = {{0, 3, 1}, //a -> b b -> c a -> c 上右下
{0, 2, 1}}; //b -> a c -> b c -> a 上左下 //实现自动移动的路线储存
void gotoxy(int x, int y) //坐标函数
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(handle, pos);
}
void init_game(int n)
{ //初始化汉诺塔
time = 50 / n;
left = 1, mid = 2 * (n + 1), right = mid + 2 * n + 1;
len = 3 * (2 * n + 1);
width = n + 1;
ttx = mid_x - width / 2;
tty = mid_y - len / 2;
int i, j;
for (i = 0; i <= width; i++)
{
for (j = 0, num = i; j <= len; j++)
{
if (i == 0 || j == 0 || i == width || j == len)
game_map[i][j] = '';
if ((i > 1 && i < width) && (j == mid - 1 || j == right - 1))
game_map[i][j] = '|';
if (num && (i >= 1 && i <= width - 1) && j % 2 != 0 && j < mid)
{
game_map[i][j] = -95;
game_map[i][j + 1] = -10; //打印 ■ ■占2个字节可以拆开来
num--;
}
}
}
//容易出现东西卡顿
for (i = 0; i <= width; i++)
{
gotoxy(tty, ttx + i);
for (j = 0; j <= len; j++)
printf("%c", game_map[i][j]);
printf("\n");
}
}
void play(int x, int y)
{ //显示汉诺塔移动轨迹
int turn_0, n = 0, i, j, k, tx, ty, flag = 0;
if ((x == mid && y == right) || (x == left && y == mid) || (x == left && y == right))
turn_0 = 0; //往右
else if ((x == mid && y == left) || (x == right && y == left) || (x == right && y == mid))
turn_0 = 1; //往左
for (i = 1, j = y; i <= width; i++)
{ //目的地
if (game_map[i][j] != 0)
{
tx = i - 1;
ty = j;
break;
}
}
for (i = 1, j = x; i <= width; i++)
{ //出发点
if (game_map[i][j] != 0)
{
break;
}
}
while (1)
{
while ((i != 1 || j != x) && (i != 1 || j != y) && (i != tx || j != ty))
{
if (turn_0 == 0)
for (k = mid - 3; k >= 0; k--)
{
game_map[i + game_next[turn[turn_0][n]][0]][j + game_next[turn[turn_0][n]][1] + k] = game_map[i][j + k];
game_map[i][j + k] = 0;
}
else
for (k = 0; k < mid - 2; k++)
{
game_map[i + game_next[turn[turn_0][n]][0]][j + game_next[turn[turn_0][n]][1] + k] = game_map[i][j + k];
game_map[i][j + k] = 0;
}
gotoxy(j + tty, i + ttx);
Sleep(time);
for (k = 0; k < mid - 2; k++)
{
printf(" ");
}
i = i + game_next[turn[turn_0][n]][0];
j = j + game_next[turn[turn_0][n]][1];
gotoxy(j + tty, i + ttx);
Sleep(time);
for (k = 0; k < mid - 2; k++)
{
printf("%c", game_map[i][j + k]);
}
}
n++; //改变方向;
if (i == tx && j == ty)
return;
if (turn_0 == 0)
for (k = mid - 3; k >= 0; k--)
{
game_map[i + game_next[turn[turn_0][n]][0]][j + game_next[turn[turn_0][n]][1] + k] = game_map[i][j + k];
game_map[i][j + k] = 0;
}
else
for (k = 0; k < mid - 2; k++)
{
game_map[i + game_next[turn[turn_0][n]][0]][j + game_next[turn[turn_0][n]][1] + k] = game_map[i][j + k];
game_map[i][j + k] = 0;
}
gotoxy(j + tty, i + ttx);
for (k = 0; k < mid - 2; k++)
{
printf(" ");
}
Sleep(time);
i = i + game_next[turn[turn_0][n]][0];
j = j + game_next[turn[turn_0][n]][1];
gotoxy(j + tty, i + ttx);
for (k = 0; k < mid - 2; k++)
printf("%c", game_map[i][j + k]);
Sleep(time);
}
}
void move_hnt(int a, int b, int c, char aa, char bb, char cc, int n)
{ //正常的汉诺塔递归程序
if (n == 1)
{
//printf("from %c to %c",aa,cc);
play(a, c);
return;
}
move_hnt(a, c, b, aa, cc, bb, n - 1);
/* gotoxy(0,width+1);
printf("from %c to %c",aa,cc);*/
play(a, c);
move_hnt(b, a, c, bb, aa, cc, n - 1);
}
void init()
{ //初始化整个程序
printf("↑ ↓ ← → 空格 进行操作\n\n");
printf("用空格按下电源键即可进行开机\n\n");
printf("xp系统祝你使用愉快~~\n\n");
printf("开机密码WHJY(按shift或者大写锁定键才能开大写)\n");
printf("桌面程序只有第一个和相关有用,其他暂未开放\n");
printf("汉诺塔程序运行过程中是不能中止的,尽量开6个以下\n"); //这里是原本写了一个版本,自动变化函数+人工输入函数能中途退出,但改一下整个程序都要改动,就放弃了那个版本
printf("按任意键继续\n");
getch();
int i, j, k;
system("color 70");
system("mode con cols=125 lines=60");
for (i = 0; i <= 40; i++)
{
printf("%s\n", map[i]);
Sleep(50);
}
x = 1, y = 20, num = board_place[keyboard[x][y]][2];
tx = board_place[keyboard[x][y]][3];
ty = board_place[keyboard[x][y]][4];
gotoxy(ty, tx);
//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),02);
for (i = 0; i < num; i++)
{
printf("%c", temp[i]);
}
}
void init_start()
{ // 开机 + 动态加载页面 + 打开输入密码权限
gotoxy(0, 0);
int i;
for (i = 0; i <= 16; i++)
{
printf("%s\n", start[i]);
Sleep(100);
}
int l, j;
for (l = 0; l < 3; l++)
{ //动态加载
for (i = 53; i <= 71; i = i + 2)
{
for (j = i - 4; j <= i; j = j + 2)
{
if (j >= 53 && j <= 70)
{
gotoxy(j, 12);
printf("[]");
}
Sleep(100);
}
for (j = i - 4; j <= i; j = j + 2)
{
if (j >= 53 && j <= 70)
{
gotoxy(j, 12);
printf(" ");
}
}
}
}
gotoxy(0, 0);
for (i = 0; i <= 16; i++)
{
printf("%s\n", password[i]);
Sleep(10);
}
if_input = 1; // 9 77 18个
input_x = 9;
input_y = 77;
input_max = 18;
}
void load_desktop()
{ //加载桌面
if_into_desktop = 1;
if_input == 0;
gotoxy(0, 0);
int i;
for (i = 0; i <= 16; i++)
{
printf("%s\n", desktop[i]);
Sleep(100);
}
}
void end()
{ //加载关机 (关机做的有点仓促)
gotoxy(0, 0);
int i;
for (i = 0; i <= 16; i++)
{
printf("%s\n", ending[i]);
Sleep(1000);
}
gotoxy(0, 0);
for (i = 0; i <= 16; i++)
{
printf("%s\n", map[i]);
Sleep(10);
}
}
void load_more()
{ //更多信息
gotoxy(0, 0);
int i;
for (i = 0; i <= 16; i++)
{
printf("%s\n", thinking[i]);
Sleep(1000);
}
}
void load_game()
{ //加载汉诺塔程序
if_into_desktop = 0;
gotoxy(0, 0);
int i;
for (i = 0; i <= 16; i++)
{
printf("%s\n", game_hnt[i]);
Sleep(100);
}
if_game = 1;
gotoxy(mid_y - 16, mid_x);
printf("请输入你要递归的汉诺塔数目_");
input_x = mid_x;
input_y = mid_y - 16 + 27;
input_max = 1;
if_input = 1;
}
int move()
{ //控制虚拟键盘的指针移动函数
int i, k;
char ch = '\0', ch1 = '\0';
while (ch != ' ')
{
ch = getch();
lx = x, ly = y;
if (ch != ' ' && ch != 'w' && ch != 's' && ch != 'a' && ch != 'd' &&
ch != -32)
continue;
if (ch == -32)
{ //同时启用wasd 和上下左右键 //如果读取到第一个是-32那么 继续读取一个字符
ch1 = getch();
switch (ch1)
{
case 72:
ch = 'w';
break;
case 75:
ch = 'a';
break;
case 80:
ch = 's';
break;
case 77:
ch = 'd';
break;
}
}
system("color 70");
gotoxy(0, tx);
printf("%s", map[tx]);
switch (ch)
{
case 'a':
y = y - 1;
break;
case 'd':
y = y + 1;
break;
case 'w':
x = x - 1;
break;
case 's':
x = x + 1;
break;
case ' ':
break;
}
if (keyboard[x][y] == 0)
{
x = lx;
y = ly;
}
num = board_place[keyboard[x][y]][2];
tx = board_place[keyboard[x][y]][3];
ty = board_place[keyboard[x][y]][4];
gotoxy(ty, tx);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 57);
for (i = 0; i < num; i++)
{
printf("%c", temp[i]);
}
gotoxy(ty, tx);
}
system("color 70");
if (board_place[keyboard[x][y]][0] == 0)
return 0;
else if (board_place[keyboard[x][y]][0] >= 1 && board_place[keyboard[x][y]][0] <= 9)
{
function = board_place[keyboard[x][y]][0];
/*gotoxy(0,41);
printf("%d",board_place[ keyboard[x][y] ][0]);*/
return 2;
}
else
{
letter = if_shift ? board_place[keyboard[x][y]][1] : board_place[keyboard[x][y]][0];
/*gotoxy(0,41);
printf("%c",board_place[ keyboard[x][y] ][0]);*/
return 1;
}
}
void put_letter_to_computer(char letter)
{ //把字符传输给电脑屏幕,如果电脑if_input为零就禁止显示
if (if_input == 1 && put_in_num < input_max)
{
put_in_computer[put_in_num] = letter;
put_in_num++;
put_in_computer[put_in_num] = '\0';
}
gotoxy(input_y, input_x);
printf("%s", put_in_computer);
}
void put_function_to_computer(int function)
{ //电脑处理相应共呢 1 ~ 返回 2 ~删除 3确认 4shift 5上 6左 7下 8又 9开机
if (function == 9)
{ //开机
if (if_start == 0)
{
init_start();
if_start = 1;
}
else
{
end();
if_start = 0;
if_into_desktop = 0;
}
}
if (function == 2 && put_in_num > 0 && if_input == 1)
{ //删除字符,但不可越界
put_in_num--;
put_in_computer[put_in_num] = '\0';
gotoxy(input_y, input_x);
printf("%s", put_in_computer);
printf(" ");
}
if (function == 4)
{ //切换大小写
if (if_shift)
if_shift = 0;
else
if_shift = 1;
}
if (function == 3 && if_input == 1 && if_game == 0)
{ //确认对应不同模式下的不同功能
if (strcmp(password_0, put_in_computer) == 0)
{
load_desktop();
if_input = 0;
put_in_num = 0;
put_in_computer[put_in_num] = '\0';
}
else
{
put_in_num = 0;
put_in_computer[put_in_num] = '\0';
gotoxy(input_y, input_x);
printf("密 码 错 误 !!!");
gotoxy(input_y, input_x);
Sleep(1200);
printf(" ");
gotoxy(input_y, input_x);
printf("|");
}
}
else if (function == 3 && if_game == 1 && put_in_num == 1 && put_in_computer[0] >= '1' && put_in_computer[0] <= '9')
{
gotoxy(mid_y - 16, mid_x);
printf(" ");
init_game(put_in_computer[0] - '0');
move_hnt(left, mid, right, 'a', 'b', 'c', put_in_computer[0] - '0');
Sleep(2000);
int i, j;
for (i = 0; i <= width; i++)
{
for (j = 0; j <= len; j++)
{
game_map[i][j] = 0;
}
}
if_game == 0;
if_input = 0;
load_desktop();
if_into_desktop = 1;
put_in_num = 0;
put_in_computer[0] = '\0';
}
else if (function == 3 && if_into_desktop)
{
if (cy == 1)
{
load_game();
if_game = 1;
}
else
{
load_more();
getch();
load_desktop();
}
}
//if(if_game == 1 && function >= 5 && function <= 8)) 移动类型游戏暂未开放
if (if_into_desktop && function >= 5 && function <= 8)
{
int ncx = cx + next[function][0], ncy = cy + next[function][1];
if (computer_map[ncx][ncy])
{
gotoxy(tcy, tcx);
printf(" ");
cx = ncx, cy = ncy;
tcx = computer_map_place[computer_map[cx][cy]][0];
tcy = computer_map_place[computer_map[cx][cy]][1];
lcx = cx, lcy = cy;
gotoxy(tcy, tcx);
printf("[]");
}
}
if (function == 1 && if_into_desktop)
{ //返回
load_desktop();
}
}
int main()
{
init();
/*load_desktop();//直接进入桌面
if_start = 1;
if_into_desktop = 1;*/
while (1)
{ //主循环
flag = move(); //move提取读取的键盘按键并判断类型
switch (flag)
{
case 0:
break; //暂无效果的按键
case 1:
put_letter_to_computer(letter);
break; //返回字符型按键给电脑
case 2:
put_function_to_computer(function);
break; //返回功能型按键给电脑
}
}
getchar();
}