GDevelop games can be executed in browsers and I just love that stuff. It makes them just so accessible for other people.
Now imagine I want to create not just one game but several and put them on my website. For users to easily find the games I then would create some index HTML page with links to the games and the user can start them.
Let’s say after some time the user wants to change the game and thus come back to the overview page. How would I from within the game create an Action that tells the browser to go back to the index HTML page?
And now imagine I allow all the navigation via gamepads. Then going back to the index page would be ok but after that the user were forced to use mouse/keyboard/touch to activate the next game. So how about instead of creating an index page, I would create another game that just allows the player to run the game he wants to play.
For both use cases all I need is some action that allows me to point the browser to some other page…
Make the first scene of your project be that main menu (index page), and each game be one or several scenes.
This is what I did with my first project.
There’s also a “open URL” action, if you prefer.
Putting all games into one project is not what I like. I prefer independent projects that can be assembled dynamically.
But the ‘open URL’ action seems what I need. How do I use that?
Ok, it took me some time to figure out that there is an action in “Files” that is called “Open a URL or a file”. It is commented as “This action launches the specified file or URL, in a browser (or in a new tab if the game is using the Web platform and is launched inside a browser”.
I tested it briefly and I saw the described action happening. But as I mentioned above, I’d like to move the existing browser window to the new game, not open a new tab. But it was close!
In that case, I guess you will need to handle things outside of GDevelop, on the website side.
see Using the Gamepad API - Web APIs | MDN
- I have the power to program my own if statements
So I use a sequence of two events now to exit my game:
<if gamepad back button is pressed> (replace with other conditions if you prefer)
Quit the game
I will use this pattern to exit my games and return to a menu.
Ultimately that should allow me to install a Raspberry to load X, a web browser in fullscreen with start page being the menu game, and it should be a decent game console that can be extended as I go…