-4 / 0 / 1
Регистрация: 24.12.2011
Сообщений: 51
1

Rewrite: File not found

03.09.2012, 20:54. Показов 751. Ответов 1
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
В процедуре Create_map ошибка в rewrite когда увидел был в шоке:
Pascal
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
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
uses crt,graph;
 
  const constMapWidth = 64;
        constMapHeight = 48;
        constBlockSize = 10;
 
        MAXNUMOFBANANAS = 200;
        MAXNUMOFWOOD = 110;
 
  type EBlockType =
  (
      ebtEmpty,
      ebtWood,
      ebtGrass,
      ebtRock,
      ebtBanana,
      ebtYourBanana,
      ebtWoodPlant,
      ebtSpawn,
      ebtSand,
      ebtBlock,
      ebtSave,
      ebtQuarry
  );
 
  type TMap = array[0..constMapWidth-1,0..constMapHeight-1] of EBlockType;
  type TPos = record
                x : integer;
                y : integer;
              end;
  type TBlockDrawParams = record
                         nStyle : byte;
                         nColor : byte;
                         bRect  : boolean;
                       end;
  const arrBlockDrawParams : array [ EBlockType ] of TBlockDrawParams =
        (
          (nStyle : 1; nColor : 11; bRect : true  ),      {ebtEmpty      }
 
          (nStyle : 1; nColor : 6 ; bRect : true  ),      {ebtWood       }
 
          (nStyle : 1; nColor : 10; bRect : true  ),      {ebtGrass      }
 
          (nStyle : 1; nColor : 8 ; bRect : true  ),      {ebtRock       }
 
          (nStyle : 4; nColor : 3 ; bRect : false ),      {ebtBanana     }
 
          (nStyle : 4; nColor : 5 ; bRect : false ),      {ebtYourBanana }
 
          (nStyle : 4; nColor : 6 ; bRect : true  ),      {ebtWoodPlant  }
 
          (nStyle : 1; nColor : 5 ; bRect : true  ),      {ebtSpawn      }
 
          (nStyle : 9; nColor : 14; bRect : true  ),      {ebtSand       }
 
          (nStyle : 1; nColor : 7 ; bRect : true  ),      {ebtBlock      }
 
          (nStyle : 4; nColor : 7 ; bRect : true  ),      {ebtSave       }
 
          (nStyle : 9; nColor : 11; bRect : true  )       {ebtQuarry     }
        );
 
 
  var g_map : TMap;
      MapPos : string;
      mp : text;
      monsterx,monstery:byte;
 
  Function NOSIF(var t : text) : integer;
  var Cnt:Integer;
      FileName,s:string;
  begin
    Cnt:=0;
    While not Eof(t) do
    begin
      ReadLn(t,s);
      Inc(Cnt);
    end;
    Close(t);
    Reset(t);
    NOSIF:=Cnt;
  end;
 
  Procedure ReadMap(mapcoor : string);
  var map : text;
      i,a : integer;
      fstring:string;
  begin
    Assign(map,mapcoor + '.map');
    Reset(map);
    for i:=0 to constMapWidth-1 do
    begin
      ReadLn(map,fstring);
      for a:= 0 to constMapHeight-1 do
      begin
        case fstring[a] of
 
         'G':  g_Map[i,a]:=ebtGrass;
 
         'Q':  g_Map[i,a]:=ebtQuarry;
 
         'D':  g_Map[i,a]:=ebtSave;
 
         'A':  g_Map[i,a]:=ebtBlock;
 
         'P':  g_Map[i,a]:=ebtYourBanana;
 
         'F':  g_Map[i,a]:=ebtWoodPlant;
 
         'D':  g_Map[i,a]:=ebtSpawn;
 
         'S':  g_Map[i,a]:=ebtSand;
 
         'W':  g_Map[i,a]:=ebtWood;
 
         'R':  g_Map[i,a]:=ebtRock;
 
         'B':  g_Map[i,a]:=ebtBanana;
 
         'E':  g_Map[i,a]:=ebtEmpty;
      end;
    end;
  end;
  end;
 
  function fileexists(var filename: string): boolean;
  var f: file;
  begin
    {$I-} assign(f,filename); reset(f); {$I+}
    fileexists:=(ioresult=0) and (filename<>'');
  end;
 
  Procedure CreateMobPos(var pos:TPos);
  Begin
    repeat
      pos.x := Random(constMapWidth);
      pos.y := Random(constMapHeight);
    until g_map[pos.x, pos.y] <> ebtEmpty;
  End;
  Procedure CreatePlayerPos(var pos:TPos);
  Begin
    repeat
      pos.x := Random(constMapWidth);
      pos.y := Random(constMapHeight);
    until g_map[pos.x, pos.y] <> ebtEmpty;
  End;
 
 
  PROCEDURE CreateMap(mapcoor : string);
 
     Function IsEmptyBlockClose(x : integer; y : integer) : boolean;{with this function I can know is empty close}
     Begin
       IsEmptyBlockClose := ( g_Map[x,y-1]   = ebtEmpty ) or
                            ( g_Map[x,y+1]   = ebtEmpty ) or
                            ( g_Map[x+1,y+1] = ebtEmpty ) or
                            ( g_Map[x+1,y-1] = ebtEmpty ) or
                            ( g_Map[x+1,y]   = ebtEmpty ) or
                            ( g_Map[x-1,y-1] = ebtEmpty ) or
                            ( g_Map[x-1,y+1] = ebtEmpty ) or
                            ( g_Map[x-1,y]   = ebtEmpty );
     End;
 
     Procedure CreateSpawn;
     var x,y:integer;
     Begin
       Repeat
          X:=Random(constMapWidth-1);
          Y:=Random(constMapHeight-1);
       Until not(g_Map[x,y]<>ebtGrass)and(not(g_Map[x+1,y+1]<>ebtGrass));
       g_Map[x,y]:=ebtSpawn;
 
     End;
 
  const constNumOfIslands = 29;
        constIslandWidth  = 16;
 
 
  var iBlocksInString,IslandWidth : byte;
      iIsland,numofplants,plantx,planty,rand,x,y,iIslandString : integer;
      numOfplantxhasbeenset,numOfplantyhasbeenset:integer;
      DB:boolean;
      map:text;
  Begin
    {generate areas of earh, i.e.islands}
    for iIsland := 1 to constNumOfIslands do
    begin
      db:=false;
      islandWidth:=1;
      if (iIsland<6){create place of first island block}
         then begin
              y:=10+Random(17);
              x:=10+Random(35);
              end
         else begin
              y:=25+Random(7);
              x:=Random(45);
              end;
 
      for iIslandString:=1 to 21{number of row in island} do{create new row}
      begin
        for iBlocksInString:=1 to IslandWidth do{create new block in row}
        begin
          rand:=Random(100);{random for beutiful terrarian}
           if (rand<=90)then
                g_Map[x+iIslandString,y+iBlocksInString]:=ebtGrass
           else g_Map[x+iIslandString,y+iBlocksInString]:=ebtWood;
           if (rand=1)
              then g_Map[x+iIslandString,y+iBlocksInString]:=ebtRock;
           if (rand=0)
              then g_Map[x+iIslandString,y+iBlocksInString]:=ebtEmpty;
        end;
 
      if(IslandWidth>=20)
       then begin
              db:=true;
            end;
      if (db)
       then begin
              y:=y+1;
              IslandWidth:=IslandWidth-2;
            end
       else begin
              y:=y-1;
              IslandWidth:=IslandWidth+2;
             end;
      end;
    end;
 
    {set bananas}
    For numOfplants:=0 to 4 do
    begin
      { find not empty block }
      Repeat
          plantx:=Random(constMapWidth);
          planty:=Random(constMapHeight);
      Until g_Map[plantx,planty]<>ebtEmpty;
 
      {set bananas in found place}
      For x:=0 to 2 do
      begin
        For y:=0 to 2 do
        begin
          g_Map[x+plantx,y+planty]:=ebtBanana;
        end;
      end;
    end;
 
    {edge of map should be water}
    for x:=0 to  constMapWidth-1 do
    begin
      g_Map[x,0]:=ebtEmpty;
      g_Map[x,constMapHeight-1]:=ebtEmpty;
    end;
    for y:=0 to  constMapHeight-1 do
    begin
      g_Map[0,y]:=ebtEmpty;
      g_Map[constMapWidth-1,y]:=ebtEmpty;
    end;
 
    {set sand on the edge of water}
    for x:=1 to  constMapWidth-1 do
    begin
        for y:=1 to constMapHeight-1 do
        begin
            if (g_Map[x,y]=ebtGrass) and IsEmptyBlockClose(x,y)
               then g_Map[x,y]:=ebtSand;
        end;
    end;
 
    Assign(map, mapcoor);
    Rewrite(map);
 
    for y:=1 to  constMapHeight-1 do
    begin
        for x:=1 to constMapWidth-1 do
        begin
            if (g_Map[x,y]=ebtGrass)then
              Write(map,'G');
            if(g_Map[x,y]=ebtQuarry)then
              Write(map,'Q');
            if(g_Map[x,y]=ebtSave)then
              Write(mapcoor + '.map','D');
            if(g_Map[x,y]=ebtBlock)then
              Write(map,'A');
            if(g_Map[x,y]=ebtYourBanana)then
              Write(map,'P');
            if(g_Map[x,y]=ebtWoodPlant)then
              Write(map,'F');
            if(g_Map[x,y]=ebtSpawn)then
              Write(map, 'D');
            if(g_Map[x,y]=ebtSand)then
              Write(map,'S');
            if(g_Map[x,y]=ebtWood)then
              Write(map,'W');
            if(g_Map[x,y]=ebtRock)then
              Write(map,'R');
            if(g_Map[x,y]=ebtBanana)then
              Write(map,'B');
            if(g_map[x,y]=ebtEmpty)then
              Write(map,'E')
        end;
        WriteLn(map,'');
    end;
 
    CreateSpawn;
 
  End;
 
  Procedure DrawBlock(iCol   : integer;
                         iRow   : integer;
                         nStyle : byte;
                         eBlock : EBlockType;
                         nColor : byte
                        );
     var x,y:integer;
 
     begin
       SetFillStyle(nStyle,nColor);
       x := constBlockSize*iCol;
       y := constBlockSize*iRow;
       Bar(x,y,x+constBlockSize,y+constBlockSize);
       if arrBlockDrawParams[eBlock].bRect
          then Rectangle(x,y,x+constBlockSize,y+constBlockSize);
     end;
 
  PROCEDURE DrawMap;
     var  iRow, iCol : integer;
       x,y:integer;
       nStyle, nColor : byte;
       eBlock         : EBlockType;
  Begin
    For iCol:=0 to constMapWidth-1 do
    begin
      For iRow:=0 to constMapHeight-1  do
      begin
        eBlock := g_Map[icol,irow];
 
        SetFillStyle( arrBlockDrawParams[eBlock].nStyle
                    , arrBlockDrawParams[eBlock].nColor);
        x := constBlockSize*iCol;
        y := constBlockSize*iRow;
        DrawBlock(icol,irow,arrBlockDrawParams[eBlock].nstyle,eblock,arrBlockDrawParams[eBlock].ncolor);
      end;
 
    end;
  End;
 
var nextx,nexty:Shortint;
PROCEDURE MoveBot(mobpos,playerpos:TPos;
                  var health:byte);
var monsrtergoto:byte;
Begin
  if(playerpos.x=mobpos.x)then
    begin
      if(playerpos.y=mobpos.y)then
        begin
          health:=health-Random(5)-5;
        end
      else
        begin
          if(playerpos.y<mobpos.y)then
            begin
              if(g_map[mobpos.x,mobpos.y-1]<>ebtEmpty)and
                (g_map[mobpos.x,mobpos.y-1]<>ebtSave)then
                begin
                  nexty:=-1
                end
              else
                begin
                  if(g_map[mobpos.x+1,mobpos.y]<>ebtEmpty)and
                  (g_map[mobpos.x+1,mobpos.y]<>ebtSave)then
                    begin
                      nextx:=1;
                    end;
                  if(g_map[mobpos.x-1,mobpos.y]<>ebtEmpty)and
                    (g_map[mobpos.x-1,mobpos.y]<>ebtSave)then
                    begin
                      nextx:=-1;
                    end;
                end;
            end
          else
            begin
              if(g_map[mobpos.x,mobpos.y+1]<>ebtEmpty)and
                (g_map[mobpos.x,mobpos.y+1]<>ebtSave)then
                begin
                  nexty:=1
                end
              else
                begin
                  if(g_map[mobpos.x+1,mobpos.y]<>ebtEmpty)and
                    (g_map[mobpos.x+1,mobpos.y]<>ebtSave)then
                    begin
                      nextx:=1;
                    end;
                  if(g_map[mobpos.x-1,mobpos.y]<>ebtEmpty)and
                    (g_map[mobpos.x-1,mobpos.y]<>ebtSave)then
                    begin
                      nextx:=-1;
                    end;
                end;
            end;
          end;
    end
  else
    begin
      if(playerpos.x=mobpos.x)then
        begin
          health:=health-Random(5)-5;
        end
      else
        begin
          if(playerpos.x<mobpos.x)then
            begin
              if(g_map[mobpos.x-1,mobpos.y]<>ebtEmpty)and
                (g_map[mobpos.x-1,mobpos.y]<>ebtSave)then
                begin
                  nextx:=-1
                end
              else
                begin
                  if(g_map[mobpos.x,mobpos.y+1]<>ebtEmpty)and
                    (g_map[mobpos.x,mobpos.y+1]<>ebtSave)then
                    begin
                      nexty:=1;
                    end;
                  if(g_map[mobpos.x,mobpos.y-1]<>ebtEmpty)and
                    (g_map[mobpos.x,mobpos.y-1]<>ebtSave)then
                    begin
                      nexty:=-1;
                    end;
                end;
            end
          else
            begin
              if(g_map[mobpos.x+1,mobpos.y]<>ebtEmpty)and
                (g_map[mobpos.x+1,mobpos.y]<>ebtSave)then
                begin
                  nextx:=1
                end
              else
                begin
                  if(g_map[mobpos.x,mobpos.y+1]<>ebtEmpty)and
                    (g_map[mobpos.x,mobpos.y+1]<>ebtSave)then
                    begin
                      nexty:=1;
                    end;
                  if(g_map[mobpos.x,mobpos.y-1]<>ebtEmpty)and
                    (g_map[mobpos.x,mobpos.y-1]<>ebtSave)then
                    begin
                      nexty:=-1;
                    end;
                end;
            end;
          end;
    end;
  if((playerPos.x=mobPos.x+1)and
    (playerPos.y=mobPos.y+2))then
    begin
      if(g_map[mobpos.x,mobpos.y+1]<>ebtEmpty)and
      (g_map[mobpos.x,mobpos.y+1]<>ebtSave)then
        begin
          nexty:=1;
          nextx:=0;
        end;
    end;
  if((playerPos.x=mobPos.x+1)and
  (playerPos.y=mobPos.y+1))then
    begin
      if(g_map[mobpos.x,mobpos.y+1]<>ebtEmpty)and
      (g_map[mobpos.x,mobpos.y+1]<>ebtSave)then
        begin
          nexty:=1;
          nextx:=0;
        end;
    end;
  if((playerPos.x=mobPos.x+1)and
  (playerPos.y=mobPos.y-2))then
    begin
      if(g_map[mobpos.x,mobpos.y-1]<>ebtEmpty)and
      (g_map[mobpos.x,mobpos.y-1]<>ebtSave)then
      begin
        nexty:=-1;
        nextx:=0;
      end;
    end;
  if((playerPos.x=mobPos.x+1)and
  (playerPos.y=mobPos.y-1))then
    begin
      if(g_map[mobpos.x,mobpos.y-1]<>ebtEmpty)and
      (g_map[mobpos.x,mobpos.y-1]<>ebtSave)then
      begin
        nexty:=-1;
        nextx:=0;
      end;
    end;
  if((nextx<>0)and(nexty<>0))then
    begin
      if(Random(100)>50)then
        nextx:=0
      else
        nexty:=0;
    end;
