I have these Python games created by pygame
that I want to put on my website but I can't find out how. I tried to use PHP
and to include it but it just showed the text of the .py
file. I was wondering if you know how I can add my python game to my website in a format that the people don't have to download it and they can just play right away.
Asked
Active
Viewed 1,606 times
0
-
1No, it's not easily possible - unless maybe someone has written something fiendishly clever. This is because pygame uses local I/O operations, such as gathering input and displaying graphics [with SDL] - and if it doesn't do that, it's not really utilizing pygame. Thus to make it work either "in" or "connected to" a browser requires some form of emulation or proxy layer in the browser. (Although, I've seen JavaScript run Linux, and there are some streaming games, so not much is "impossible".) – user2864740 May 12 '20 at 00:42
-
To get Python to even _run_ on a web-server, requires a server runs Python (giving it input from request and sending the output as the response, via some integration). Otherwise the server will just return the ".py" files _as static [text] content_, as being observed. This still won't solve the end-problem of it being a pygame application: see above. – user2864740 May 12 '20 at 00:47
-
is there a way I can make my pygame embendded so i can add it like that' – THE FLASH May 12 '20 at 01:00
-
Hmm, it does look like someone has made something fiendishly clever. Three different options are listed in https://gamedev.stackexchange.com/q/82448/139562 (The supported methods may differ; check out the related project documentation). – user2864740 May 12 '20 at 01:01
-
This [question](https://stackoverflow.com/questions/8452927/is-it-possible-to-run-pygame-or-pyglet-in-a-browser) might help you. – Gober May 12 '20 at 01:05
1 Answers
-1
What you are looking for is a server where you can deploy your Python app (django, flask, etc). A nice one is Heroku.

Paulo Pereira
- 9
- 2
-
-
Once you have a Heroku server, you can install any package you want. I suggested Heroku, but you can use any VPS you want. – Paulo Pereira May 13 '20 at 01:10