Odin + Raylib: Snake game from start to finish

Опубликовано: 21 Март 2026
на канале: Karl Zylinski
11,756
397

Beginner friendly tutorial on creating a Snake game using Odinlang + Raylib.

The graphics and sound files you need: https://zylinski.se/snake-tutorial/sn...
Odin Programming Language compiler setup:    • Setup Odinlang compiler from source on Win...  
Sublime Text + Odin environment setup, including code completion:    • Sublime Text + Odin + Code completion  
Introduction to Odin article: https://zylinski.se/posts/introductio...
Final code at end of tutorial: https://github.com/karl-zylinski/snak...

I've written a book about Odin: https://odinbook.com/ ✨

Support me 😻
Patreon:   / karl_zylinski  
Buy my game CAT & ONION on Steam: https://store.steampowered.com/app/27... (made using Odin and Raylib!)
Ko-fi (single time donations): https://ko-fi.com/karl_zylinski

Things you can try to improve the game:
Make snake wrap around instead of crash into wall [medium]
Add highscore counter: A separate score counter that doesn't reset when you get 'game over' [easy]
Currently you can crash into yourself by trying to go 'the other way', i.e. if you press left while going right you'll crash. Try to fix this! [easy]
Make the snake move smoothly: You can still be on grid but move each part smoothly to the next cell. Might be tricky to make 'feel good'. [hard]
Add controller support: see rl.IsGamepadButtonPressed [easy]
Add music: see rl.PlayMusicStream and rl.UpdateMusicStream [medium]
Add screen shake when you crash and eat food: you can use target on rl.Camera2D. You'll probably need a timer to track for how long the shake should happen [medium]

Let me know how it went in the comments or on my Discord server:   / discord  

Chapters:
00:00:00 Intro
00:01:17 Setup Sublime project
00:02:19 Open a window
00:08:17 Draw snake head on a grid
00:14:43 Zoom using camera
00:18:34 Make head move
00:23:28 Input
00:25:10 Multiple body parts
00:35:16 "Game over" on hit wall
00:42:15 Food that grows snake
00:57:45 "Game over" on hit self
00:58:48 Snake and food graphics
01:19:29 Score counter
01:24:17 Sound
01:27:00 The end + ideas for improvements
01:27:48 Patreon supporter shoutouts