End;
var n:integer;
PROCEDURE Bot(var posMob,posPlayer:TPos;
                  step:integer;
              var health:byte);
var eblock : eBlockType;
Begin
  if(step>100)then
  Begin
     eblock:=g_map[posMob.x,posMob.y];
     DrawBlock(posMob.x,
               posMob.y,
               arrBlockDrawParams[eBlock].nstyle,
               eblock,
               arrBlockDrawParams[eBlock].ncolor);
     SetFillStyle(1,1);
     if((nextx<>0)and(nexty<>0))then
       begin
         if(Random(100)>50)then
           nextx:=0
         else
           nexty:=0;
       end;
     MoveBot(posMob,posPlayer,health);
     posMob.x:=posMob.x+nextx;
     posMob.y:=posMob.y+nexty;
     nextx:=0;
     nexty:=0;
  end;
  if(((g_map[posMob.x+1,posMob.y]=ebtSave)or
     (g_map[posMob.x+1,posMob.y]=ebtEmpty))and
     ((g_map[posMob.x-1,posMob.y]=ebtSave)or
     (g_map[posMob.x-1,posMob.y]=ebtEmpty))and
     ((g_map[posMob.x,posMob.y+1]=ebtSave)or
     (g_map[posMob.x,posMob.y+1]=ebtEmpty))and
     ((g_map[posMob.x,posMob.y-1]=ebtSave)or
     (g_map[posMob.x,posMob.y-1]=ebtEmpty)))then
     begin
       n:=n+1;
       if(n>500)then
         begin
           CreateMobPos(posMob);
           n:=0;
         end;
     end;
  SetFillStyle(1,1);
  bar(posMob.x*constBlockSize,
      posMob.y*constBlockSize,
      posMob.x*constBlockSize+constBlockSize,
      posMob.y*constBlockSize+constBlockSize);
  Rectangle(posMob.x*constBlockSize,
            posMob.y*constBlockSize,
            posMob.x*constBlockSize+constBlockSize,
            posMob.y*constBlockSize+constBlockSize);
