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:
⭐️ 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:
🔗 Pycharm Download:
🎥 Tutorial from Tech with Tim. Check out his YouTube channel:
—
Learn to code for free and get a developer job:
Read hundreds of articles on programming:
And subscribe for new videos on technology:
kbrunot13
15.07.2023cool, 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
Srivatsan Suresh
14.07.2023Could 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…
نون الصالح
14.07.2023Game link?
Bgamer Bass
14.07.2023Just 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
The Flusches
14.07.2023where is 'start_new_thread'?
Tom Brandis
14.07.2023learning python whilst I am isolating with covid
Tom Brandis
14.07.2023I have seen a few videos about something called ursina for making 3d stuff – has anyone used it and how hard is it to use
bloxxer02
14.07.2023i wish you labeled the code before publishing theres a cool thing in coding called documenting your work for educational purposes
LagDaemon Programming
14.07.2023SOCK_STREAM means that the socket uses TCP/IP and holds Connections. SOCK_DGRAM is connectionless and uses the User Datagram Protocol (UDP).
Jean Zyx
14.07.2023amaizing tutorial gg
Petko Popov
14.07.2023deubg time to time pls!
Gabriel1443
12.07.2023this is super useful and fun thank you TIM!!
The Flusches
12.07.2023Never mind I found start_new_thread. Could you send a link to the files though? I am making a similar game but encountering lots of errors.
Emmess d
12.07.2023how can i play it with my friend now on two different computers?
Force
12.07.2023About 1:23:57
Hope u read it and say ur opinion about this method
There is an easier way
U just make a list:
Priority = ['R', 'P','S']
And then u can just say
If p1 == p2
Return -1
Elif Priority[Priority.index(p1)-1]==p2
Return 0
Else return 1
Pranav Nyavanandi
12.07.2023God.., does this guy know everything?😄
FantasticBeast
12.07.20231:23:15 I think this works too: implement moves as circular priority
Move=["R":0,"P":1,"S":2]
if(Move[p1]==Move[p2]):
TIE
elif((Move[p1]+1) mod 3==Move[p2]):
p2 winner
else:
p1 winner
aydin anginer
12.07.2023never use try: … except: pass, it's just bad, print error or something
조기영
12.07.2023when I execute client file at first video I get a error messge 'video system not initialized' at "keys= pygame.key.get_pressed()".
Is there any problem to execute the program? Why this happen?
Faisal
12.07.2023how do i play this with my friends
Aarthi Iyer
12.07.2023i'm getting the same error as at 41:10
s.listen(2)
OSError: [WinError 10022] An invalid argument was supplied
How do I resolve it?
Cole Payne-sexton
09.07.2023for linux
python3 –version
if it says python3 command not found then install python 3 with the following
sudo apt update && sudo apt upgrade -y && sudo apt install python3 -y && sudo apt install python3-pip -y
at the next prompt (assuming no errors) run the following
python3 -m pip install tk && sudo apt install tk and python3 -m pip install pygame
you vanced
09.07.2023But how can people access the game? They have to install it on their computer right? Cause pygame can't run on the browser
vafadie kongolo
09.07.2023Hi I am learn python for kids
Nils
09.07.2023Even if the Video is a bit older, can anyone help me? When I try to run the server, it throws an error and says that s.listen, an invalid argument is given, no matter how often I rewrite it or write 2 or nothing in the brackets…
Isak Kack
09.07.2023I got the error [WinError 10053] du you know hot to fix it
Anna Tsvetkova
09.07.2023You are just amazing!!! As well as your typing!!!!!
Nick Cooper
09.07.2023finaly a pycharm tutorial 😀
Amaury Ribeiro
09.07.20231:15:05 6
AdriHack07
09.07.2023Hello, I have no idea what all of this means (starting with the server file). Could you maybe explain all that vocabulary?
spiral spark
09.07.2023by 17:00 i got distracted and made a whole sliding system, and I have never object orientedly programmed before
SPACE STORIES
08.07.2023Sir, how do I run it on different networks?
モハイ・イェレン
08.07.2023so just wondering, I get this error at1:13:50when i'm trying to run the client:EOFError: Ran out of inputAnd after a wile another error was appared at the server console:Exception ignored in thread started by: <function threaded_client at 0x000001B6074C1C60>Traceback (most recent call last):File "MYDESK:MYFOLDERMutiplayer Gameserver.py", line 76, in threaded_clientconn.send(pickle.dumps(players[player]))IndexError: list index out of rangeI maked sure everything was the exact same from your codeI FIXED IT
Where is the gobal server part ;-;
Lydia Shanad
08.07.2023line 48, in main
p = Player(50,50,100,100.(0,255,0))
TypeError: 'float' object is not callable
That error came to me when I tested the player
Storm keeper
08.07.2023ı found this tutorial helpful but my coding doesnt accept "import pygame" part and some other part idk why can someoen help me im new at this
Rusty Trombone
08.07.2023not the best tutorial if you dont already know what pygame does. very fast pace, and no explanations are given.
The Chipmonks
08.07.2023great video, but a little question,
all this is on local host, what if we want to host it on a remote server and then connect over the internet
Order
08.07.2023veryyyyy good keep doing this
Gasimoe
08.07.2023Very nice guide! Can I use Kivy instead of pygame if I want to make an mobile app out of my game?
Real Uniquee
08.07.2023It is good for people starting networking game
Onlne game for rock paper scissor
John Dorian
08.07.2023Anyone learning coding who gets triggered by having to throw away hours of work in order to redo it……….probably shouldn't be coding… it's a part of the experience.
WJJ
07.07.2023p.move() do not work for me 🙁
doggoluvr
07.07.2023note at 41:00 roughly I was getting "none" when I ran the code using python idle. but it was because with idle when you run code through the "run module" method it runs it though the shell that was used to open that code –
so if you run the network after the server then the server is shut down before the network runs.
to fix this open two idle shell windows and run the network in one, and server in the other.
Carter Levy
07.07.2023this is one of the best in depth tutorials I have seen in a long time!
Balaji Srinivasan
07.07.2023U are so good I got like 5 percent of you told and 3 percent I knew
Robot Vivo
07.07.2023bro in 01:02:04 …next error:
[WinError 10053]] Se ha anulado una conexión establecida por el software en su equipo host
[WinError 10053]] A connection established by the software on your host computer has been aborted
Sashannel
07.07.2023Does anyone know why I can't use str.split(",") ?
Thomas O'Neill
07.07.2023This is great. Does anyone know how to deploy this through google cloud or a similar platform?
钢强张
07.07.2023sorry,This code link returns a 404 error,Can you share the program again?thanks
akshat agrawal
07.07.2023I am getting "[WinError 10053] An established connection was aborted by the software in your host machine" while running the network.py file. Can anyone help me please?