Fixing blink on sprites (#1047)

This commit is contained in:
Richard Knoll 2018-08-06 14:34:04 -07:00 committed by GitHub
parent b03c984c38
commit 68361499a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -537,7 +537,7 @@ namespace game {
*/ */
//% parts="ledmatrix" //% parts="ledmatrix"
public setDirection(degrees: number): void { public setDirection(degrees: number): void {
this._dir = ((degrees / 45) % 8) * 45; this._dir = (Math.floor(degrees / 45) % 8) * 45;
if (this._dir <= -180) { if (this._dir <= -180) {
this._dir = this._dir + 360; this._dir = this._dir + 360;
} else if (this._dir > 180) { } else if (this._dir > 180) {
@ -717,7 +717,6 @@ namespace game {
* @param this TODO * @param this TODO
*/ */
public blink(): number { public blink(): number {
let r: number;
return this._blink; return this._blink;
} }
@ -728,7 +727,7 @@ namespace game {
if (ps._brightness > 0) { if (ps._brightness > 0) {
let r = 0; let r = 0;
if (ps._blink > 0) { if (ps._blink > 0) {
r = (now / ps._blink) % 2; r = Math.floor(now / ps._blink) % 2;
} }
if (r == 0) { if (r == 0) {
_img.setPixelBrightness(ps._x, ps._y, _img.pixelBrightness(ps._x, ps._y) + ps._brightness); _img.setPixelBrightness(ps._x, ps._y, _img.pixelBrightness(ps._x, ps._y) + ps._brightness);