{"id":13487232,"url":"https://github.com/liyupi/yulegeyu","last_synced_at":"2025-05-15T16:03:28.798Z","repository":{"id":59603859,"uuid":"537406874","full_name":"liyupi/yulegeyu","owner":"liyupi","description":"羊了个羊纯前端实现版【鱼了个鱼】，自定义关卡+图案+无限道具，可在线玩：https://yulegeyu.cn","archived":false,"fork":false,"pushed_at":"2023-05-21T12:04:08.000Z","size":548,"stargazers_count":1780,"open_issues_count":41,"forks_count":566,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-08T00:34:28.304Z","etag":null,"topics":["ant-design","frontend","h5","javascript","typescript","vite","vue"],"latest_commit_sha":null,"homepage":"http://yulegeyu.yupi.icu","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liyupi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-16T10:18:36.000Z","updated_at":"2025-04-05T07:00:42.000Z","dependencies_parsed_at":"2024-01-16T09:01:19.601Z","dependency_job_id":"940787d7-c591-4e61-a9e3-fa51c1d312cd","html_url":"https://github.com/liyupi/yulegeyu","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyupi%2Fyulegeyu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyupi%2Fyulegeyu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyupi%2Fyulegeyu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyupi%2Fyulegeyu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyupi","download_url":"https://codeload.github.com/liyupi/yulegeyu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374401,"owners_count":22060609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ant-design","frontend","h5","javascript","typescript","vite","vue"],"created_at":"2024-07-31T18:00:56.901Z","updated_at":"2025-05-15T16:03:28.772Z","avatar_url":"https://github.com/liyupi.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","置顶"],"sub_categories":["08、家庭与物联网"],"readme":"# 鱼了个鱼\n\n\u003e 被羊了个羊虐了百遍后，我自己做了一个！\n\n在线体验：http://yulegeyu.yupi.icu\n\n游戏视频：https://www.bilibili.com/video/BV1Pe411M7wh\n\n相关文章：https://mp.weixin.qq.com/s/D_I1Tq-ofhKhlp0rkOpaLA\n\n游戏截图（自定义了图案）：\n\n![游戏截图](doc/img.png)\n\n游戏特色：\n\n1. 支持选择难度（4 种）\n2. 支持自定义难度\n3. 支持自定义动物图案（比如 🐔🏀）\n4. 可以无限使用技能（道具）\n5. 不需要看广告\n6. 能通关\n\n\u003e 补一句：就出于兴趣做了几个小时，有 bug 正常哈哈，欢迎 PR~\n\n简单说下实现原理，主要有 4 个点：\n\n1. 游戏全局参数：做游戏的同学都知道，游戏中会涉及很多参数，比如槽位数量、层数等等。我们要将这些参数抽取成统一的全局变量，供其他变量使用。从而做到修改一处，游戏自动适配。还可以提供页面来让用户自定义这些参数，提高游戏的可玩性。\n2. 网格：为了让块的分布相对规整、并且为计算坐标提供方便，我将整个游戏画布分为 24 x 24 的虚拟网格，类似一个棋盘。一个块占用 3 x 3 的格子。\n3. 随机生成块：包括随机生成方块的图案和坐标。首先我根据全局参数计算出了总块数，然后用 shuffle 函数打乱存储所有动物图案的数组，再依次将数组中的图案填充到方块中。生成坐标的原理是随机选取坐标范围内的点，坐标范围可以随着层级的增加而递减，即生成的图案越来越挤，达到难度逐层加大的效果。\n4. 块的覆盖关系：怎么做到点击上层的块后，才能点下层的块呢？首先要给每个块指定一个层级属性。然后有两种思路，第 1 种是先逐层生成，然后每个格子里层级最高的块依次判断其周围格子有没有块层级大于它；第 2 种是在随机生成块的时候就给相互重叠的块绑定层级关系（即谁覆盖了我？我覆盖了谁？）。这里我选择了第 2 种方法，感觉效率会高一些。\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyupi%2Fyulegeyu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyupi%2Fyulegeyu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyupi%2Fyulegeyu/lists"}