Skip to content

Add an external tutorial link of a complete game to wiki#262

Merged
Frosty-J merged 2 commits intolibgdx:devfrom
rimmontrieu:patch-1
Mar 3, 2026
Merged

Add an external tutorial link of a complete game to wiki#262
Frosty-J merged 2 commits intolibgdx:devfrom
rimmontrieu:patch-1

Conversation

@rimmontrieu
Copy link
Copy Markdown
Contributor

Add a complete tutorial series for creating an 8-bit snake game from scratch

rimmontrieu and others added 2 commits March 3, 2026 10:31
Add a complete tutorial series for creating an 8-bit snake game from scratch
@rimmontrieu
Copy link
Copy Markdown
Contributor Author

Thanks, looks good to me!

@Frosty-J
Copy link
Copy Markdown
Collaborator

Frosty-J commented Mar 3, 2026

This seems like a pretty good tutorial. My only concerns from a quick read-through (some of which may have already been addressed - I see links to each part that weren't there when I started writing this) are:

  • filterMag: MipMapLinearLinear in part 1 isn't valid. OpenGL permits mipmaps for min only (not that I think generating them for pixel art makes a great deal of sense either). Presumably you meant for this to be Nearest.
  • keyDown() in part 4 isn't used to its full potential. Instead of swallowing all inputs, you can return true when a switch-case is matched and false if it reaches end of method.
  • }; in part 5 is a redundant semicolon.
  • disIntegrate() in part 6 reads as "dis integrate". The use of Timer doesn't handle the case of the game being suspended very well (e.g. web build when user is in a different tab) but it doesn't look like this game clamps delta time anyway and I respect doing it a more robust way could be out of scope.
  • Sound IDs in part 6 are unused and most of the time sounds in libGDX are treated as fire-and-forget anyway.

Furthermore:

  • The embedded examples are difficult to play with arrow keys, as Gdx.input.setCatchKey() hasn't been used. The mouse cursor used is very large and clicking to activate the iframes would be nicer than having to refresh the page. Why not use the Home screen built in part 1 for this?
  • Navigating nested ZIPs in the download is a bit difficult. If you want a quick way to remove build directories and junk like .DS_Store from it (anything defined in .gitignore), I find pushing to GitHub then downloading as ZIP works a treat.
  • There is a serious bug where the snake sometimes decides to die. In the web build, I found this easiest to replicate by pressing up and right simultaneously when the snake is moving left. For desktop builds, you can set configuration.setForegroundFPS(25) or any other low frame rate for the snake to die immediately, or disable vsync with no FPS cap for it to die upon touching a food pellet.

Miscellaneous code review:

  • Use of magic numbers like snake.setDirection(1) should be avoided.
  • Doing new Color(0x1f1f1fff) instead of Color.valueOf("#1F1F1F") would avoid parsing a string. Makes no difference when you only have two colours, of course, and the latter is probably less error-prone to be fair.
  • Dangling JavaDoc in SoundHelper. You'd need to move the @author annotation inside the SoundHelper doc for it to be picked up. The one in Constants doesn't do anything either.
  • Package use isn't all that intuitive. I wouldn't consider the world to be an entity. screens package makes complete sense, though - definitely keep that one.
  • As much as the Home screen doesn't like to be resized, I like the use of Scene2D actions in it. The best part about Scene2D, actions are.
  • I don't know about Eclipse but I think it's worth acknowledging in this discussion the fact the downloaded code has quite a few warnings in IntelliJ IDEA. It's mostly "field may be 'final'", nothing I really care about.

GDX Bootstrap seems pretty good and is close to what I wanted rather than sending people away to fiddle with gdx-liftoff. Obviously it's missing some simple settings like platforms (e.g. Android) and uses a somewhat outdated version of libGDX, but that's perfectly fine for tutorial purposes.

I am going to merge this because it's a lot more up-to-date than the other tutorials, and the gamedevelopment.blog which was previously at the top has a ghastly mixture of dark and light styling with a serif font. I love Snake.

@Frosty-J Frosty-J merged commit 7bdb63b into libgdx:dev Mar 3, 2026
@rimmontrieu
Copy link
Copy Markdown
Contributor Author

Thanks for a thorough review @Frosty-J. I wouldn't expect it to be this comprehensive and crystal clear. I'll fix all that and update the tutorial today.

@rimmontrieu rimmontrieu deleted the patch-1 branch March 5, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants