From 68361499a267886a7e90bf78342378a287f3ae64 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 6 Aug 2018 14:34:04 -0700 Subject: [PATCH] Fixing blink on sprites (#1047) --- libs/core/game.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/core/game.ts b/libs/core/game.ts index 2acdef58..626cc7f2 100644 --- a/libs/core/game.ts +++ b/libs/core/game.ts @@ -537,7 +537,7 @@ namespace game { */ //% parts="ledmatrix" public setDirection(degrees: number): void { - this._dir = ((degrees / 45) % 8) * 45; + this._dir = (Math.floor(degrees / 45) % 8) * 45; if (this._dir <= -180) { this._dir = this._dir + 360; } else if (this._dir > 180) { @@ -717,7 +717,6 @@ namespace game { * @param this TODO */ public blink(): number { - let r: number; return this._blink; } @@ -728,7 +727,7 @@ namespace game { if (ps._brightness > 0) { let r = 0; if (ps._blink > 0) { - r = (now / ps._blink) % 2; + r = Math.floor(now / ps._blink) % 2; } if (r == 0) { _img.setPixelBrightness(ps._x, ps._y, _img.pixelBrightness(ps._x, ps._y) + ps._brightness); @@ -766,7 +765,7 @@ namespace game { } // ensure greyscale mode const dm = led.displayMode(); - if (dm != DisplayMode.Greyscale) + if (dm != DisplayMode.Greyscale) led.setDisplayMode(DisplayMode.Greyscale); // render sprites const now = input.runningTime();