VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
Python Online Multiplayer Game Development Tutorial

Python Online Multiplayer Game Development Tutorial

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
This Python online game tutorial will show you how to code a scaleable multiplayer game with python using sockets/networking and pygame. You will learn how to deploy your game so that people anywhere around the world can play against each other. You will learn and understand the following after this tutorial: - How a Client/Server System Works - How to Develop Applications to an External Server - How to Code a Client - How to Code a Server - Sending Encrypted Data Such as Objects Over a Port - Connecting Multiple Clients to a Server -Code: https://techwithtim.net/wp-content/uploads/2019/03/networkTutrorial.zip -- Contents -- -- (0:00:51) 1 - Creating a Client Using Sockets -- (0:16:55) 2 - Creating a Server -- (0:34:04) 3 - Sending & Receiving Information From Server -- (0:44:43) 4 - Connecting Multiple Clients -- (1:03:38) 5 - Sending Objects With Pickle! -- (1:14:52) 6 - Online Rock Paper Scissors - How to Install Pygame: https://www.youtube.com/watch?v=AdUZArA-kZw - Pycharm Download: https://www.jetbrains.com/pycharm/ - Tutorial from Tech with Tim. Check out his YouTube channel: https://www.youtube.com/techwithtim
Date: 2022-03-14

Comments and reviews: 10


This is not really a great tutorial. He basically just types everything out and keeps saying 'Don't worry, you'll understand it later', but he never actually explains anything later. Luckily most of the code is fairly self-explanatory.And some of that code is janky af. That line make_pos(read_pos) and then like a thousand brackets to convert a string to a tuple and back to a string.
Also nothing is commented so you have to do that all yourself but it also makes it impossible to come back to this code and re use it in future
On a more minor note, his names for variables are terrible 'p' and 'n' are basically textbook 'don't name your variables this' examples. Unfortunately this is the only tutorial like this I found so we have to make do.

reply

Thanks for a great tutrorial on Socket programming in Python.
Here's another way to handle to rules to RPC. First define the the rules like so:
self.rules = --
-R-: --R-: False, -P-: False, -S-: True-,-
-P-: --R-: True, -P-: False, -S-: False-,-
-S-: --R-: False, -P-: True, -S-: False--
-
# Note the rules only defines the winning combiniations.
Then the winner() method would be defined as:
def winner(self):-
p1 = self.moves[0].upper()[0]-
p2 = self.moves[1].upper()[0]-
winner = -1-
if self.rules[p1][p2]:-
winner = 0 # player Id 0 won-
elif self.rules[p2][p1]:-
winner = 1 # player Id 1 won
return winner
enjoy!

reply

Hey I know this video is old, but at 1:23:18 where you use if statements to check for the winner for rock paper scissors, you could instead use a nested dictionary to improve the runtime. I substituted the use of the following one:
windict = --R-:--S-:0, -P-:1, -R-: -1-, -P-:--R-:0, -S-: 1, -P-:-1-, -S-:--P-:0, -R-: 1, -S-:-1--
in this format, all I'd have to do is define the dictionary and then:
winner = windict[p1][p2]
-Tech With Tim

reply

For those having trouble running the required multiple files - server, client1, and client2 - in Visual Studio Code (VSC), open subsequent instances of VSC for each client file to run and then open and run the one client file in each instance, while running the server file in the main instance. Cool is that edits in the client file in the main VSC instance will automatically show up in the other open two instances.
reply

Could someone tell how to make server be accessible across the internet. That is, I want to access the server running in one network from a completely different network. I tried all methods, such as using public IP, etc etc, but nothing seems to work...
reply

Just a small hint for everyone watching:
Don't lose time watching/trying to understand this video or code if you don't have GOOD basic understanding in python.
First learn the basics and object oriented programming, then come and watch this video

reply

hey! I wanted to make a -The Price is Right- game where the opponent chooses a number and the other one has to guess it
depending of the number you pick it tells you -Higher- or -Lower-
could you help me please? thanks in advance! :D

reply

1:21:40 I typed exactly the code correctly, I even copied the code from the link, but I still had an error in .upper(). It says: Cannot find reference 'upper' in 'None'. How can I fix it? If anyone knows, please let me know :)
reply

I keep getting an error that says -OSError: [WinError 10022] An invalid argument was supplied- where I wrote -s.listen(2)-. Somebody please let me know what is going on.
reply

cool, but how i'm turn my socket in a real server?, exemplo: i need a socket for connect two peoples of != wi-fi, how i'm make this? i just can run in localhost
reply
Add a review, comment






Other channel videos