Skip to content

Event functions for p5.Element elements possibly not working?  #165

@misolietavec

Description

@misolietavec

I successfully compiled and tested examples sketch_000 - sketch 009 with pyodide (some with minor changes). Also I have a running example of simple Arkanoid (breakout) game. But there is a problem with sketch_010. I think this minimal code from p5.js reference shows it (not sure if draw() is needed, I tried with and without it):

button = None

def setup():
    createCanvas(100, 100)
    background(0)
    button = createButton('click me')
    button.position(0, 0)
    button.mousePressed(changeBG)

def changeBG():
    val = random(255)
    background(val)

def draw():
    pass

In Firefox development console there is an error each time the mouse button is pressed:
Uncaught TypeError: t.call is not a function mousePressed http://0.0.0.0:8000/static/p5.js:3

sketch_010 works with transcrypt, so maybe, there are some (as yet) not implemented features in pyodide compilation?

I like the concept of pyp5js with pyodide. In Slovakia high schools, many are using pygame (or pygame zero) for teaching with game programming. I think, web approach is better suited for the future, especially in connection with Jupyter (and holoviz panel?).

Last commits (apr. 17-th) were great, I use 0.5.2 version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions