{"id":25990103,"url":"https://github.com/lipten/skulpt_pygame_zero","last_synced_at":"2025-03-05T13:32:57.422Z","repository":{"id":57362523,"uuid":"343372204","full_name":"lipten/skulpt_pygame_zero","owner":"lipten","description":"This module provides most of the functions of pygame-zero for skulpt","archived":false,"fork":false,"pushed_at":"2023-02-07T19:19:14.000Z","size":7463,"stargazers_count":23,"open_issues_count":6,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-14T22:05:24.907Z","etag":null,"topics":["pygame-zero"],"latest_commit_sha":null,"homepage":"","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/lipten.png","metadata":{"files":{"readme":"README-zh_CN.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}},"created_at":"2021-03-01T10:15:07.000Z","updated_at":"2024-06-26T07:16:25.000Z","dependencies_parsed_at":"2022-09-26T16:32:10.380Z","dependency_job_id":null,"html_url":"https://github.com/lipten/skulpt_pygame_zero","commit_stats":null,"previous_names":["lipten/skulpt-pygame-zero"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lipten%2Fskulpt_pygame_zero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lipten%2Fskulpt_pygame_zero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lipten%2Fskulpt_pygame_zero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lipten%2Fskulpt_pygame_zero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lipten","download_url":"https://codeload.github.com/lipten/skulpt_pygame_zero/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242035146,"owners_count":20061265,"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":["pygame-zero"],"created_at":"2025-03-05T13:32:26.123Z","updated_at":"2025-03-05T13:32:57.416Z","avatar_url":"https://github.com/lipten.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English](./README.md) | 简体中文\n\n# 基于skulpt的第三方模块: skulpt_pygame_zero\n\n## 简介\n\n这是一个基于skulpt实现在浏览器运行pygame-zero的模块，为skulpt拓展2d游戏的能力，底层运行基于PIXI.js实现。\n\n## 安装\n\nnpm 引入:\n\n```\nnpm install skulpt-pygame-zero\n```\n\n或者使用 cdn 引入:\n\n```\nhttps://cdn.jsdelivr.net/npm/skulpt-pygame-zero/dist/main.js\n```\n\n## 快速上手\n\n1. 导入模块\n\n```javascript\n// webpack\nimport 'skulpt-pygame-zero'\n\n// cdn\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/skulpt-pygame-zero/dist/main.js\"\u003e\u003c/script\u003e\n```\n\n2. 使用 `PyGameZero.usePyGameZero` 包裹skulpt的read钩子函数\n\n```javascript\nSk.configure({\n  .... other settings\n  // before\n  read: builtinRead,\n  // after \n  read: PyGameZero.usePyGameZero(builtinRead),\n  __future__: Sk.python3,\n});\n```\n\n3. 传入渲染容器\nhtml\n```html\n\u003cdiv id=\"stage\"\u003e\u003c/div\u003e\n```\n​\t javascript\n```javascript\nPyGameZero.setContainer(document.getElementById('stage'))\n```\n4. 最好在运行skulpt之前执行一次`PyGameZero.reset()`\n\n   ```javascript\n   // insert before running\n   PyGameZero.reset();\n   // running skulpt\n   Sk.misceval.asyncToPromise(function() {\n   \treturn Sk.importMainWithBody(\"\u003cstdin\u003e\", false, pythonCode, true);\n   });\n   ```\n\n复制项目中的 [test/simple.py](https://github.com/lipten/skulpt-pygame-zero/blob/master/test/simple.py) 代码可用于测试\n\n----\n\n\n### skulpt_pygame_zero与pythen的pygame-zero有哪些区别：\n\n1. 加载图片只能用外链资源\n\n   ```python\n   Actor('https://static.lipten.link/blogs/pig1.png')\n   ```\n\n2. 创建角色可以传入多个图片资源，然后通过frame属性控制使用第几张\n\n   ```python\n   pig = Actor(('https://static.lipten.link/blogs/pig1.png','https://static.lipten.link/blogs/pig2.png'))\n   \n   # then ute frame=2 to switch the second photo\n   pig.frame = 2\n   ```\n\n### 以下是未实现的Pygame-zero的api\n\n* images\n* music.fadeout\n* music.queue\n* Actor keyword argument: pos, topleft, topright, bottomleft, bottomright, midtop, midleft, midright, midbottom or center （Actor构造器不支持一些关键参数）\n* Anchor point （角色锚点）\n* Tone Generator （音调生成器）\n* WIDTH、HEIGHT （变量为只读，值为html容器的宽高）\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flipten%2Fskulpt_pygame_zero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flipten%2Fskulpt_pygame_zero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flipten%2Fskulpt_pygame_zero/lists"}