This is an school assignment. To create a snake game. So I have created two packages one for graphics and one for the snake. The snake moves smoothly and everything works. But I need to control the snake with the keyboard.This is the main procedure:
with Graphics; use Graphics;
with Graphics.Snake; use Graphics.Snake;
procedure Run_Snake is
B : Buffer (1 .. 24, 1 .. 80);
S : Snake_Type (1 .. 5) := ((10, 10),
(10, 11),
(10, 12),
(11, 12),
(12, 12));
D : Duration := 0.07;
begin
loop
Empty (B);
Draw_Rect (B, (1, 1), Width => 80,
Height => 24);
Draw (B, S);
Update (B);
Move (S, 0, -1);
delay D;
end loop;
end Run_Snake;
in this line of code I controll the snakes head rotation:
Move (S, x, y);
where x is the x value it can be -1 for left, 1 for right.
where y is the y value it can be -1 for down, 1 for up;
Anyways, how can I read the input without pausing the snake from moving? Thanks