pytchlang / pytch-vm

Pytch: Core language and runtime
Other
3 stars 7 forks source link

Handle malformed appearance specs #11

Closed bennorth closed 4 years ago

bennorth commented 4 years ago

Currently, if a Costume or Backdrop has a malformed descriptor (for example, omitting the centre-x and centre-y values), no obvious error is thrown, but the project does not behave properly.

Add validation of the descriptors; failure is translated into a Python-level exception.

bennorth commented 4 years ago

This PR was prompted by a report from @gdstrong:

If the sprite costume center coords are missing then Pytch silently fails. The sprite is positioned at the center of the stage and does not respond to any "move" statements (which also silently fail when they are run). We should either (1) check for missing coords during Sprite.__init__, or (2) automatically set the center of the image (if we can determine the bounding box).

This PR takes approach (1), although it's actually during Sprite registration that the check happens.  I also quite like the idea of (2), but maybe that can be a separate issue/feature-request.

bennorth commented 4 years ago

Apologies; GitHub auto-closed when I deleted the (temporary) base branch. Have created new PR #12 and transferred comments across.