Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 28th, 2012  |  syntax: Ada  |  size: 1.44 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. with Graphics; use Graphics;
  3. with Graphics.Snake; use Graphics.Snake;
  4. With Ada.Text_IO; use Ada.Text_IO;
  5.  
  6. procedure Snake is
  7.            C : Character;
  8.            S : Snake_Type (1 .. 5) := ((10, 10),
  9.                               (10, 11),
  10.                               (10, 12),
  11.                               (11, 12),
  12.                               (12, 12));
  13.  
  14.  
  15.  
  16.    task Run_Snake is
  17.       entry Input_ReceCed (S : Snake_Type; x : Integer; y : Integer);
  18.    end Run_Snake;
  19.  
  20.    task body Run_Snake is
  21.       D : constant Duration := 0.07;
  22.       B : Buffer (1 .. 24, 1 .. 80);
  23.    begin
  24.       loop
  25.          select
  26.             accept Input_ReceCed (S : Snake_Type; x : Integer; y : Integer) do
  27.                Move (S, x, y);  --Error here snake.adb:27:22: actual for "ASnake" must be a variable
  28.             end;
  29.          or
  30.             delay D;
  31.             Empty (B);
  32.             Draw_Rect (B, (1, 1), Width => 80, Height => 24);
  33.             Draw (B, S);
  34.             Update (B);
  35.          end select;
  36.       end loop;
  37.    end Run_Snake;
  38.  
  39.                                
  40.  
  41.  
  42. begin
  43.    loop
  44.         get(C);
  45.        
  46.         case C is
  47.                         when 'w' =>     Run_Snake.Input_ReceCed(S, 0, 1);
  48.                         when 'a' =>     Run_Snake.Input_ReceCed(S, -1, 0);
  49.                         when 'd' =>     Run_Snake.Input_ReceCed(S, 1, 0);
  50.                         when 's' =>     Run_Snake.Input_ReceCed(S, 0, -1);
  51.                         when 'x' => exit;
  52.                         when Others =>null;
  53.         end case;
  54.                
  55.      
  56.    end loop;
  57. end Snake;