5

I'm trying to create a website for a university project where you can play some minigames I've programmed with Pygame (Python). How can I make the games executable online (like flashgames)? I'm using php

3
  • 3
    Hi! Welcome to StackOverflow! I would suggest you to be more specific in what you need, and also to post whatever attempt you have for what you are trying to achieve. See also How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example. Commented Oct 1, 2018 at 10:13
  • You can’t. There is (unfortunately) no way to run Python with pygame as a web application. Commented Oct 2, 2018 at 22:14
  • I'm also finding a way to realize it, but I only find a good way by web socket.But I think it's will make a delay problem. Skuplt maybe a good way to realize by js. I'm looking for another way. Commented Apr 1, 2019 at 3:05

3 Answers 3

0

PYGAME ON WEB(Pygbag)

Now you can run pygame in browser using the pygbag,for more details you can checkout :

For more information you can checkout

  • The pygame-ce discord.(pygame-community discord)
Sign up to request clarification or add additional context in comments.

Comments

-1

If you're not fully committed to pygame, you could investigate the pyjsdl project which is modelled on pygame. You'd still have to translate your code.

Another alternative is to create stand-alone executable of your existing pygame projects using pyinstaller and distribute those.

Kivy can generate HTML5 apps, e.g. here's a tutorial on creating pong. It's not really directed at games.

Or you could consider redeveloping using a web game library in a different language (probably javascript).

4 Comments

do you know which one of the above methods is better for collecting user data?
@jigz it depends on what sort of data you want to gather, the users click-speed, their browser footprint? I think you'd be better off with a framework designed for web.
I just need to record their input. For instance, consider their are playing a grid-world game with keyboard (i.e., changing the state of their agent). I want to save the game data so I can replay later. Does this make sense?
If you're already handling events @jigz, then you can extend the existing handler to log the actions for replay etc.
-1

I have tried several options.

  1. Trinket.io didn't work well to me since it is cropping the game screen.
  2. itch.io requires a downloadable file which I didn't have
  3. I tried to use http://www.skulpt.org/, but it didn't even open.
  4. So I ended up using replit.com, since this was the only site that didn't crop the game and could host pygame app in browser

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.