Snake (raylib classic)¶
Grid logic, score HUD, one of three raylib classics.
▶ Run in browserUpstream: https://github.com/raysan5/raylib-games/tree/master/classics/src
Tags: port tier-0
Snake (raylib classic): SimVX port¶
Faithful port of raylib-games/classics/src/snake.c.
Run¶
uv run python ported_games/raylib_classics/snake/simvx_port/main.py
Controls¶
Key |
Action |
|---|---|
Arrow keys / WASD |
Change direction |
P |
Pause / resume |
ENTER |
Restart after game over |
Web export¶
uv run simvx export web ported_games/raylib_classics/snake/simvx_port/main.py \
-o ported_games/raylib_classics/snake/simvx_port/web/index.html
Source¶
1#!/usr/bin/env python3
2# /// script
3# requires-python = ">=3.13"
4# dependencies = ["simvx-core", "simvx-graphics"]
5# ///
6"""Snake (raylib classic): Grid logic, score HUD, one of three raylib classics.
7
8# /// simvx
9# tags = ["port", "tier-0"]
10# upstream = "https://github.com/raysan5/raylib-games/tree/master/classics/src"
11# web = { width = 620, height = 480, responsive = true }
12# ///
13
14Run::
15
16 uv run python ported_games/raylib_classics/snake/simvx_port/main.py
17
18Web export::
19
20 uv run simvx export web ported_games/raylib_classics/snake/simvx_port/main.py \
21 -o ported_games/raylib_classics/snake/simvx_port/web/index.html
22"""
23
24import os
25import sys
26
27_HERE = os.path.abspath(os.path.dirname(__file__))
28if _HERE not in sys.path:
29 sys.path.insert(0, _HERE)
30
31from simvx.graphics import App # noqa: E402
32
33from nodes.snake_game import SnakeGame # noqa: E402
34
35WIDTH, HEIGHT = 620, 480
36
37
38def main():
39 App(title="Snake (raylib classic)", width=WIDTH, height=HEIGHT).run(SnakeGame())
40
41
42if __name__ == "__main__":
43 main()