Commit graph

228 commits

Author SHA1 Message Date
Paul Kaplan
b68b874067 Add sprite duplication method 2017-09-07 11:51:21 -04:00
TheBrokenRail
936ff04b0f Fix setting Infinity to direction (#612)
* Create rendered-target.js

* Update math-util.js

* Update rendered-target.js

* Update math-util.js

* Update rendered-target.js
2017-07-26 17:44:02 -04:00
Paul Kaplan
f96a92b4d1 Move renaming and adding into rendered-target with tests 2017-07-25 10:32:25 -04:00
Christopher Willis-Ford
06d5994a32 Use targetWasCreated event to clone pen state
Remove explicit cloning of `_customState` in favor of smarter,
state-specific cloning.
2017-06-16 14:22:51 -07:00
Christopher Willis-Ford
04871e24d6 Move RenderedTarget.runtime into Target
Some code in `Target` was already assuming a `runtime` property was
available, so this change just makes it official.
2017-06-16 13:16:13 -07:00
Christopher Willis-Ford
454082b569 Improve cleanup on clone disposal
The `dispose()` method on `RenderedTarget` now:
- informs the runtime that it should end any threads corresponding the
  target being disposed, and
- removes the clone from its sprite.
2017-06-07 17:05:24 -07:00
Paul Kaplan
3eaec99e51 Always activate the current costume after deleting 2017-05-22 08:17:28 -04:00
Paul Kaplan
423da12c3c Handle more cases of deleting costumes 2017-05-22 08:17:28 -04:00
Paul Kaplan
30a0c0d251 Allow deleting the last sound 2017-05-22 08:17:28 -04:00
Paul Kaplan
a608ca4fed Make rendered targets in charge of deleting their own sounds and costumes 2017-05-22 08:17:28 -04:00
Ray Schamp
20337b53f2 Stop emitting SPRITE_INFO_REPORT
Instead, set the `_refreshTargets` flag, and emit a full target list at the end of the step.
2017-05-12 11:42:22 -04:00
Ray Schamp
6c9701f4b2 Merge branch 'develop' into feature/serialization 2017-05-11 13:04:27 -04:00
Rasmus Haglund
d0f1b77209 Copy _customState for now until blocks have init functions 2017-05-05 21:58:18 +02:00
Ray Schamp
baee9a2793 Don't clean costume and sound lists
They are already clean, since we don't store the data on them any more.
2017-05-04 13:03:42 -04:00
Ray Schamp
f785117e1d Lint and fix failing tests 2017-04-27 17:49:57 -04:00
Ray Schamp
c9ce6776aa Get SB3 imports working
For now, store the md5 + extension on costumes in the VM. This way we can load them the same way as we load SB2 assets.
2017-04-27 17:08:06 -04:00
Ray Schamp
b2ea201707 Don't include asset data in exported JSON 2017-04-26 17:45:36 -04:00
Ray Schamp
a4cdb027ab Merge branch 'develop' of github.com:morantsur/scratch-vm into feature/serialization
# Conflicts:
#	src/playground/index.html
#	src/serialization/sb2.js
#	src/sprites/rendered-target.js
#	src/virtual-machine.js
#	test/unit/serialization_sb2.js
2017-04-26 11:44:53 -04:00
Ray Schamp
a4f095db5e Use ES6 style classes 2017-04-17 19:42:48 -04:00
Ray Schamp
e01c4ae108 Pass with --fix 2017-04-17 15:10:04 -04:00
Chris Willis-Ford
44623db5e3 Merge pull request #522 from presight/develop
Fix so that size is set in float to ensure backward compatibility with Scratch 2.0
2017-04-06 14:55:08 -07:00
Paul Kaplan
8e84b2757e Report costume and sound data in sprite json 2017-04-06 09:37:39 -04:00
spenen
0f0292320b Added size to playground render info 2017-04-05 18:51:16 +02:00
spenen
8c7097f724 Fix #521 so that size is set in float to ensure backward compatibility with Scratch 2.0 2017-04-05 13:46:42 +02:00
Eric Rosenbaum
2303a1abc5 Remove call to loadSounds from rendered-target initDrawable 2017-03-27 11:56:28 -04:00
Moran
94d2a39cc1 Merge branch 'develop' of https://github.com/LLK/scratch-vm into develop 2017-03-13 18:07:17 -04:00
Christopher Willis-Ford
c23e9c6bf8 Load projects & costumes through scratch-storage
This also sets up the framework to load sounds through scratch-storage,
to be finished in a later change.
2017-03-09 11:25:55 -08:00
Paul Kaplan
5b82096670 Clear gfx on stop all 2017-03-06 15:54:52 -05:00
Moran
d8e1d42bf2 Merge branch 'develop' of https://github.com/LLK/scratch-vm into develop 2017-03-03 15:23:43 -05:00
Ray Schamp
bf2303f6de Merge pull request #490 from rschamp/dnd
Add methods for dragging and dropping sprites
2017-03-03 09:50:34 -05:00
Ray Schamp
d0cd9cd897 Add methods for dragging and dropping sprites
* Add `getTargetIdForDrawableId` to translate between renderer picks and VM targets
* Add `startDrag` to stop sprite motion while dragging
* Add `stopDrag` to return sprite motion after dragging
2017-03-03 09:43:31 -05:00
Ray Schamp
319f27a060 Merge pull request #487 from rschamp/draggability
Add draggable property to sprites
2017-03-02 15:56:12 -05:00
Andrew Sliwinski
a4578ba086 Default bitmapResolution to 1 if not provided in costume metadata (#485)
* Default bitmapResolution to 1 if not provided in costume metadata. Resolves GH-484
2017-03-02 11:21:01 -05:00
Ray Schamp
8dadc42857 Add draggable property to sprites
This property should be managed by the VM so that it can be displayed in the sprite info panel in the GUI.
2017-03-01 18:49:17 -05:00
Ray Schamp
370f2c6a47 Merge pull request #459 from griffpatch/feature/FencingAgain
Feature fencing again
2017-02-24 11:27:10 -05:00
Chris Willis-Ford
a56db95aba Merge pull request #446 from magmaboat/hasownproperty
Perform hasOwnProperty validation
2017-02-22 13:55:54 -08:00
griffpatch
7bc141e76e Feature Fencing
This is a re-comit after the previous pull was reverted.
2017-02-15 15:59:54 +00:00
Ray Schamp
39158c9d48 Revert "Feature fencing" 2017-02-15 09:40:10 -05:00
griffpatch
75e3f6002b Fencing - Take 3
Dependant on scratch-render pull request.
2017-02-14 09:12:35 +00:00
Christopher Willis-Ford
bd76395676 Minor cleanup around cloning methods 2017-02-13 14:44:51 -08:00
griffpatch
4d63dcac3b Rename fencing method 2017-02-11 14:30:18 +00:00
Magmaboat
85eee4f18e Perform hasOwnProperty validation 2017-02-09 21:12:47 -05:00
griffpatch
464722f7bd Feature - Fencing of sprites
This change requires that the pull request for scratch-render (Feature
fencing #82) be taken first
2017-02-09 10:02:45 +00:00
morant
ed978e3062 Read sprite costume names from JSON, and write currentCostume to JSON 2017-02-07 20:12:55 -05:00
morant
0dc1883e9f Write costumes and sounds to JSON on save 2017-02-07 18:15:11 -05:00
morant
e16f2924a3 Merge branch 'develop' of https://github.com/LLK/scratch-vm into develop 2017-02-07 09:53:17 -05:00
Eric Rosenbaum
9741dc2e35 Merge branch 'develop' of https://github.com/LLK/scratch-vm into sound 2017-02-02 16:37:07 -05:00
Ray Schamp
727fcc7875 Lint for eslint-config-scratch@3 2017-02-01 16:27:55 -05:00
Eric Rosenbaum
95e29ed66a move sound-related code out of rendered target 2017-01-31 18:32:46 -05:00
Eric Rosenbaum
2d8491123e Merge branch 'develop' of https://github.com/LLK/scratch-vm into sound 2017-01-30 11:28:52 -05:00
Eric Rosenbaum
cb4209b27a target handles playnote via audio engine 2017-01-30 10:56:06 -05:00
Eric Rosenbaum
5966a46bbd target manages instrument setting 2017-01-30 10:54:24 -05:00
Eric Rosenbaum
4e4b0b86e1 target manages audio effect values 2017-01-30 10:53:12 -05:00
Eric Rosenbaum
01e237a2d5 audio engine loads all sounds 2017-01-30 10:50:28 -05:00
Eric Rosenbaum
4e57ab561d move playsound function to target 2017-01-30 10:45:15 -05:00
morant
c6c1a63ff0 Merge branch 'feature/194' of https://github.com/morantsur/scratch-vm into develop
+ Solve code conflicts, and handle deserialization of 3.0 projects.

# Conflicts:
#	src/index.js
#	test/unit/serialization_sb2.js
2017-01-27 20:05:54 -05:00
griffpatch
cf43efe3ee Effect not correctly copied to clones #337
Fixes Effect not correctly copied to clones #337
2017-01-27 13:11:17 +00:00
Christopher Willis-Ford
a6190da774 Lint fixes and related cleanup 2017-01-19 12:50:46 -08:00
Christopher Willis-Ford
369c02b5d5 Implement pen blocks
These blocks implement pen features as found in Scratch 2.0

Supporting changes include:
- `Target` is now an event emitter
- `RenderedTarget` now emits an event when it moves
- `Target` can now store arbitrary "extra" data, called "custom state"
  in the code, using a `Target`'s `setCustomState` and `getCustomState`
  methods. This is used to store per-target pen state without requiring
  `Target` or `RenderedTarget` to know anything about the pen.
- `Cast` can now cast to an RGB color object.
- `Color` now has functions to convert between RGB and HSV, constants
  for for black & white, and a `mixRgb` function to lerp between two
  colors.
2017-01-19 11:51:22 -08:00
Ray Schamp
a56346d0a9 Only update costume rotationCenter if it exists
This prevents sending `NaN`s to the renderer as the rotation center, which prevents the initial render of the costume/backdrop.

Towards LLK/scratch-gui#18
2017-01-13 13:05:06 -05:00
Ray Schamp
4ba76bbdbd Fix adding SVG costumes
Previously it assumed every costume to have a `bitmapResolution` property which doesn't apply to vector costumes. This caused the renderer to not render added SVG costumes when they were added with setCostume.
2017-01-12 15:34:05 -05:00
Eric Rosenbaum
4022703537 move audio state vars into rendered target 2017-01-11 15:42:07 -05:00
Eric Rosenbaum
bd8fdad1d4 add check for audioengine 2017-01-06 16:24:16 -05:00
Eric Rosenbaum
18c88c8ee0 fix stop for audio 2017-01-06 16:14:41 -05:00
Eric Rosenbaum
b88c6c96e2 initialize audio player once per sprite (not for clones) 2017-01-06 16:14:27 -05:00
Eric Rosenbaum
fec9e5b91a add audio to playground 2017-01-06 11:49:25 -05:00
Eric Rosenbaum
c0d57b4b6b separate out main audioengine from audioplayer for each clone 2017-01-04 18:37:55 -05:00
Andrew Sliwinski
6d83931341 WIP clean-up 2016-12-30 10:19:58 -05:00
Andrew Sliwinski
04d9620631 Merge branch 'patch-24' of https://github.com/TheBrokenRail/scratch-vm into feature/194 2016-12-24 08:46:50 -05:00
Eric Rosenbaum
f90807e8a4 add get sound index by name 2016-12-21 16:42:19 -05:00
Eric Rosenbaum
f2793a1d59 Merge branch 'develop' of https://github.com/LLK/scratch-vm into sound
# Conflicts:
#	package.json
#	src/engine/runtime.js
#	src/sprites/clone.js
2016-12-21 15:29:57 -05:00
TheBrokenRail
838608af86 Update sprite.js 2016-12-11 12:42:39 -05:00
TheBrokenRail
04fc32b294 Update rendered-target.js 2016-12-11 12:40:06 -05:00
Ray Schamp
e9da046969 Report full sprite info in targetsUpdate
We need more than just the name for the initial render, so send everything consistent with sprite info reports.
2016-12-07 17:11:08 -05:00
TheBrokenRail
dd86759915 Update rendered-target.js 2016-12-02 15:34:01 -05:00
Ray Schamp
ce17fdbd30 Include costume data in sprite info reports
Also emit the report on all costume changes
2016-11-30 13:19:49 -05:00
TheBrokenRail
72b44b3ec7 Update rendered-target.js 2016-11-29 18:57:35 -05:00
TheBrokenRail
74b8378a7c Update sprite.js 2016-11-29 18:55:38 -05:00
TheBrokenRail
1980fbc98d Update rendered-target.js 2016-11-29 18:53:38 -05:00
TheBrokenRail
0f4e80cbfc Add Export To Sprite 2016-11-29 17:23:28 -05:00
TheBrokenRail
cac52020a4 Add Export To Rendered Target 2016-11-29 17:18:20 -05:00
Tim Mickel
a767c5ec79
Keep min and max scale in relative bounds as in Scratch 2.0 2016-11-14 12:20:29 -05:00
Eric Rosenbaum
6dadaba117 onStopAll function for stop button 2016-10-27 16:28:39 -04:00
Tim Mickel
0ede7e6ca1 Rename and delete sprites (#319)
* Add function to rename sprites

* Add delete sprite function

* Add `isSprite` helper and duplicate check for rename
2016-10-26 13:27:24 -04:00
Tim Mickel
56ef01745f Implement sprite info emitting and posting (#320) 2016-10-26 13:27:12 -04:00
Tim Mickel
2f0ce7137c Rename Clone -> RenderedTarget (#317) 2016-10-26 11:19:43 -04:00
Tim Mickel
6e9b3f262c Divide rotation center by bitmap resolution (#309) 2016-10-26 10:38:24 -04:00
Tim Mickel
5103cfb853 Address #299 and #300 (#314)
* Place clones behind sprite

* Disallow stage from cloning itself
2016-10-26 10:06:58 -04:00
Ray Schamp
7712b2902f Fix quote-props 2016-10-24 11:02:19 -04:00
Ray Schamp
73edb65c4d Replace console with minilog 2016-10-23 22:20:30 -04:00
Ray Schamp
f6c0064235 All linting other than console statements 2016-10-23 22:20:29 -04:00
Ray Schamp
68ed110b49 Pass with eslint --fix
Resolved whitespace issues, e.g., space-before-function-paren and key-spacing
2016-10-23 12:41:45 -04:00
Tim Mickel
9af9a87cb6 Pass rotation center and bitmap resolution to renderer (#288) 2016-10-19 17:01:48 -04:00
Tim Mickel
e49f076fa1 Interpreter fixes, enhancements, features (#280)
* Thread stepping rework; interp.redraw equivalent

* Add turbo mode and pause mode

* Yielding behavior to match Scratch 2.0

* Implement warp-mode procedure threads

* Add check for recursive call

* Inline wait block timer

* Revert to setInterval and always drawing

* Restore yielding in glide

* 30TPS compatibility mode

* 5-call count recursion limit

* Removing dead primitive code

* To simplify, access runtime.threads inline in `stepThreads`.

* Warp mode/timer fixes; recursive check fixes; clean-up

* Add basic single-stepping

* Add single-stepping speed slider

* Allow yielding threads to run in single-stepping

* Restore inactive threads tracking for block glows

* Add clock pausing during pause mode

* Documentation and clean-up throughout

* Don't look for block glows in `thread.topBlock`.

* Add null check for block glows; rename `_updateScriptGlows` to reflect block glowing

* Use the current executed block for glow, instead of stack

* Add more comments to `stepToProcedure`, and re-arrange to match 2.0

* Tweak to Blocks.prototype.getTopLevelScript

* Revert previous

* Fix threads array to be resilient to changes during `stepThreads`

* Restore inactive threads filtering

* Fix typo in "procedure"

* !! instead of == true
2016-10-17 23:23:16 -04:00
Tim Mickel
060d1ab2a5 Updated blocks for new renderer features (#257)
* Add "touching" block, layers blocks

* Keep in fence, if on edge bounce, fix to touching edge

* Fix degtoRad in "if on edge, bounce"

* Fixes from review
2016-10-17 23:17:55 -04:00
Eric Rosenbaum
6d9f889aa7 fixed sound loading 2016-10-17 17:16:55 -04:00
Eric Rosenbaum
ba84b6e34b move audioengine to its own module 2016-10-17 17:16:13 -04:00
Eric Rosenbaum
7bd0142deb Merge branch 'develop' of https://github.com/LLK/scratch-vm into sound
# Conflicts:
#	playground/index.html
2016-10-17 17:13:43 -04:00
Ray Schamp
bd95c1461d Add VM.clear method
Use it before loading projects so targets don't accumulate when multiple projects are loaded on the same instance.

Move check to see if the clone is the original clone onto the block implementation so all clones can be removed.

Fixes #274
2016-10-17 13:43:38 -04:00
Eric Rosenbaum
7b179546ed new setup for use with scratch-gui 2016-10-12 13:17:51 -04:00
Eric Rosenbaum
ed650ba487 Merge remote-tracking branch 'LLK/develop' into develop 2016-10-05 17:16:13 -04:00
Tim Mickel
5728d648b1 Ensure clone.effects is defined on each instance (#225)
* Ensure clone.effects is defined on each instance

* Add regression test for GH-224
2016-10-03 10:16:43 -04:00
Tim Mickel
2226fda19e Implement rotation style (#223) 2016-09-28 17:09:04 -04:00
Tim Mickel
d10ba11c8f Round costume values (#221) 2016-09-28 16:43:12 -04:00
Tim Mickel
a585a08a93 Remove extra calls to updateAllDrawableProperties (#222) 2016-09-28 16:43:04 -04:00
Eric Rosenbaum
6988cfc0d3 starting to load sounds from project files 2016-09-28 16:42:25 -04:00
Tim Mickel
a118d50056 Variables and lists (#187)
* Import lists and variables from SB2

* Switch to Variable and List objects

* Add Clone.lookupOrCreateVariable, Clone.getVariable, Clone.setVariable

* Add (get, set, change) variable blocks.

* Copy variables and lists on clone instantiation

* Move variable options closer to blocks

* Add list primitives

* Move variable and lists storage to `Target` instead of `Clone`

* Move _computeIndex to a Cast function

* Rename `getList` -> `getListAsString`

* Renames renames

* Remove extra check in Cast.isNaN
2016-09-21 16:38:33 -04:00
Tim Mickel
aa5e8d2648 Clear graphic effects on green flag (#199) 2016-09-21 16:31:07 -04:00
Ray Schamp
499ba5235c Scope renderer to instance
This allows usage without global scope to attach a renderer to the VM. It also provides the ability to have multiple VMs/renderers to be used at once.
2016-09-20 02:52:33 -04:00
Tim Mickel
9744bcbb70 Clones (#150)
* Provide property to Clone to distinguish "original" clones

* Provide method to clone a clone's properties

* Don't report clones in the UI target list

* Add target info to Thread

* Allow hats to skip clones (for green flag)

* Green flag skips clones

* Implement "create clone" and hat

* Pass the runtime to sprites and clones (for start hats)

* Clone disposal; trigger hats after drawable initializes.

* Separate stop threads for target; fix handling of stop button

* Remove extraneous `skipClones` property

* Add global clone limit

* Don't allow a non-clone to delete itself.

* Rename `cloneClone` -> `makeClone`

* Variable updates in runtime.js

* Synchronous drawable initialization (until we put it back to promises)
2016-09-15 19:37:12 -04:00
Tim Mickel
542899949e Update for RenderWebGLLocal -> RenderWebGL (#181)
* Update for RenderWebGLLocal -> RenderWebGL

* Move button under title
2016-09-15 19:02:03 -04:00
Tim Mickel
bbea1af5a3 Better shadow evaluation (#160)
* Better shadow evaluation

* Audit and improve casting for all primitives

* Force repeat times to int

* Remove colorPicker shadow menu
2016-09-12 13:14:16 -04:00
Tim Mickel
d93eeed05d More color utilities, touching color, color touching color (#155)
* Fill out color utilities

* Amend Color.decimalToHex name

* Add `Cast.toScaledRgbColor`

* Add touching color, color touching color blocks

* Fix scale of Cast.toRgbColor

* Fix format of colors to use renderer-style lists

* Update `Color.decimalToRgb`

* Lint self
2016-09-12 10:58:50 -04:00
Tim Mickel
797f844de3 Stage, costumes, backdrops (#149)
* Add `Clone.prototype.getCostumeIndexByName`, keep in range

* Add basic costume primitives from Scratch 2.0

* Add costume getter block

* Add properties and methods for distinguishing stage and sprites-vs-clones

* Add backdrop-related looks blocks

* Fix up "switch to backdrop" to be working

* Costume/backdrop reporters are 1-indexed

* Fire "when backdrop switched" hats

* Cut cloning helpers for a separate PR

* Disable many blocks on the stage

* Refactor into _setCostumeOrBackdrop; implement switch backdrop and wait

* Fire hats even when backdrop unchanged
2016-09-08 09:40:27 -04:00
Tim Mickel
ad82a5cb74 Add naming mechanism for targets/clones 2016-08-31 11:50:10 -04:00
Tim Mickel
8339e2769f Clean up and add documentation to sprite/clone 2016-08-31 11:30:09 -04:00
Tim Mickel
be06078df1 Update sprite and clones to have basic costume support 2016-08-31 11:21:32 -04:00
Tim Mickel
2c031d87f6 Make renderer/self nullable in the Clone
Fixes a test issue where renderer is not necessarily defined.
2016-08-08 18:29:44 -04:00
Tim Mickel
67c3ceff86 Update clone's scale to match renderer update 2016-08-08 16:47:52 -04:00
Tim Mickel
c650de8520 Real version of Clone.prototype.setVisible 2016-07-13 16:52:46 -04:00
Tim Mickel
7c24bdc612 More documentation in sprite, clone 2016-07-06 14:09:06 -04:00
Tim Mickel
798368b6c5 Add documentation in src/sprites/clone.js 2016-07-06 13:57:58 -04:00
Tim Mickel
460760bd06 Stub "say" and "think" blocks with console.log 2016-07-06 13:47:32 -04:00
Tim Mickel
ce941c6fd8 Add show/hide blocks using ghost effect as backend 2016-07-01 12:56:59 -04:00
Tim Mickel
1eaed6fff3 Implement graphic effects and size blocks 2016-06-30 18:59:47 -04:00
Tim Mickel
727d2c0d23 Clamp clone direction like Scratch 2.0 2016-06-30 18:59:47 -04:00
Tim Mickel
19da0b0032 Add renderer demo using scratch-render-webgl 2016-06-30 18:59:47 -04:00
Tim Mickel
809528abdc Straw-man implementation of targets/sprites/clones 2016-06-30 18:59:17 -04:00