Workflow
URL Snake
icon
Search documents
地址栏也能打游戏!程序员用不到400行代码,在浏览器地址栏复活《贪吃蛇》,网友惊叹:怎么想出这个点子的?
猿大侠· 2025-10-11 04:12
Core Idea - The article discusses a creative project called "URL Snake," where a developer has implemented the classic game Snake within the browser's address bar using less than 400 lines of JavaScript code, showcasing innovative programming techniques and the potential for creative expression in unconventional spaces [2][4][12]. Technical Implementation - The game operates in a 40x4 pixel grid, utilizing Unicode Braille characters to represent the game elements, allowing for a unique visual experience despite the limitations of the address bar [10][12]. - The developer, Demian Ferreiro, used a method that involves continuously updating the address bar content to create the illusion of movement, similar to ASCII animations in command-line interfaces [13][21]. - The game supports controls via arrow keys or WASD, and as the player consumes food, the snake grows longer and the game speed increases, adding to the challenge [10][12]. User Experience - Players may notice that the browser's history gets filled with multiple entries of "URL Snake" due to the frequent updates to the address bar, which can be cumbersome to manage [14][16]. - The limited height of the game (only four lines) makes gameplay particularly challenging, as players must react quickly to avoid collisions [17]. Creative Exploration - Ferreiro emphasizes that the project is more about creativity and challenge rather than practicality, aiming to draw attention to the often-overlooked address bar as a space for creative expression [18][21]. - The project reflects a hacker spirit and a desire to explore the boundaries of what can be achieved in programming, encouraging others to think outside conventional frameworks [18][21]. Community Engagement - The project is open-source, with the developer inviting feedback and contributions from the community on GitHub, fostering collaboration and further innovation [11][19].
不到 400 行代码!程序员在浏览器地址栏复刻贪吃蛇,网友惊叹:太牛了,怎么想出这个点子的?
程序员的那些事· 2025-10-09 08:50
Core Concept - The article discusses a creative project called "URL Snake," where a developer has implemented the classic game Snake within the browser's address bar using less than 400 lines of JavaScript code, showcasing innovative use of Unicode characters to create a playable game in a constrained environment [4][15][25]. Technical Implementation - The game operates on a 40x4 grid, utilizing Unicode Braille characters to represent the snake and food, with the game state updated through the browser's URL [17][18]. - The developer, Demian Ferreiro, utilized the `requestAnimationFrame` method to animate the game, allowing for smooth updates of the snake's position and the game state [17][18]. - The game mechanics include controlling the snake's movement using arrow keys or WASD, with the speed increasing as the snake grows longer [14][17]. User Experience - Players can experience a nostalgic gameplay reminiscent of DOS-era games, with a simple yet engaging interface that evokes memories of early gaming [14][25]. - The game has a limited visual space, which adds to the challenge as players must react quickly to avoid collisions [22][25]. Creative Exploration - The project serves as a creative experiment rather than a practical game, emphasizing the potential for innovation in unconventional environments [23][25]. - Ferreiro encourages community involvement for further improvements and bug fixes, highlighting the collaborative spirit of open-source development [24]. Community Reaction - The project has sparked interest and excitement within the developer community, with some expressing curiosity about the potential for more complex games to be developed in similar constrained environments [25].