Kjetil's Information Center: A Blog About My Projects

Multiplayer Tank Game

Here is another game project I have had lying around for many years but never finished, until now that is. The idea was to make a graphical multiplayer game and the result is this game which lets up to 6 players drive a tank and shoot at each other. No emphasis on any advanced functionality, I just wanted to get this done and released. Note that a lot of trust is placed on the client here, which makes things simpler, but also makes it pretty easy to cheat by modifying the code.

The game is written in C and uses version 2 of the SDL library for graphics and sound. To make the networked multiplayer portion work, it uses the ENet reliable UDP networking library. It was created to be used on Linux, and I have not tried compiling and running it on other platforms. It probably works best on a local LAN, but I did test it through the Internet as well.

A screenshot:

Tank game screenshot


The map data is stored as a text file that looks like this, easily edited:

################################################################
#      #                                                       #
#      #                                                       #
#      #                                                       #
#   T  #                                                    T  #
#      #                                                       #
#      #                             T                         #
#      #      #########                                 ########
#                                                              #
#                                                              #
#                                                              #
#                                                              #
#             #                                                #
#             #                                                #
#             #                T                               #
#             #                              ###########       #
#             #                              #                 #
#             #                              #                 #
#             #                              #                 #
#             #                              #                 #
#             #            #########                           #
#             #            #########                           #
#             #            #########                           #
#     T       #            #########                           #
#             #            #########              T            #
#             #                                                #
#             #                                                #
#             #                                                #
#             #                                                #
#             #                                                #
#             #                                                #
#             #                T     #                         #
#             #                      #                         #
#             #                      #                         #
#             #                      ###################       #
#             #                                                #
#             #        #######                                 #
#                                                              #
#                                                              #
#                                                              #
########                                                #      #
#                                        T              #      #
#                                                       #      #
#                                                       #      #
#   T                                                   #   T  #
#                                                       #      #
#                                                       #      #
################################################################
          


The source code is released under the MIT license and can be downloaded here.

Topic: Open Source, by Kjetil @ 17/04-2021, Article Link