[Homebrew] My first game... yet another Snake!

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
[Homebrew] My first game... yet another Snake!
by on (#209381)
Hello folks,

After some time programming on the Atari VCS I decided to give it a go at programming for the device I spend my whole childhood on... the gameboy.

I looked around and I couldn't find any decent implementation of Snake (by decent I mean fast, nice grafix, with multiple levels, and fun).
For my own madness, I decided the snake had to be fully 60hz animated too.

Image

After what was roughly 1 week of hacking around + 1 week of fixing things, here is then my implementation of the classic Snake (or more close to a more recent Snake, say Snake 2 or something)

Also included in the package are the 2 python programs I used to parse grafix... ugly but useful!

In afterthought, I think I should have done some things otherwise... but the result is fun anyway.
Everything is done by myself, this includes the grafix and the little background music.

I hope you like it, and I would welcome suggestions and improvements (although I won't have a lot of time this week)
Re: [Homebrew] My first game... yet another Snake!
by on (#209391)
Congratulations! Well done, i love the fluid animation. :beer:


Some thoughts on possible changes:

-Maybe add a unique "egg in belly" tile for when it was swallowed right in a 90 degree turn?
-The music is a good start, but gets grating after a short while since the loop is so short.
-When the snake has gotten very long, if you die, it takes quite a while for the retry message to appear
-Maybe a countdown on eggs until next level rather than amount of eggs swallowed would be more informative + slightly nerve wracking. Especially with that delay between swallowing and being extended.
-Maybe introduce the "cherry" to vary gameplay. The exact mechanics are up to you, but it could disappear after some timer runs out or if you take the egg first. Normally, a cherry would grant points, but there are no points except a record on how long you got the snake. It could count towards that score/goal without elongating the snake? Sounds like a suitable reward for risking your life for a time-limited bonus.
-Maybe one of the action buttons could speed up the snake a bit? (use at own risk).
Re: [Homebrew] My first game... yet another Snake!
by on (#209395)
The nintendo logo scrolling off the bottom of the screen was a clever touch :)

When the snake goes off the top of the screen the last tail section glitches out. It looks like it's getting flipped before scrolling off. I also agree that the music is a bit harsh sounding.

Impressive for only a couple weeks of work!
Re: [Homebrew] My first game... yet another Snake!
by on (#209408)
Alyosha_TAS wrote:
The nintendo logo scrolling off the bottom of the screen was a clever touch :)

I first saw this in Wordtris.

Another approach, especially for a larger project intended for a cartridge, is to fade a couple lines of text onto the logo for a couple seconds while your game is setting various things up.
Attachment:
tmss_exploit.png
tmss_exploit.png [ 475 Bytes | Viewed 6830 times ]


I've done something similar with Genesis TMSS (source: Tweet).
Attachment:
md_tmss_exploit.jpg
md_tmss_exploit.jpg [ 50.26 KiB | Viewed 6830 times ]


In each case, the BIOS notice displays for a couple seconds, and then your notice displays for a couple seconds after that.
Re: [Homebrew] My first game... yet another Snake!
by on (#209419)
Thank you all for your feedback!


In no particular order:

Quote:
The nintendo logo scrolling off the bottom of the screen was a clever touch

--- Haha :D ... that was what I thought too. I did spend my whole childhood watching that far too slow logo fade away, so it was totally worth it! :twisted:


Quote:
When the snake goes off the top of the screen the last tail section glitches out. It looks like it's getting flipped before scrolling off.

--- Oups... I completly forgot to fix that one! Yes, I had noticed it earlier, and I know what's wrong, so I will have a look at it as soon as possible.


Quote:
Maybe add a unique "egg in belly" tile for when it was swallowed right in a 90 degree turn?

--- The lack of that is also a source of another little bug, in that the tail sprite glitches when digesting that kind of corner-eggs. I already had a look, but my collision code is messy and I need to rewrite it first


Quote:
The music gets grating after a short while since the loop is so short.

--- So true... I wish I was better with sounds but I'm not a real chiptune artist. But I will work on it. Only disabling/enabling one of the channels already does magic!


Quote:
Maybe a countdown on eggs until next level rather than amount of eggs swallowed would be more informative + slightly nerve wracking. Especially with that delay between swallowing and being extended.

--- The HUD might not be clear enough. Left is the number of eggs swallowed (actually the number of eggs digested, but that will change very soon). In the middle is the timer, not used yet, and in the right is the highscore for the current level (in eggs swallowed). By the way, have you tried pressing A/B/Select/Start on retry to switch levels? :roll:


Quote:
Maybe one of the action buttons could speed up the snake a bit?

--- I even thought about speeding up the game after some time, to put more stress on the player to get their eggs early. For those to work, I have to craft an variable timer, which is easy enough (just take the high nibble instead of the low nibble as a time index) but I didn't yet find time to implement it


Quote:
Maybe introduce the "cherry" to vary gameplay.

--- I love that idea! But pfft... first some more bugs/features to fix!


Quote:
When the snake has gotten very long, if you die, it takes quite a while for the retry message to appear

--- You have been playing too long... get a pause! :D Well, I will speed it up a bit as soon as I have the function for...
Re: [Homebrew] My first game... yet another Snake!
by on (#209507)
Version 0.2A!

Fantastic how adding a little countdown quickening-up the game can work on peoples nerves! :twisted:
Now find the time to add 90 degrees egg in belly, better music, and maybe some cherries and we're good to go! :D
Re: [Homebrew] My first game... yet another Snake!
by on (#209693)
Didn't have much time this week, but here is a version 0.2B...

What have changed:
- Fixed the tail cornering bug
- Added 90 degrees egg-in-belly grafix
- Improved a little the music :?

:D Please keep on sending feedback :D
:beer: ... and if you like it, why not share it? :beer:
Re: [Homebrew] My first game... yet another Snake!
by on (#209695)
much more fun to play now with the softer toned music.

I think it could us some more animations though, like one for eating the egg, or the snakes belly segments expeanding as he swallows it.
Re: [Homebrew] My first game... yet another Snake!
by on (#209743)
I gonna have a look... but it is not easy. The head and tails are (for technical reasons) movable shapes, and I'm a bit short of OAM shapes!

Image

However, running my shape deduplicator on it, with detection of mirror and flip, shows that 36 of the 256 shapes are (indirectly) duplicates...

Image

So as soon as I have those deduplicated, I can start to add more animation...
To be more specific, I can add 1 animation sequence for 4 directions (32 shapes i.e. 8 steps * 4 directions), and then I keep 4 movable shapes for things like cherries, baskets, ect...

So what do you prefer? An sequence where the snake's head opens its mouth to eat an egg? Or maybe something else?
Re: [Homebrew] My first game... yet another Snake!
by on (#209830)
Small update! (version 0.2C, I think)

I added an bonus called The Basket. It appears somewhere between difficulty level 4 and 7, and if you tumble it, it will make eggs scatter the screen. :mrgreen: Of course, only one is the real egg, but the others are delicious too! :P

I worked on the extra animations, I even found space to squeeze in both head eating and segment expanding frames, but they are not finished yet. That will be for a next update!
Re: [Homebrew] My first game... yet another Snake!
by on (#210400)
New version...

Not much did change, but I added a cherry, which gives 5 points.
Also, I did put in the animations. As it turned out, the game goes too fast for them to be any good :shock:
(specially on my ultra-blurry gbpocket :lol: ), but the one with the eating head also appears when you eat yourself, and is just too much fun to not use :D .

I won't have a lot of time after this week to code, so please send in your last suggestions before it is too late. :beer:
I have an idea for a next gameboy game, but that will be for after the holidays...

By the way, what website do you recommend to publish this game on? I don't know anything about that kind of jobs... :(
Re: [Homebrew] My first game... yet another Snake!
by on (#210411)
itch.io is good for building a portfolio.
Re: [Homebrew] My first game... yet another Snake!
by on (#210413)
Yvar de Goffau wrote:
New version...

Not much did change, but I added a cherry, which gives 5 points.
Also, I did put in the animations. As it turned out, the game goes too fast for them to be any good :shock:
(specially on my ultra-blurry gbpocket :lol: ), but the one with the eating head also appears when you eat yourself, and is just too much fun to not use :D .

I won't have a lot of time after this week to code, so please send in your last suggestions before it is too late. :beer:
I have an idea for a next gameboy game, but that will be for after the holidays...

By the way, what website do you recommend to publish this game on? I don't know anything about that kind of jobs... :(


I noticed a glitch in my emulator's audio code due to this game, so thanks for that!

my only point of criticism is that the eggs appearing over the snake after they are eaten looks a bit sloppy. Other then that pretty cool. :D
Re: [Homebrew] My first game... yet another Snake!
by on (#210882)
Pretty cool, although the sound could use a bit of work. It sounds really basic to me.

On that note, here's a test to see if I could get DevSound (my own Game Boy music system) to work in your game. I mostly succeeded, although there are a few issues. First of all, DevSound expects to have full control over the sound chip, so it ends up corrupting the sound effects. Secondly, the music no longer increases in speed when the game does. Deliberately slowing down the call rate for music playback (which is what your sound code did) is not sufficient as DevSound needs to be called on every frame in order for the music to sound correct. Finally, the music constantly pauses. I tried to fix the latter issue, but I wasn't able to due to not wanting to spend too much time.

By the way, I noticed that you're following your halts with nops. This isn't necessary; the assembler will automatically insert a nop after each halt opcode.
Re: [Homebrew] My first game... yet another Snake!
by on (#210901)
Nice tune!
I first thought a simple game wouldn't be very demanding on the matter of sound, but indeed that is pretty cool :beer: .

To make the sound effects work, one simple solution would be to simply disable channel 4 in the music engine since all sound effects are made to work with channel 4. The sound effects are very plain ones, with no real code behind, but I don't know how the SFX works in your music engine. I will try to set up 1 unified sound effect trigger routine once I get home, that would make things a bit easier.

For the speedup, [v_speed] contains the current speed of the game; if I would know where the current song speed is stored I would be able to just modify that... or how does DevSound store the rythm speed of the tune? Can you invoque for example [$89 - SetSpeed] from within the game code?

By the way, is it an idea to make 8 different tunes for the 8 maps :D ? I have no real talent for music so I didn't get past 1 boring old loop... :roll:


(edit) By the way, why did you remove the halt in the waitKey routine? Did that cause problems with the music engine? If it is the emulator that hangs (which happened to one of my emulators) than you can use the waitKeyOld routine...
Re: [Homebrew] My first game... yet another Snake!
by on (#211344)
Sorry for the late reply, I don't check this place often.

Right now, DevSound doesn't support SFX on its own. However, it is designed to integrate with FX Hammer, a sound effect system that was originally created as a companion to Carillon Editor. When using raw register writes for SFX (which IIRC is what you are doing) it's very difficult to tell exactly when a sound effect stops playing so the relevant music channel(s) can kick back in. Disabling CH4 in DevSound is kinda not an option for me because I like to be able to use all 4 sound channels :P

Quote:
Can you invoque for example [$89 - SetSpeed] from within the game code?

Right now no (unless you like writing directly to DevSound's RAM), but that's an excellent idea! I'll get to work on a sort of "external command" system for that purpose. Not sure what else the external command system would be used for, but I'm sure I'll think of something.

Also, an idea for your SFX trigger system: Each SFX should have its own "length" value, that way a music engine (such as DevSound) will know exactly when the SFX stops so the music channels can kick back in.

As for removing the halt in waitKey, I was trying to get it so that music could play during a waitKey, but I couldn't get it to work. I probably forgot to put the halt back in.

Quote:
By the way, is it an idea to make 8 different tunes for the 8 maps :D ?

For the sake of variety, I'd say yes. I'd also recommend having different background graphics for each level if possible to add to the variety.

EDIT: I have the external command system working now.
Re: [Homebrew] My first game... yet another Snake!
by on (#211375)
I have some questions on DevSound.

- how do you compose? Is there a converter for Deflemask, for example?
- what is the license for FX hammer? The demo says "free for non-commercial use", and there is no other info in the files
Re: [Homebrew] My first game... yet another Snake!
by on (#211389)
To be honest, I should probably create a proper thread for DevSound here. Don't want to derail this one...

1. There is a WIP Deflemask converter, however the output will require some manual tweaking. I have attached the converter (which isn't mine BTW) if you're interested. (Requires Python 3 BTW)
2. Aleksi Eeben (the creator of FX Hammer) has gone on record to say that anyone is free to use FX Hammer as they see fit. You'd have to ask him if you plan on selling a game using it, though. The best way to contact him seems to be through Twitter (@aleksieeben).

EDIT: ...forgot to actually attach it -___-

EDIT 2: Any further DevSound discussion should go in this thread.
Re: [Homebrew] My first game... yet another Snake!
by on (#211743)
Indeed, I need to work on a simple centralized [s_playFX] function, which will trigger the playback of any sound effect in the game (not too difficult, since all that changes is the "frequency" of the noise register). I could store the lengths quite easily for DevSound, but I don't know where.

My knowledge of sound engines goes no futher than Something that Triggers the Right Note at the Right Time... :lol: why it would need to be update each frame goes beyond me but that doesn't matter :D

But it would be easier to use an existing SFX engine together with DevSound or another sound engine. I couldn't find anything about how to make FXHammer work or how to create new SFX for it. The disassembly I found somewhere is no help either for me noob in sound code :?

Can someone help me with it? I don't have much time for it now that real life has caught me up :roll:
Re: [Homebrew] My first game... yet another Snake!
by on (#211808)
FX Hammer has an official editor. I attached it for convenience.

That disassembly of FX Hammer you found is mine btw :mrgreen:
Re: [Homebrew] My first game... yet another Snake!
by on (#211885)
By hijacking DevSounds timer that normally makes the notes trigger, :twisted: I was able to accelerate the notes in line with the game (as well as keeping it in sync with the animations; something impossible with the classic song speeds). Until there would be a seperate TriggerSongNotes routine, this does the job.

I tried to make FXHammer work, but I discovered it was so much easier to just disable in DevSound the writing of the CH4's registers during that short period in which the SFX plays. This way, I could just keep the old sounds. 8-)

Now it is just waiting for some mad geniuses of an chip artists to compose the best snake theme-song in the world, and to make 8 variations of it for the 8 maps, and a 9th one for the title screen :wink: . Unfortunatly, my talent lies not as an composer....