Categories
Game Creation Mastering Development

Issue with sprite animation

I have been trying to get my player to animate for some time now and i’ve read multiple tutorials but i cant seem to achieve this. The tutorial i am following is at : https://www.simplifiedcoding.net/javascript-sprite-animation-tutorial-html5-canvas/ I create the player of a component class: mySprite = new component(168, 33, “Images/Run/character.png”, 0, 0, “sprite”); Then i create […]

Categories
Mastering Development

How to invert color in canvas for a specific condition in javascript?

I want to add a condition: if the color is [R=158, G=220, B=163], then it will invert the color. How should I change this code? ctx.drawImage(background, 0, 0, canWidth, canHeight); ctx.drawImage(character, srcX, srcY, width, height, x, y, width, height); var imgData = ctx.getImageData(x, y, width+1, height); var i; for (i = 0; i < imgData.data.length; […]