Skip to content

Commit

Permalink
Begun entity work
Browse files Browse the repository at this point in the history
  • Loading branch information
jmickle66666666 committed Dec 27, 2018
1 parent 539a6fb commit 9044b00
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
30 changes: 29 additions & 1 deletion js/jzbuilder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/jzbuilder.js.map

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class BuilderCanvas {
ACTIVE_FONT_COLOR : string = "#FFFFFFFF";
INACTIVE_FONT_COLOR : string = "#FFFFFF77";
PROCESSED_VERTEX_COLOR : string = "#019900";
ENTITY_COLOR:string = "#66CC44";
ENTITY_STROKE_COLOR:string = "#336622";

VERTEX_SIZE : number = 2;
ZOOM_SPEED : number = 1.05;
Expand Down Expand Up @@ -65,9 +67,22 @@ class BuilderCanvas {
public redraw():void {
this.drawGrid();
this.drawSectors(mapData.sectors);
this.drawEntities(mapData.entities);
this.drawIcons();
}

public drawEntities(entities:Array<IEntity>) {
this.ctx.fillStyle = this.ENTITY_COLOR;
this.ctx.strokeStyle = this.ENTITY_STROKE_COLOR;
entities.forEach(e => {
this.ctx.beginPath();
let p = this.posToView(e.position);
this.ctx.ellipse(p.x, p.y, 16 / this.zoom, 16 / this.zoom, 0, 0, Math.PI * 2);
this.ctx.fill();
this.ctx.stroke();
});
}


public modeSelectionOffset:Vertex = new Vertex(10,74);
private toolSpacing:number = 24;
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function init() {
Tool.tools.push(new BaseTool());
Tool.tools.push(new Extrude());
Tool.tools.push(new Split());
// Tool.tools.push(new EntityTool());

Tool.changeTool(Tool.tools[0]);

Expand Down
2 changes: 2 additions & 0 deletions src/mapdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
class MapData {

public sectors : Array<Sector>;
public entities : Array<IEntity>;

constructor () {
this.sectors = new Array<Sector>();
this.entities = new Array<IEntity>();
this.defaultMap();
}

Expand Down
8 changes: 8 additions & 0 deletions src/tools/entitytool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class EntityTool implements ITool {
name:string = "Entities";
selectKey:string = "r";

onMouseDown() {
mapData.entities.push({position:Input.mousePos.clone()});
}
}

0 comments on commit 9044b00

Please sign in to comment.