griffpatch
a25e117412
optimisation/avoid negative index lookups #407
...
Run-time Optimisation
The thread.stackFrames array is accessed all the time to retrieve the
'parent' stack frame. This is done using as index of [this.stack.length
- 1]. However, a lot of the time this evaluated to [-1]. Although this
results in null, which is fine, to get to this javascript actually
defers from a numeric array lookup to an object lookup using the string
"-1". This is roughly 100 times slower to compute and so a simple catch
for negative indexes is well worth the extra check.
2017-01-28 14:38:13 +00:00
griffpatch
c6a872ef4a
Fix whitespace issues
2017-01-28 14:11:48 +00:00
griffpatch
5f100129b6
Fix for ending warp bug
...
When popping down the stack frame it is assumed that you keep using the
previous warp state rather than looking at the warp state of the level
you just popped out to. This causes the loss of screen updates if the
warping block was the last statement in a loop as the loop does not obey
it's 'non warp' status.
2017-01-28 14:03:29 +00:00
Andrew Sliwinski
de4035055b
Merge pull request #403 from griffpatch/feature/Support-ARGB-for-pen
...
Fix for Support ARGB for pen #393
2017-01-27 17:07:43 -05:00
griffpatch
0dcaa46107
Fix lint issues
...
Had to update the test scripts to handle the alpha channel, also I note
that all the hex tests are using CSS notation, not scratch notation
(which is 0x not #)
2017-01-27 17:05:17 +00:00
Andrew Sliwinski
eb3b7bfd40
Merge pull request #401 from griffpatch/Effect-not-correctly-copied-to-clones
...
Effect not correctly copied to clones #337
2017-01-27 10:52:24 -05:00
griffpatch
b856041d9a
Fix for Support ARGB for pen #393
...
Requires fix to scratch-render before this will work (see:
6f5acfee7b961d71237f1fd50bb3d5a5139c527e)
2017-01-27 13:45:16 +00:00
griffpatch
2ac4b73a1f
Importers: adjust block coordinate calculation so blocks overlap less. #326
...
This change imports the scratch blocks much closer to the Scratch 2
spacing.
2017-01-27 13:39:21 +00: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
88cc50aa18
Code review: more docs, move constants, clone util
...
Changes include:
- Added missing JSDoc for items in `scratch3_pen.js` and `target.js`.
- Moved constants used by `Scratch3PenBlocks` into the class.
- Created a constant for minimum and maximum pen size.
- Added `util/clone.js` to host cloning functionality.
- Pen blocks now check for the renderer before trying to use it.
- The pen integration test covers all blocks, though `clear`, `stamp`,
and `pen down` will skip some of their functionality when there is no
renderer.
2017-01-20 11:26:18 -08:00
Christopher Willis-Ford
d0845728ee
Add unit tests for new color-related functionality
...
Also, fix a math error in `Color.rgbToHsv`.
Newly covered functions:
- `toRbgColorObject` from `util/cast.js`
- `hsvToRgb` from `util/colors.js`
- `rgbToHsv` from `util/colors.js`
- `mixRgb` from `util/colors.js`
2017-01-19 15:24:45 -08: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
c6c4c4c00c
Merge pull request #379 from rschamp/bugfix/empty-rotation-center
...
Only update costume rotationCenter if it exists
2017-01-13 16:55:39 -05:00
Chris Willis-Ford
9b04392211
Move build outputs into a dist/
subdirectory ( #375 )
...
* Move Node output: /dist.js => /dist/node/scratch-vm.js
* Move web output: /vm{.js,.min.js} => /dist/web/scratch-vm{.js,.min.js}
* Update build output references in package.json and the playground's index.html
* Move the VirtualMachine class out of index.js into its own file, referenced by index.js. The VirtualMachine class is otherwise unchanged.
* Add .gitattributes rules for new file types which were added to this repository without specifying their text/binary attributes
* Turn on source maps in webpack and add corresponding .gitignore rule
2017-01-13 13:34:26 -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
9cc1c316d6
wrapclamp drum and instrument to num available
2017-01-11 11:41:21 -05:00
Eric Rosenbaum
f2ad364b90
vm converts one-indexing of drums and instruments to zero-indexing
2017-01-11 11:23:39 -05:00
Eric Rosenbaum
71339874de
fix name of DRUM arg
2017-01-11 11:22:58 -05:00
Eric Rosenbaum
76a475c31c
cast args to numbers
2017-01-10 18:00:33 -05:00
Eric Rosenbaum
3344c92f7e
change ‘drumtype’ to ‘drum’ in specmap
2017-01-10 18:00:02 -05:00
Eric Rosenbaum
f034564603
Merge branch 'develop' of https://github.com/LLK/scratch-vm into sound
2017-01-09 15:51:47 -05:00
Eric Rosenbaum
4d7ff97011
instrument number is zero-indexed inside audio engine
2017-01-09 15:48:31 -05:00
Eric Rosenbaum
ce8b069140
include volume reporter
2017-01-09 15:48:02 -05:00
Eric Rosenbaum
2d7cfd128a
use a single global tempo owned by audioengine
2017-01-09 15:47:29 -05:00
Eric Rosenbaum
dc9126e067
Merge pull request #373 from ericrosenbaum/sound
...
Integrate audio engine
2017-01-06 16:28:09 -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
9980f4da3f
lint
2017-01-06 16:13:43 -05:00
Eric Rosenbaum
fec9e5b91a
add audio to playground
2017-01-06 11:49:25 -05:00
Eric Rosenbaum
9350baef3b
add current volume block
2017-01-06 10:31:11 -05:00
Eric Rosenbaum
dbe2cef93c
move promise into audio engine
...
changes to play note, play drum and rest blocks so their promises to wait are returned by the audio engine
2017-01-06 10:31:01 -05:00
Eric Rosenbaum
c0d57b4b6b
separate out main audioengine from audioplayer for each clone
2017-01-04 18:37:55 -05:00
Eric Rosenbaum
5a1386f727
remove redundant type check
2017-01-04 14:42:00 -05:00
Eric Rosenbaum
3bf9238e0c
treat numeric input to sound name as 1-indexed
2017-01-04 14:41:14 -05:00
Eric Rosenbaum
7a49a3ae43
lint
2017-01-03 23:41:49 -05:00
Andrew Sliwinski
5daaaa4438
Merge pull request #362 from thisandagain/bugfix/coverage
...
Add integration test coverage
2017-01-03 09:38:14 -05:00
Andrew Sliwinski
4709cae4b7
Basic integration (end-to-end) testing for default project
2016-12-23 10:39:19 -05:00
Andrew Sliwinski
48721dd336
If not hat fields are not found, check inputs before continuing. Resolves GH-360
2016-12-23 09:38:18 -05:00
Eric Rosenbaum
f0e01d3e87
fix name of sounds menu
2016-12-22 14:12:20 -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
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
Ray Schamp
adaf2df743
Emit sprite info report for all sprites
...
This allows costume data to reach listeners even when the sprite isn't the editing target.
Filter out non-editing target reports in the playground to match previous behavior.
2016-11-30 13:21:00 -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
Ray Schamp
d00cdd6b2c
Account for done threads on threadCount update
...
Also rename inactiveThreads -> doneThreads, since this describes them better. They are the threads that have completed in the step.
2016-11-28 10:49:05 -05:00
Ray Schamp
0003b294cb
Lint
2016-11-24 10:36:30 -05:00
Ray Schamp
55ac7e269c
Add PROJECT_RUN_START/STOP events
...
These events signal when any threads are running or when all threads have stopped running. This maps to whether the green flag or the stop button should be illuminated in the GUI.
2016-11-23 15:47:49 -05:00
Ray Schamp
2ff719f2ba
Fix consistency of existing emits
2016-11-23 15:43:05 -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
Tim Mickel
4deee071b2
Don't copy threads in step; stable restartThread ( #331 )
2016-11-10 15:05:49 -05:00
Ray Schamp
2c3e4536eb
Merge pull request #316 from tmickel/feature/remove-empty-project
...
Remove empty project
2016-11-10 12:56:31 -05:00
Tim Mickel
b99f089ae7
Fix #327 , "switch costume to [next/previous]" ( #330 )
2016-11-09 11:22:17 -05:00
Tim Mickel
f235cb47e6
Merge remote-tracking branch 'LLK/develop' into feature/remove-empty-project
...
# Conflicts:
# src/index.js
2016-10-31 10:39:36 -04:00
Eric Rosenbaum
6dadaba117
onStopAll function for stop button
2016-10-27 16:28:39 -04:00
Eric Rosenbaum
1e5555e96d
add volume and tempo blocks
2016-10-27 11:31:22 -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
1dc4aaa2d7
Remove rAF usage and inline into _step ( #318 )
2016-10-26 11:32:15 -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
d75f1c5965
Remove empty project
2016-10-26 10:30:16 -04:00
Tim Mickel
cf20ca1add
Fix #313 (block specs in shadow) ( #315 )
2016-10-26 10:26:56 -04:00
Tim Mickel
28a0831e8d
Fix 1-1 in daysSince2000
2016-10-26 10:26:03 -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
Liam
f75577bcbe
Implement '(attribute) of' sensing block ( #311 )
...
* Implement '(attribute) of' sensing block
* Remove unused util parameter
2016-10-24 20:37:27 -04:00
Eric Rosenbaum
90867cd14e
convert string to number for sound index
2016-10-24 17:00:51 -04:00
Andrew Sliwinski
1b4a1ca1bc
Resolve merge conflicts
2016-10-24 15:53:42 -04:00
Andrew Sliwinski
153df22918
Address feedback from PR review
2016-10-24 15:16:06 -04:00
Ray Schamp
659014b45f
Fix typo
2016-10-24 14:07:38 -04:00
Ray Schamp
d2a0e6fa2d
Disable no-useless-call in case of behavior change
2016-10-24 13:01:57 -04:00
Ray Schamp
22bf947ddb
Revert no-lonely-if
2016-10-24 13:01:41 -04:00
Andrew Sliwinski
279a9560af
Resolve JSDoc lint errors
2016-10-24 12:04:06 -04:00
Andrew Sliwinski
336bc65e2d
Add minimal test coverage and docs for mouse module
2016-10-24 11:56:52 -04:00
Ray Schamp
04d7f4f019
Use consistent function declaration style
2016-10-24 11:49:34 -04:00
Andrew Sliwinski
2de58050dd
Conform JSdoc for keyboard module to format used elsewhere
2016-10-24 11:40:07 -04:00
Ray Schamp
9f0c4eb098
Update to eslint-config-scratch 2.0
...
We are on a fast release cycle here.
2016-10-24 11:39:39 -04:00
Ray Schamp
63cfa4229a
Fix space-infix-ops
...
http://eslint.org/docs/rules/space-infix-ops
2016-10-24 11:19:07 -04:00
Ray Schamp
7712b2902f
Fix quote-props
2016-10-24 11:02:19 -04:00
Ray Schamp
14a2dbc50f
Revert no-lonely-if
2016-10-24 10:28:31 -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
Andrew Sliwinski
faf8a898a0
Add minimal test coverage and docs for keyboard module.
2016-10-21 18:31:07 -04:00
Tim Mickel
84bd42d734
Functions to add Sprite2/costumes/backdrops ( #291 )
...
* Functions to add Sprite2/costumes/backdrops
* Have sb2import return the top-level target
2016-10-20 11:44:01 -04:00
Tim Mickel
3d57c2e74c
Drop single-stepping and pause modes ( #294 )
2016-10-20 11:42:16 -04:00
Tim Mickel
9af9a87cb6
Pass rotation center and bitmap resolution to renderer ( #288 )
2016-10-19 17:01:48 -04:00
Eric Rosenbaum
0858a22ffb
adding theremin block and set instrument
2016-10-19 15:44:30 -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
Tim Mickel
352c6516d3
Fix parent setting in sb2 importer ( #283 )
2016-10-17 16:44:33 -04:00
Cosmic Web Services
454eb904a3
Add days since 2000 block ( #272 )
...
* Add days since 2000 block
* Empty line addition
* Add semicolin
* Empty line addition
* Tabed
* Remove extra line
* Make it exactly like scratch 2 was
* Fixed spacing
2016-10-17 13:57:25 -04:00
Ray Schamp
2904152318
Merge pull request #282 from rschamp/feature/vm.clear
...
Add VM.clear method
2016-10-17 13:56:37 -04:00
Ray Schamp
5615583fb2
Lint
2016-10-17 13:54:27 -04:00