End;
var exit:boolean;
PROCEDURE DrawIndicators(bananas,wood,Health:integer);
var numofsquare:byte;
    strwood,strbana:string;
Begin
  {----Else----}
    if (wood > MAXNUMOFWOOD)
       then wood:=MAXNUMOFWOOD;
    if (bananas > MAXNUMOFBANANAS)
       then BANANAS:=MAXNUMOFBANANAS;
 
    SetFillStyle(1,11);
    Bar(0,450,310,480);
    SetColor(1);
    str(wood,strwood);
    strwood:='Number of wood is: '+strwood;
    str(bananas,strbana);
    strbana:='Number of bananas is: '+strbana;
    SetFillStyle(1,0);
    bar(0,440,10,450);
    OutTextXY(0,460,strbana);
    OutTextXY(0,450,strwood);
    SetColor(15);
    if(health<3)then
      Begin
        exit:=true;
      end;
  {----Else----}
 
 
  {---Health---}
  setcolor(4);
  for numofsquare:=1 to health div 10 do
    Begin
      OutTextXY(1+numofsquare*10-10,472,chr(3));
    End;
  {---Health---}
 
  SetColor(15);
 
  {---Banana---}
  SetFillStyle(1,12);
          For numofsquare:=1 to wood div 11 do
            begin
              bar(200+numofsquare*10,450,210+numofsquare*10,460);
              rectangle(200+numofsquare*10,450,210+numofsquare*10,460);
            end;
  {---Banana---}
 
 
  {----Wood----}
  SetFillStyle(1,17);
          For numofsquare:=1 to bananas div 20 do
            begin
              bar(200+numofsquare*10,460,210+numofsquare*10,470);
              rectangle(200+numofsquare*10,460,210+numofsquare*10,470);
            end;
  {----Wood----}
  setcolor(15);
