summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 09:00:07 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 09:00:07 +0100
commita2ea4e5ef5233c7373ceeaaccc3d8df72dc6359e (patch)
tree61de354d2e2a098e58340b4e86ad37cf69cd818b /src
parent00970b9faa9338817ec3dddced6dadef69d86fe3 (diff)
downloadrpgedit-a2ea4e5ef5233c7373ceeaaccc3d8df72dc6359e.tar
rpgedit-a2ea4e5ef5233c7373ceeaaccc3d8df72dc6359e.zip
Be explicit about return types, fix a few visibilities
Diffstat (limited to 'src')
-rw-r--r--src/control/MapContext.ts19
-rw-r--r--src/model/EntityPosition.ts2
-rw-r--r--src/view/InputHandler.ts4
-rw-r--r--src/view/MapView.ts10
4 files changed, 17 insertions, 18 deletions
diff --git a/src/control/MapContext.ts b/src/control/MapContext.ts
index 73b3c4d..1660ad4 100644
--- a/src/control/MapContext.ts
+++ b/src/control/MapContext.ts
@@ -13,13 +13,12 @@ import MapView from '../view/MapView';
export default class MapContext {
- view: MapView;
+ private view: MapView;
- entities: EntityPosition[] = [];
- playerEntity: EntityPosition;
+ private entities: EntityPosition[] = [];
+ private playerEntity: EntityPosition;
-
- collision: number[][];
+ private collision: number[][];
constructor(private map: MapData, private inputHandler: InputHandler) {
@@ -63,12 +62,12 @@ export default class MapContext {
return p.x >= 0 && p.x < this.map.width && p.y >= 0 && p.y < this.map.height;
}
- private incCollision(p: Position) {
+ private incCollision(p: Position): void {
if (this.inMap(p))
this.collision[p.x][p.y]++;
}
- private decCollision(p: Position) {
+ private decCollision(p: Position): void {
if (this.inMap(p))
this.collision[p.x][p.y]--;
}
@@ -77,19 +76,19 @@ export default class MapContext {
return (!this.inMap(p)) || (this.collision[p.x][p.y] > 0);
}
- private addEntity(entity: EntityPosition) {
+ private addEntity(entity: EntityPosition): void {
this.entities.push(entity);
this.incCollision(entity.position);
}
- private addTransition(entity: EntityPosition, dest: Position, start: number, dur: number) {
+ private addTransition(entity: EntityPosition, dest: Position, start: number, dur: number): void {
entity.transition = new Transition(start, start+dur, entity.position, dest);
this.incCollision(dest);
}
- private finishTransition(entity: EntityPosition) {
+ private finishTransition(entity: EntityPosition): void {
this.decCollision(entity.position);
entity.position = entity.transition.dest;
diff --git a/src/model/EntityPosition.ts b/src/model/EntityPosition.ts
index 28b3837..19bcad5 100644
--- a/src/model/EntityPosition.ts
+++ b/src/model/EntityPosition.ts
@@ -8,7 +8,7 @@ import Transition from './Transition';
export default class EntityPosition {
- public transition: Transition = null;
+ transition: Transition = null;
constructor(public entity: Entity, public position: Position, public direction: Direction) {}
}
diff --git a/src/view/InputHandler.ts b/src/view/InputHandler.ts
index dcfd85d..86d4ec6 100644
--- a/src/view/InputHandler.ts
+++ b/src/view/InputHandler.ts
@@ -7,9 +7,9 @@ import Direction from '../model/Direction';
class InputHandler {
keys: {[key: number]: boolean} = {};
- listeners: (() => void)[] = [];
+ private listeners: (() => void)[] = [];
- private callListeners() {
+ private callListeners(): void {
this.listeners.forEach(l => l());
}
diff --git a/src/view/MapView.ts b/src/view/MapView.ts
index 230ecf3..daab7cb 100644
--- a/src/view/MapView.ts
+++ b/src/view/MapView.ts
@@ -100,7 +100,7 @@ export default class MapView {
});
}
- private setSize() {
+ private setSize(): void {
var e = document.documentElement;
var w = window.innerWidth || e.clientWidth || body.clientWidth;
var h = window.innerHeight || e.clientHeight || body.clientHeight;
@@ -114,7 +114,7 @@ export default class MapView {
this.redraw()
}
- private drawTile(x: number, y: number, tile: HTMLImageElement) {
+ private drawTile(x: number, y: number, tile: HTMLImageElement): void {
if (!tile)
return;
@@ -139,7 +139,7 @@ export default class MapView {
return !!e.transition;
}
- private setOrigin(time: number) {
+ private setOrigin(time: number): Rect {
var origin = entityPosition(this.origin, time);
var w = this.canvas.width;
@@ -156,7 +156,7 @@ export default class MapView {
);
}
- private draw(time: number) {
+ private draw(time: number): void {
this.updateState(time);
this.redrawPending = false;
@@ -204,7 +204,7 @@ export default class MapView {
this.redraw();
}
- redraw() {
+ redraw(): void {
if (this.redrawPending)
return;