Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
First variant of renderMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkonior committed Jul 31, 2018
1 parent 7b80e89 commit b1fd46b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Binary file added Assets/Smoke.pdn
Binary file not shown.
2 changes: 1 addition & 1 deletion GraphicsEngine/GUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GUI
render()
{
this.renderControler.renderBackground();
this.renderControler.renderMap(this.fases[this.curentFase].canDrawMap,);
this.renderControler.renderMap(this.fases[this.curentFase].canDrawMap,this.controler.Offset);
this.renderControler.renderGui(this.fases[this.curentFase].GuiElements);
}
switchFase(index)
Expand Down
32 changes: 30 additions & 2 deletions GraphicsEngine/RenderControler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,45 @@ class RenderControler {
this.sprites = sprites;
this.canvases=canvases;
this.engine = engine;
this.worldSize = this.engine.getWorldSize();
}

renderSprite(type, variant, x, y) {
this.sprites[type][Math.abs(variant) % this.sprites[type].length].draw(this.canvases,"mainCanvas", x, y);
//Отрисовка справйта
}
renderMap(canDo)

renderMap(canDo,offset)
{
if (canDo)
{
//for (let i = Number.max(0,);i</*todo */,i++)
var leftHightCell = new PositionOnCanvas(Math.floor((offset.x) / 32)-1, Math.floor(((offset.y)) / 32)-1);
var rightBottomCell = new PositionOnCanvas(Math.floor((offset.x+this.canvases["mainCanvas"].width) / 32)+1, Math.floor(((offset.y+this.canvases["mainCanvas"].height)) / 32)+1);
leftHightCell.x = Math.max(0,leftHightCell.x);
leftHightCell.y = Math.max(0,leftHightCell.x);
rightBottomCell.x = Math.min(rightBottomCell.x,this.worldSize.width);
rightBottomCell.y = Math.min(rightBottomCell.y,this.worldSize.height);
for (let x = leftHightCell.x; x < rightBottomCell.x; x++)
{
for (let y = leftHightCell.y; y < rightBottomCell.y; y++)
{
for (let z = 0; z < this.worldSize.depth; z++)
{
let cellInfo = this.engine.getCellInfo(x,y,z);
if (cellInfo.visibility==0||cellInfo.type=="empty")
{
continue;
}else
{
this.renderSprite(cellInfo.type,cellInfo.variant,x*BaseCellWidth,y*BaseCellHeight);
if (cellInfo.visibility==-1)
{
this.renderSprite("smoke",0,x*BaseCellWidth,y*BaseCellHeight);
}
}
}
}
}

//game.engine.getCellInfo()
}
Expand Down

0 comments on commit b1fd46b

Please sign in to comment.