Haifisch7734

Hetman

Jan 14th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2.     for ($i = 0; $i < 8; $i++) {
  3.         for ($j = 0; $j < 8; $j++) {
  4.             $field[$i][$j] = 'O';
  5.         }
  6.     }
  7.    
  8.     $x = rand(0,7);
  9.     $y = rand(0,7);
  10.    
  11.     $field[$x][$y] = 'H';
  12.    
  13.     $pomX = $x + 1;
  14.     $pomY = $y;
  15.    
  16.     while ($pomX < 8) {
  17.         $field[$pomX][$pomY] = 'X';
  18.         $pomX++;
  19.     }
  20.    
  21.     $pomX = $x - 1;
  22.     $pomY = $y;
  23.    
  24.     while ($pomX >= 0) {
  25.         $field[$pomX][$pomY] = 'X';
  26.         $pomX--;
  27.     }
  28.    
  29.     $pomX = $x;
  30.     $pomY = $y - 1;
  31.    
  32.     while ($pomY >= 0) {
  33.         $field[$pomX][$pomY] = 'X';
  34.         $pomY--;
  35.     }
  36.    
  37.     $pomX = $x;
  38.     $pomY = $y + 1;
  39.    
  40.     while ($pomY < 8) {
  41.         $field[$pomX][$pomY] = 'X';
  42.         $pomY++;
  43.     }
  44.    
  45.     $pomX = $x + 1;
  46.     $pomY = $y + 1;
  47.    
  48.     while ($pomX < 8 && $pomY < 8) {
  49.         $field[$pomX][$pomY] = 'X';
  50.         $pomY++;
  51.         $pomX++;
  52.     }
  53.    
  54.     $pomX = $x + 1;
  55.     $pomY = $y - 1;
  56.    
  57.     while ($pomX < 8 && $pomY >= 0) {
  58.         $field[$pomX][$pomY] = 'X';
  59.         $pomY--;
  60.         $pomX++;
  61.     }
  62.    
  63.     $pomX = $x - 1;
  64.     $pomY = $y - 1;
  65.    
  66.     while ($pomX >= 0 && $pomY >= 0) {
  67.         $field[$pomX][$pomY] = 'X';
  68.         $pomY--;
  69.         $pomX--;
  70.     }
  71.    
  72.     $pomX = $x - 1;
  73.     $pomY = $y + 1;
  74.    
  75.     while ($pomX >= 0 && $pomY < 8) {
  76.         $field[$pomX][$pomY] = 'X';
  77.         $pomY++;
  78.         $pomX--;
  79.     }
  80.    
  81.     for ($i = 0; $i<8; $i++) {
  82.         for ($j = 0; $j<8; $j++) {
  83.             echo $field[$i][$j];
  84.         }
  85.         echo '<br />';
  86.     }
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment