I am creating a simple JS canvas tile based game, I know it needs refactoring and updating of the syntax which I plan to do when I understand more about what is going on.
I have created the tile sizes dynamically which I think is why I am struggling. The collision detection isn't precise, and I am stumped as to making it more precise... By precise, I mean depending on the size of the display the collision is not hitting the right wall but just before it or after it for example.
Any help/advice, or pointing in the right direction, would be greatly appreciated.
this.moveUp = function(){
if(this.y > gameCanvas.height / 8){
this.y -= 7;
}
};
this.moveDown = function(){
if(this.y < gameCanvas.height - map.tSizeY * 1.5){
this.y += 7;
}
};
this.moveLeft = function(){
if(this.x > gameCanvas.width / 8){
this.x -= 7;
}
};
this.moveRight = function(){
if(this.x < gameCanvas.width - map.tSizeX * 1.25){
this.x += 7;
}
}
Github Repo: https://github.com/MrWalshy/jsLameTileGame