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

Commit

Permalink
Fix little bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkonior committed Jul 31, 2018
1 parent b1fd46b commit 1a8eedc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions GraphicsEngine/RenderControler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class RenderControler {
}

renderSprite(type, variant, x, y) {
if(type=="mob")
{
type="hero";
}
this.sprites[type][Math.abs(variant) % this.sprites[type].length].draw(this.canvases,"mainCanvas", x, y);
//Отрисовка справйта
}
Expand All @@ -17,8 +21,8 @@ class RenderControler {
{
if (canDo)
{
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);
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);
Expand All @@ -35,10 +39,10 @@ class RenderControler {
continue;
}else
{
this.renderSprite(cellInfo.type,cellInfo.variant,x*BaseCellWidth,y*BaseCellHeight);
this.renderSprite(cellInfo.type,cellInfo.variant,x*BaseCellWidth + offset.x,y*BaseCellHeight + offset.y);
if (cellInfo.visibility==-1)
{
this.renderSprite("smoke",0,x*BaseCellWidth,y*BaseCellHeight);
this.renderSprite("smoke",0,x*BaseCellWidth + offset.x,y*BaseCellHeight + offset.y);
}
}
}
Expand Down

0 comments on commit 1a8eedc

Please sign in to comment.