|
307 | 307 | }, |
308 | 308 | /** BASIC GRAPHICS API */ |
309 | 309 | /** |
310 | | - * Clear the game screen |
| 310 | + * Clear the game screen with an optional color |
311 | 311 | * |
312 | 312 | * @param {number?} color The background color (index) or null (for transparent) |
313 | 313 | */ |
314 | 314 | cls(color) { |
315 | 315 | if (true) { |
316 | 316 | assert( |
317 | 317 | null == color || isFinite(color) && color >= 0, |
318 | | - "cls: 1st param must be a number" |
| 318 | + "cls: 1st param must be a positive number or zero or null" |
319 | 319 | ); |
320 | 320 | } |
321 | | - let width = _ctx.canvas.width, height = _ctx.canvas.height; |
322 | 321 | if (null == color) { |
323 | | - _ctx.clearRect(0, 0, width, height); |
| 322 | + _ctx.clearRect(0, 0, _ctx.canvas.width, _ctx.canvas.height); |
324 | 323 | } else { |
325 | | - instance.rectfill(0, 0, width, height, color); |
| 324 | + instance.rectfill( |
| 325 | + 0, |
| 326 | + 0, |
| 327 | + _ctx.canvas.width, |
| 328 | + _ctx.canvas.height, |
| 329 | + color |
| 330 | + ); |
326 | 331 | } |
327 | 332 | }, |
328 | 333 | /** |
|
667 | 672 | /** |
668 | 673 | * Get or set the canvas context 2D |
669 | 674 | * |
670 | | - * @param {CanvasRenderingContext2D} [context] |
671 | | - * @returns {CanvasRenderingContext2D} |
| 675 | + * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] |
| 676 | + * @returns {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} |
672 | 677 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D |
673 | 678 | */ |
674 | 679 | ctx(context) { |
|
852 | 857 | return false; |
853 | 858 | } |
854 | 859 | zzfxParams = zzfxParams || instance.DEFAULT_SFX; |
855 | | - if (pitchSlide > 0 || volumeFactor !== 1) { |
| 860 | + if (pitchSlide !== 0 || volumeFactor !== 1) { |
856 | 861 | zzfxParams = zzfxParams.slice(); |
857 | 862 | zzfxParams[0] = volumeFactor * (zzfxParams[0] || 1); |
858 | 863 | zzfxParams[10] = ~~zzfxParams[10] + pitchSlide; |
|
919 | 924 | assert(isFinite(y2), "colcirc: 5th param must be a number"); |
920 | 925 | assert(isFinite(r2), "colcirc: 6th param must be a number"); |
921 | 926 | } |
922 | | - return (x2 - x1) ** 2 + (y2 - y1) ** 2 <= (r1 + r2) ** 2; |
| 927 | + return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) <= (r1 + r2) * (r1 + r2); |
923 | 928 | }, |
924 | 929 | /** PLUGINS API */ |
925 | 930 | /** |
|
0 commit comments