Distributed computing using sockets and threads SPACE DUEL
RM32-99 MYR
Закрито
Опублікований over 8 years ago
RM32-99 MYR
Оплачується при отриманні
Write an ASCII graphics game for two computers using the techniques from Lab 5 and Lab 6 where each player controls a space ship. You always see your own space ship at the bottom of the screen, while your enemy's space ship is at the top of the screen, for example:
+------------------------------------------------------------------------------+
| +-H-+ |
| V |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| A |
| |
| |
| |
| V |
| |
| |
| |
| |
| |
| |
| A |
| +-H++ |
+------------------------------------------------------------------------------+
Here we see your space ship at the bottom shooting missiles “A” while your enemy, controlled from the other PC, shoots “V”. The missiles proceed across the screen until they hit the other side or another missile coming the opposite direction. (If two missiles hit each other, both are eliminated.)
You move your ship with the left and right arrow keys, and shoot with the up arrow key. Your program must communicate with the program running on the other computer in order to update the screen with the current ship and missile positions. You should be able to keep shooting more missiles even while earlier missiles are still flying on the screen.
The game ends when a missile hits a ship. The game should then announce whether you won or your opponent won.
Hint: to figure out what the arrow keys generate in getch, write a little test program that calls getch and prints out what the return value is.