0.3.4-alpha2 • Published 3 years ago

skulpt-pygame-zero v0.3.4-alpha2

Weekly downloads
127
License
ISC
Repository
github
Last release
3 years ago

English | 简体中文

pygame-zero module for skulpt

Introduction

This module provides most of the functions of pygame-zero for skulpt, and can use pygame-zero to write some simple 2d games in the web environment and run based on PIXI.js

Installation

Use npm:

npm install skulpt-pygame-zero

Use cdn:

https://cdn.jsdelivr.net/gh/lipten/skulpt-pygame-zero@master/dist/main.js

Usege

  1. Import module

    // webpack
    import 'skulpt-pygame-zero'
    
    // cdn
    <script src="https://cdn.jsdelivr.net/gh/lipten/skulpt-pygame-zero@master/dist/main.js"></script>
  1. Use PyGameZero.usePyGameZero to wrap read function

    Sk.configure({
      .... other settings
      // before
      read: builtinRead,
      // after 
      read: PyGameZero.usePyGameZero(builtinRead),
      __future__: Sk.python3,
    });
  2. Designated container

html

<div id="stage"></div>

javascript

PyGameZero.setContainer(document.getElementById('stage'))
  1. It is best to execute a reset method before running

    // insert before running
    PyGameZero.reset();
    // running skulpt
    Sk.misceval.asyncToPromise(function() {
    	return Sk.importMainWithBody("<stdin>", false, pythonCode, true);
    });

Copy the code of test/simple.py for testing

What is the difference between skulpt-pygame-zero and pygame-zero

  1. Image resources can only be loaded via links

    Actor('https://static.lipten.link/blogs/pig1.png')
  2. You can also pass in multiple pictures

    pig = Actor(('https://static.lipten.link/blogs/pig1.png','https://static.lipten.link/blogs/pig2.png'))
    
    # then ute frame=2 to switch the second photo
    pig.frame = 2

Below is the unimplemented pygame-zero api

  • images
  • music.fadeout
  • music.queue
  • Actor keyword argument: pos, topleft, topright, bottomleft, bottomright, midtop, midleft, midright, midbottom or center
  • Anchor point
  • Tone Generator

Building

  1. git clone git@github.com:lipten/skulpt-pygame-zero.git
  2. Install the required parcel using npm i -g parcel-bundler
  3. Execute the following commands in the project directory:
npm run build
0.3.3-alpha

3 years ago

0.3.4-alpha2

3 years ago

0.3.4-alpha

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.0-alpha2

3 years ago

0.3.0-alpha3

3 years ago

0.3.0-alpha1

3 years ago

0.2.3-alpha3

3 years ago

0.2.3-alpha2

3 years ago

0.2.3-alpha

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago