MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / Input

Function Input

Project_Snake_Game/snake-game.cpp:96–124  ·  view source on GitHub ↗

managing input of keyboard to control snake

Source from the content-addressed store, hash-verified

94}
95// managing input of keyboard to control snake
96void Input() {
97 if (_kbhit())
98 {
99 switch (_getch())
100 {
101 case 'a':
102 dir = LEFT;
103 break;
104 case 'd':
105 dir = RIGHT;
106 break;
107 case 'w':
108 dir = UP;
109 break;
110 case 's':
111 dir = DOWN;
112 break;
113 case 'x':
114 game = false;
115 break;
116 case 'r':
117 dir = STOP;
118 welcome();
119 default:
120 break;
121 }
122
123 }
124}
125// logic how snake should grow in size and when game stops
126void Logic() {
127

Callers 1

startGameFunction · 0.85

Calls 1

welcomeFunction · 0.85

Tested by

no test coverage detected