Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

How can I put my python game into the HTML5 form?

A topic by Blue Pheonix created Mar 18, 2023 Views: 1,095 Replies: 4
Viewing posts 1 to 2
(+1)

I'm making a game in python but I lack some experience in programming. The game works, so now I want to start publishing it on itch.io as HTML5. However, I don't know how to convert it into the appropriate form.

I've seen a guide page by itch.io that says that I need to upload a ZIP file if I'm making a HTML5 game with numerous files. However, it also says I need an index.html file for paths. I don't know how to do that and how it works.

Note: My game uses a few modules that I'll like to implement too.

(+1)

By default, a python game (.py) cannot be run as an HTML game.

What you should do is use the "pygbag" package to export your game to HTML format (I don't remember if it is mandatory to also use pygame).

If you've never used pygbag before, it's best to look up tutorials, since you need the main function to be asynchronous.

I did try pygbag, It only resulted to getting black screens and getting errors , I did check the debug page of the pygbag export but it didn't really help. 

You will have some error in the code.
I have used pygbag for a JAM and it worked without any problem.

You must program thinking about pygbag, a normal game of pygame won't work if you don't adapt it to pygbag.

(+2)

I did fix it after all by getting help from the pygame community discord, The main issue was that the sound clips weren't in .ogg format, and that I forgot to add await asyncio.sleep(0) after every While True function.

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.