Ash47.net

Ash47.net

BlogGamesProjectsAbout

Snake Game

What I did

Today I made a snake game in Godot.

I created the game, and then generated a HTML page which contains a web assembly version of the game. I added a page and embedded the game in it. Pretty dope.

A bit of history.

I've been making games all my life, I have lost the majority of my work, or simply not published it. I want to start publishing the games I make, starting with this very simple game, here, for free on my website.

I normally work with the Unity engine, the majority of the games I've modded when working on AzzaMods were made with Unity. I'm very familiar with the engine.

I've used a range of different engines in the past. I spent a lot of time using Game Maker when I was growing up.

Why not Unity?

Traditionally I've used Unity, but I've been a little worried about the future of the engine. Their license agreement issues, and having to pay a ton of money ($2,040.00 USD / year at the time of writing) to simply remove the Unity splash screen don't fill me with confidence. The install fees and other tracking stuff in Unity is also a bit of a turn off.

Why not Game Maker?

There's an amazing tool I love called the UndertaleModTool. It lets you take a game made in GameMaker and decompile it, getting back source code that can be edited. That's amazing, but I have a long term goal of making a multiplayer game, and the ability to decompile that easily will make it very easy for people to cheat. I don't want to make a game that can be easily cheated.

I'm also not a fan of the cost of GameMaker, or the closed source nature.

What else did I try?

I had my heart set on learning Rust and needed a project, so I decided to try and make a game using Rust. I read around half of the Rust Book and was really enjoying it. I think the language is great. I installed a game engine called Bevy.

Bevy

Bevy is a game engine that lets you make games with Rust.

It uses something called ECS, which stands for Entity Component System. It's a way of seperating out the data from the logic in your game. It took me a bit to wrap my head around it, but it seemed decent.

I spent a few days playing around in Bevy, but it took a long time to really do anything. I know there's always going to be a learning curve but this felt insane. One of the problems I faced was that the APIs were unstable and always changing -- Google something or ask ChatGPT, and it will be wrong. I like to Google for help, or use ChatGPT to help me along to learn something fast, but it was impossible with Bevy.

I started to reach a point where it felt like I was pulling teeth to get anything done. I decided to try something else -- Fyrox.

Fyrox

I don't have a lot to say about Fyrox, I installed and played with some of the samples. I was more impressed with Fyrox than Bevy because it came with an actual Editor, similar to Unity.

I started to wonder why Fyrox? Why even bother? It feels like I am trying to screw in a screw using a hammer. That's kind of where it struck me -- I should try out Godot. During the Unity licensing issues period, lots of people were talking about Godot. There is a new language to learn which would appeal to that side of me, and it felt similar enough to Unity that I would be able to pick it up fast.

Godot

I installed Godot, got to work, and was able to create and publish a basic version of Snake in around 4 hours of work.

For reference, I spent more than that just trying to get a sprite to render to the screen and move around with keyboard inputs using Bevy.

There was still a learning curve here, sure, but damn that was fast.

Publishing Pains

I actually had a lot of trouble publishing it to this website. This website is hosted via GitHub Pages. Godot doesn't support being run on GitHub pages due to needing specific headers that GitHub Pages doesn't support.

My game showed an error upon loading. I've currently partially fixed the error, will fix it better in the future.

Error The following features required to run Godot projects on the Web are missing: Cross Origin Isolation - Check web server configuration (send correct headers) SharedArrayBuffer - Check web server configuration (send correct headers)

Some googling led me to a solution -- coi-serviceworker -- This uses a service worker to add the required COOP and COEP headers -- magic.

Simply download the .js file, include it in your project, and then add a script tag to any pages that need it.

Right now, it seems to fail the first time you open a page, but if you refresh, it seems to work after that. It's something I'd like to investigate but not that important right now.

Conclusion

It was a bit of a journey, but I'm happy with the result. I'm going to continue to learn Godot and see where it takes me.

Copyright © www.Ash47.net 2024.