unit ModuleS; interface type indicator = ^part; part = record coordinate_x,coordinate_y: byte; next: indicator end; var snake,tail: indicator; x,y,x1,y1: byte; input,key: char; FoodInsideSnake,TheEnd: boolean; score: word; board: array[1..10,1..10] of char; procedure SnakeDisplayStart; procedure SnakeDisplay; procedure AddSegment(length: byte); implementation procedure SnakeDisplayStart; begin while tail <> nil do with tail^ do begin board[coordinate_y,coordinate_x] := '0'; tail := next end end; procedure SnakeDisplay; begin while tail^.next <> nil do with tail^ do begin coordinate_y := next^.coordinate_y; coordinate_x := next^.coordinate_x; if (coordinate_y = y) and (coordinate_x = x) then TheEnd := true; if FoodInsideSnake = true then while (coordinate_y = y1) and (coordinate_x = x1) do begin x1 := random(10)+1; y1 := random(10)+1 end; board[coordinate_y,coordinate_x] := '0'; tail := next end end; procedure AddSegment(length: byte); var i: byte; begin for i := 1 to length do begin New(tail); tail^.next := snake; with tail^ do begin coordinate_y := y; coordinate_x := x + (i - 1) end; snake := tail end end; end.