{"id":16385934,"url":"https://github.com/aaaaash/2048-game","last_synced_at":"2026-06-17T12:32:38.132Z","repository":{"id":100794972,"uuid":"61258485","full_name":"Aaaaash/2048-game","owner":"Aaaaash","description":"2048小游戏","archived":false,"fork":false,"pushed_at":"2016-06-17T01:48:23.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-12T12:31:57.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Aaaaash.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-16T03:14:37.000Z","updated_at":"2016-07-22T22:47:02.000Z","dependencies_parsed_at":"2023-06-10T01:03:19.061Z","dependency_job_id":null,"html_url":"https://github.com/Aaaaash/2048-game","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aaaaash/2048-game","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aaaaash%2F2048-game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aaaaash%2F2048-game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aaaaash%2F2048-game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aaaaash%2F2048-game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aaaaash","download_url":"https://codeload.github.com/Aaaaash/2048-game/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aaaaash%2F2048-game/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34449277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T04:15:43.605Z","updated_at":"2026-06-17T12:32:38.114Z","avatar_url":"https://github.com/Aaaaash.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 2048-game\n2048小游戏\u003cbr/\u003e\n\u003ca href=\"https://sakub.github.io/2048-game/\"\u003e在线体验\u003c/a\u003e\u003cbr/\u003e\n#游戏整体思路\n1.js动态生成4X4的方格\u003cbr/\u003e\n2.board数组映射界面中的每一个方格\u003cbr/\u003e\n3.游戏所有的操作底层是对board数组进行操作，之后根据board的数据变化再随时更新为游戏画面\u003cbr/\u003e\n4.游戏一开始随机生成两个格子并且值为2或者4,利用JavaScript的Math.random()方法\u003cbr/\u003e\n5.PC端监控键盘事件，根据keyCode（37,38,39,40）分别响应↑↓←→箭头的事件\u003cbr/\u003e\n6.分别定义是否可以在某个方向移动的函数，判断返回值为true或false进行移动（或相同数合并）\u003cbr/\u003e\n7.数字移动或合并后再次随机生成一个方格以及一个随机数\u003cbr/\u003e\n8.每次移动或合并且生成一个随机新方格后判断游戏是否可以结束（分别判断board数组是否还有为0的数，以及是否还有可以合并的数）\u003cbr/\u003e\n9.移动端适配，由于方格为动态生成，所以使用js实现响应式设计，应用不同的设备分辨率采用不同的界面以及方格尺寸\u003cbr/\u003e\n10.移动端触摸滑动事件，判断touchstart以及touchend事件，根据定方向滑动距离来判断为X轴滑动还是Y轴滑动，再根据触摸终点与起始点的差值来判断分别为X轴左右或Y轴上下方向\u003cbr/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaaaash%2F2048-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaaaash%2F2048-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaaaash%2F2048-game/lists"}