{"id":16186950,"url":"https://github.com/robloach/wasm4-as","last_synced_at":"2026-02-15T07:33:02.330Z","repository":{"id":66036602,"uuid":"448817125","full_name":"RobLoach/wasm4-as","owner":"RobLoach","description":"Drop-in replacement to WASM-4's wasm4.ts to make using AssemblyScript with WASM-4 easy","archived":false,"fork":false,"pushed_at":"2022-01-25T07:10:03.000Z","size":21,"stargazers_count":4,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T07:53:07.687Z","etag":null,"topics":["wasm4"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobLoach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-01-17T08:48:42.000Z","updated_at":"2025-03-28T15:56:01.000Z","dependencies_parsed_at":"2023-02-21T21:16:03.321Z","dependency_job_id":null,"html_url":"https://github.com/RobLoach/wasm4-as","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RobLoach/wasm4-as","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwasm4-as","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwasm4-as/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwasm4-as/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwasm4-as/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobLoach","download_url":"https://codeload.github.com/RobLoach/wasm4-as/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwasm4-as/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29472880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T06:58:05.414Z","status":"ssl_error","status_checked_at":"2026-02-15T06:58:05.085Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["wasm4"],"created_at":"2024-10-10T07:19:54.588Z","updated_at":"2026-02-15T07:33:02.312Z","avatar_url":"https://github.com/RobLoach.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WASM-4 AssemblyScript Extras\n\nWASM-4 AssemblyScript Extras (*wasm4-as*) is a drop-in replacement to WASM-4's [`wasm4.ts`](src/wasm4.ts) to ease development and make using WASM-4 with AssemblyScript feel more at home.\n\n## Features\n\n- Set the palette using hex strings\n- Rapidly change drawing colors directly through the drawing methods\n- Input API to check if buttons were pressed once\n- Write to persistent memory like an integer array\n- Clean API to avoid having to reference the WASM-4 memory address banks directly\n\n## Example\n\n``` js\nimport * as w4 from \"./wasm4\"\n\nexport function start() : void {\n    // Palette\n    // https://lospec.com/palette-list/mononoke-san\n    w4.palette(\"03324e\", \"c74148\", \"dbb9a0\", \"ffffff\")\n}\n\nexport function update (): void {\n    // Clear the screen.\n    w4.cls()\n\n    // Draw some Rectangles\n    w4.rect(0, 0, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, 1, 1)\n    w4.rect(w4.SCREEN_SIZE / 2, 0, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, 2, 2)\n    w4.rect(0, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, 3, 3)\n    w4.rect(w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, 4, 4)\n\n    // Shapes\n    w4.circ(10, 20, 10, 3, 2)\n    w4.ellipse(40, 20, 10, 5, 3, 2)\n    w4.line(80, 120, 50, 80, 2)\n    w4.pixel(w4.mousex(), w4.mousey(), 2)\n\n    // Text\n    w4.text(\"Hello World!\", w4.SCREEN_SIZE / 2, w4.SCREEN_SIZE / 2, 4, 2, 1, 1)\n\n    // Input\n    if (w4.mouse(w4.MOUSE_LEFT)) {\n        w4.text(\"Random Number: \" + w4.rand(0, 100).toString(), 0, w4.SCREEN_SIZE, 1, 0, 0, 2)\n    }\n}\n```\n\n## Quick Start\n\n``` bash\nnpm i\nnpm start\n```\n\n## Usage\n\n1. Replace your project's `wasm4.ts` this [wasm4.ts](src/wasm4.ts)\n2. Import all the methods by using either of the following:\n    ``` js\n    // WASM-4\n    import * as w4 from \"./wasm4\"\n\n    // WASM-4\n    import { color, palette, cls, line, pixel, hline, vline, ellipse, oval, rect, text, textWidth, textHeight, circ, btn, btnp, mouse, mousep, mousex, mousey, rand, diskw, diskr } from \"./wasm4\"\n    ```\n\n## API\n\nThe API builds ontop of the base WASM-4 API to be a bit more user-friendly.\n\n``` js\ncolor([color1], [color2], [color3], [color4])\npalette(color1, color2, color3, color4)\ncls([color])\nline(x1, y1, x2, y2, [color])\npixel(x, y, [color])\nhline(x, y, length, [color])\nvline(x, y, length, [color])\nellipse(x, y, radiusH, radiusV, [color], [fill])\nrect(x, y, width, height, [color], [fill])\ntext(text, x, y, [color], [background], [horizontalAlign], [verticalAlign])\ncirc(x, y, radius, [color], [fill])\nbtn(button, [player])\nbtnp(button, [player])\nmouse(button)\nmousep(button)\nmousex()\nmousey()\nrand(min, max)\ndiskw(position, value)\ndiskr(position)\n```\n\n## License\n\n*wasm4-as* is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fwasm4-as","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobloach%2Fwasm4-as","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fwasm4-as/lists"}