◀ VibeCruiser

basketball snake

A free snake game — play it in your browser, no install. A basketball-themed snake game built with vanilla HTML, CSS and JavaScript.

by @isxiaoxu · isxiaoxu/basketball-snake on GitHubLANG JavaScriptHOSTED ON ISXIAOXU.GITHUB.IOUPDATED 26 Nov 2026

Made this, @isxiaoxu? See how many people played it → or use email

Controls: Space · Mouse

▶ Play full screen ▲ Vote: free account with email ▲ Or sign in with GitHub

GitHub may ask you to sign in, then to let VibeCruiser “Verify your GitHub identity” and “Act on your behalf”. We only read your profile and email, and never post anything.

Open the live demo Source on GitHub

From the README

一个不用安装、打开浏览器就能玩的贪吃蛇小游戏,使用原生 HTML、CSS、JavaScript 编写,没有第三方依赖。

CSS 变量和响应式布局 style.css 开头的 :root 定义了颜色变量,修改那里就能换主题。 页面用 Flexbox、Grid 和媒体查询适配手机屏幕。

Canvas 绘图 game.js 使用 绘制球场、蛇、篮球和粒子效果。 这适合需要频繁刷新画面的游戏和动画。

游戏循环 通过 requestAnimationFrame 不断地“更新状态 → 重新绘制”。 蛇按固定时间间隔移动,而不是每一帧都移动。

状态机 游戏有 ready、running、paused、over、won 五种状态, 不同状态决定按键行为、遮罩层内容和暂停按钮是否可用。

碰撞检测 每次移动时检查新蛇头是否撞墙、是否碰到自己的身体,以及是否吃到篮球。

本地存储 最高分通过 localStorage 保存在浏览器里,刷新页面也不会丢失。 它只存在当前电脑的浏览器中,不会上传到服务器。

触摸和键盘输入 电脑上可以使用方向键 / WASD;手机上可以滑动棋盘,或使用屏幕方向键。

改颜色:编辑 style.css 里的 :root 变量。 改篮球数量、增加障碍物:从 spawnFood() 和 stepGame() 两处逻辑入手。

Read the full README on GitHub →

Built something like this? Submit your vibe — free account, takes a minute. How listing works.

More like this

More snake games →

Made this?

Claim it: create a free account, then press CLAIM THIS in the cruiser. Put the badge below in your README or on your demo page first; that link is how we know it's yours.

Your project is on the cruise, loaded live from your own site. Put the badge in your README or on the demo page: it shows your live play count, it links back to this page, and everyone who lands here is one click from running the real thing.

On VibeCruiser

How listing, the badge and claiming work →