End;
 
Procedure MovePlayer(var posPlayer,posMob:Tpos;
                     var health:byte);
var exit,saveorblock : boolean;
    numofwood,bananas:word;
    plants,numofstep,numofseeds:longint;
    strwood,strbana:string;
    quarrypos:tpos;
  Procedure PressKey(var SpawnHealth:integer);
  const up=72;        {Buttons keys}
        down=80;
        left=75;
        right=77;
        mine=101;
        bplant=113;
        wplant=122;
        w=119;
        a=97;
        s=115;
        d=100;
        x=120;
        j=106;
        k=107;
        h=104;
        help=59;      {Buttons keys}
  Function IsPlayerOnPlant(PlayerPOs:TPos):boolean;
  Begin
    if(g_map[PlayerPOs.x,PlayerPOs.y]=ebtBanana)then
      begin
        IsPlayerOnPlant:=true;
        plants:=plants+1;
      end
    else
      IsPlayerOnPlant:=false;
  End;
  var key : char;
      eblock : EblockType;
  Begin
    numofstep:=numofstep+1;{Number of steps}
    Bot(posMob,posPlayer,numofstep,health);{This procedure controls bot}
    if ((NumOfStep mod 20)=0){every 10 step doings somethig procedures}
       then begin
            bananas:=bananas+1+plants div 3;
            numofwood:=numofwood+numofseeds div 3;
            health:=health+5;
            if(health>100)then health:=100;
            end;
    key:=ReadKey;
    if(key=#0)then{ReadKey retuns 0 and code of key what you've pressed}
      key:=readkey;{This ReadKey returnus code of key what you've pressed}
    eblock:=g_map[posPlayer.x,posPlayer.y];
    DrawBlock(posPlayer.x,
              posPlayer.y,
              arrBlockDrawParams[eBlock].nstyle,
              eblock,arrBlockDrawParams[eBlock].ncolor);
    case ord(key) of
       up:      begin
                  if(g_map[posPlayer.x,posPlayer.y-1]<>ebtEmpty)then
                     posPlayer.y:=posPlayer.y-1;
                end;
 
       down:    begin
                  if(g_map[posPlayer.x,posPlayer.y+1]<>ebtEmpty)then
                    posPlayer.y:=posPlayer.y+1;
                end;
 
       left:    begin
                  if(g_map[posPlayer.x-1,posPlayer.y]<>ebtEmpty)then
                    posPlayer.x:=posPlayer.x-1;
                end;
 
       right:   begin
                  if(g_map[posPlayer.x+1,posPlayer.y]<>ebtEmpty)then
                    posPlayer.x:=posPlayer.x+1;
                end;
 
       x:       if(saveorblock)then
                  saveorblock:=false
                else
                  saveorblock:=true;
 
       w:       begin
                  if(bananas>=5)and(numofwood>=5)then
                    begin
                     if(saveorblock)then
                       if(g_map[posPlayer.x,posPlayer.y-1]=ebtEmpty)then
                         g_map[posPlayer.x,posPlayer.y-1]:=ebtBlock
                       else
                         g_map[posPlayer.x,posPlayer.y-1]:=ebtSave;
                  eblock:=g_map[posPlayer.x,posPlayer.y-1];
                  DrawBlock(posPlayer.x,
                            posPlayer.y-1,
                            arrBlockDrawParams[eBlock].nstyle,
                            eblock,arrBlockDrawParams[eBlock].ncolor);
                end;
                end;
 
       s:       begin
                  if(bananas>=5)and(numofwood>=5)then
                    begin
                     if(saveorblock)then
                       if(g_map[posPlayer.x,posPlayer.y+1]=ebtEmpty)then
                         g_map[posPlayer.x,posPlayer.y+1]:=ebtBlock
                     else
                       g_map[posPlayer.x,posPlayer.y+1]:=ebtSave;
                  eblock:=g_map[posPlayer.x,posPlayer.y+1];
                  DrawBlock(posPlayer.x,
                            posPlayer.y+1,
                            arrBlockDrawParams[eBlock].nstyle,
                            eblock,arrBlockDrawParams[eBlock].ncolor);
                end;
                end;
 
       a:       begin
                  if(bananas>=5)and(numofwood>=5)then
                    begin
                     if(saveorblock)then
                       if(g_map[posPlayer.x-1,posPlayer.y]=ebtEmpty)then
                         g_map[posPlayer.x-1,posPlayer.y]:=ebtBlock
                     else
                       g_map[posPlayer.x-1,posPlayer.y]:=ebtSave;
                  eblock:=g_map[posPlayer.x-1,posPlayer.y];
                  DrawBlock(posPlayer.x-1,
                            posPlayer.y,
                            arrBlockDrawParams[eBlock].nstyle,
                            eblock,arrBlockDrawParams[eBlock].ncolor);
                end;
                end;
 
       d:       begin
                  if(bananas>=5)and(numofwood>=5)then
                    begin
                     if(saveorblock)then
                       if(g_map[posPlayer.x+1,posPlayer.y]=ebtEmpty)then
                         g_map[posPlayer.x+1,posPlayer.y]:=ebtBlock
                     else
                       g_map[posPlayer.x+1,posPlayer.y]:=ebtSave;
                  eblock:=g_map[posPlayer.x+1,posPlayer.y];
                  DrawBlock(posPlayer.x+1,
                            posPlayer.y,
                            arrBlockDrawParams[eBlock].nstyle,
                            eblock,arrBlockDrawParams[eBlock].ncolor);
                end;
                end;
 
       wplant:  begin
                  if(bananas>=15)and(numofwood>=5)
                   then begin
                         bananas:=bananas-15;
                         numofwood:=numofwood-5;
                         g_map[posPlayer.x,posPlayer.y]:=ebtWoodPlant;
                         numofseeds:=numofseeds+1;
                        end;
                end;
 
       mine:    begin
                  if((bananas>=5)and(g_map[posPlayer.x,posPlayer.y]=ebtWood))
                   then begin
                         bananas:=bananas-5;
                         g_map[posPlayer.x,posPlayer.y]:=ebtGrass;
                         numofwood:=numofwood+4+Random(1);
                        end;
                  if((bananas>=MAXNUMOFBANANAS div 2)and
                    (numofwood>=MAXNUMOFWOOD div 2)and
                    (g_map[posPlayer.x,posPlayer.y]=ebtSpawn))
                   then begin
                         bananas:=100;
                         spawnhealth:=spawnhealth-1;
                         iF(spawnhealth<=0)then
                           begin
                             g_map[posPlayer.x,posPlayer.y]:=ebtGrass;
                             {spawn:=false;}
                           end;
                         numofwood:=55;
                        end;
                end;
 
       bplant:  begin
                  if(bananas>=15)
                   then begin
                         bananas:=bananas-15;
                         g_map[posPlayer.x,posPlayer.y]:=ebtYourBanana;
                        end;
                end;
 
       j:       begin
                  key:=readkey;
                  if(ord(key)=k)then
                    begin
                     key:=readkey;
                     if(ord(key)=h)then
                       begin
                         numofwood:=200;
                         bananas:=200;
                       end;
                    end;
                end;
 
       help:    begin
                  ClrScr;
                  OutTextXY(1,1,'Hello,Player!');
                  OutTextXY(1,10,'Now you plaing in Ilands Adventures v3.1 IM&Q (Intelectual Mobs & Mining).');
                  OutTextXY(1,20,'Stop you did not read help in the title scren?!');
                  OutTextXY(1,30,'Game by yegof1,n-klyshko and A-Ikon.Give us a cookie, it will be realy cool :D.');
                  ReadKey;
                  DrawMap;
                end;
 
       27:      exit:=true;
    end;
    if (IsPlayerOnPlant(posPlayer))
       then g_map[POsPlayer.x,POsPlayer.y]:=ebtYourBanana;
    DrawIndicators(bananas,numofwood,health);
    setFillStyle(9,5);
    bar(posPlayer.
        x*constBlockSize,
        posPlayer.y*constBlockSize,
        posPlayer.x*constBlockSize+10,
        posPlayer.y*constBlockSize+10);
 
    rectangle(posPlayer.x*constBlockSize,
              posPlayer.y*constBlockSize,
              posPlayer.x*constBlockSize+10,
              posPlayer.y*constBlockSize+10);
 
    if(health>100)then
      begin
        SetTextStyle(DefaultFont, HorizDir,5);
        SetColor(12);
        OutTextXY(200,130,'You lose!!!');
        delay(2000);
        ReadKey;
        exit:=true;
      end;
  End;
 
var x,spawnhealth,y:integer;
Begin
  numofstep:=0;
  numofwood:=0;
  bananas:=0;
  plants:=0;
  numofseeds:=0;
  spawnhealth:=10;
  exit:=false;
  saveorblock:=true;
  while not(exit) do
    PressKey(spawnhealth);
End;
 
var key : char;
    grDriver,grMode,mapposX,mapposY : integer;
    health:byte;
    posPlayer,posMob:Tpos;
    donothing:string;
 
Begin
  grDriver:=Detect;
  Randomize;
  InitGraph(grDriver,grMode,'../bgi');
  donothing:='mappos.pos';
  Assign(mp,'mappos.pos');
 
  if(not(FileExists(donothing)))then
    begin
      Rewrite(mp);
      WriteLn(mp,'0');
      WriteLn(mp,'0');
    end
  else
    begin
      Reset(mp);
      ReadLn(mp,mapposX);
      ReadLn(mp,mapposY);
      Close(mp);
      Rewrite(mp);
      Str(mapposX, donothing);
      MapPos := donothing + ',';
      Str(mapposY, donothing);
      MapPos := MapPos + donothing;
      WriteLn(mp,MapPos);
    end;
  donothing := mappos + '.map';
  if not(fileexists(donothing))then
    CreateMap(mappos + '.map')
  else
    ReadMap(donothing);
  SetBkColor(11);
  DrawMap;
  CreateMobPos(posMob);
  CreatePlayerPos(posPlayer);
  health:=100;
  n:=0;
  MovePlayer(posPlayer,posMob,health);
End.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
03.09.2012, 20:54
Ответы с готовыми решениями:

File not found (Graph.tpu)
Почему выдает ету ошибку File not found (Graph.tpu)

File not found <GRAPH.TRU> .
Всем привет! Вот решил всерьёз заняться паскалем ,тем более мне это будет требоваться при...

File not found winprocs.tpu
Сначала была такая же ошибка с WinTypes, его смог найти, теперь проблема с WinProcs. Borland Pascal...

Ошибка в программе( File not found)
Подскажите, пожалуйста, в чём ошибка. Выдаёт ошибку File not Found, файл dano создан, данные в нём...

1
6044 / 2159 / 753
Регистрация: 10.12.2010
Сообщений: 6,005
Записей в блоге: 3
03.09.2012, 22:15 2
Пока что мысль одна: строка содержит какой-то посторонний символ, который недопустим в имени файла. Попробуйте вывести на экран и посмотреть что на вход попало.
0
03.09.2012, 22:15
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
03.09.2012, 22:15
Помогаю со студенческими работами здесь

Error 15: File not found (GRAPH.TPU)
в чём смысл ошибки? нада пересохранить?

Error 15: file not found <sysutils.Tpu>
program Project1; uses SysUtils; var a,b,x,y:Integer; begin Write('Vvedite X='); ...

Unit и ошибка Error 15: file not found *.tpu
Привет! Дело такое: в турбо паскале был создан свой модуль, скомпилирован(создался *.tpu файл)....

Пишет error 15: File not found <TPCRT.TPU>
Пишет error 15: File not found &lt;TPCRT.TPU&gt; .


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2023, CyberForum.ru