Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to run pygame or pyglet in a browser?

Tags:

I have 3 game libraries installed on my PC: pyglet, pygame and Panda3D.

I would like to create a 2D game and make it a web browser game so i can put it on facebook.

I know that Panda3D has a web-browser-plugin. Panda3D is for 3D games mainly.

Therefore, I'm asking, is it possible to play a pyglet or pygame game in a browser? If not, what Python library do you recommend?

like image 987
Lynob Avatar asked Dec 09 '11 23:12

Lynob


People also ask

Is Pyglet better than pygame?

Ans:- Speed-wise, Pyglet is definitely faster than pygame and has better performance, and nowadays speed is always a concern when developing with a game.

What can pygame run on?

Pygame does not require setup tools with even ctypes to install. Truly portable. Supports Linux (pygame comes with most main stream linux distributions), Windows (95, 98, ME, 2000, XP, Vista, 64-bit Windows, etc), Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.

What is better than pygame?

Kivy, Blit, Godot, Electron, and Unity are the most popular alternatives and competitors to pygame.

Does pygame work with PyScript?

No, Pygame is not supported in PyScript at this time.


2 Answers

Neither pyglet nor pygame will run in a browser. I wouldn't really recommend using Python at all if you target is a web browser. JavaScript (with HTML5 Canvas), Flash, or Java applets are is better suited for that environment.

If you're dedicated to the idea of using Python, there are a number of projects that can compile Python into JavaScript. There are some mentioned on the Python wiki. Here are a few:

  • Skulpt
  • Pyjamas
  • Pyjaco

You'll need to write your own graphics and audio systems, though, since none of those projects can convert the native code needed by pyglet and pygame into JavaScript.

like image 146
Snowball Avatar answered Oct 01 '22 10:10

Snowball


It requires a bit of reprogramming, but i made a pygame library "port" to the browser/nodewebkit using Brython and GameJS. You can program using a version of pygame and python 3 in the browser. You can check it out at https://github.com/asherwunk/pygjs

like image 31
Asher Wolfstein Avatar answered Oct 01 '22 10:10

Asher Wolfstein