0

I'm trying to get mario to move side to side. The character is moving fine, but everytime the x-position changes the draw function seems to create a new image.

enter image description here [The code results like this ]

function draw(){
image(player,posx,posy,60,60);

if(keyIsPressed){
    if(key=="ArrowRight"){
        player=loadImage("Marioright.png");
        posx+=10;
    }
    if(key=="ArrowLeft"){
        player=loadImage("Marioleft.png");
        posx-=10;
    }
}

}

Hayul
  • 1
  • 1

1 Answers1

0

You need to redraw the background every frame in your draw function as well :)

Evander
  • 57
  • 4