Symetrical image transformation

Codnpix

5 years ago

Hi, 

I wonder if there is something in the Gamebuino_META library that allow us to make a symetrical transformation on an image. For example if a sprite goes left or right, to be able to use the same image or animation in one direction or another.

I am nearly sure I saw something about that on the forum but I can't find it back ...

Thank you !

Steph

NEW 5 years ago

I have already explained this case here for JFT (and I think you were part of that discussion, right?).

void drawMario() {
    mario.sheet.setFrame(mario.frame);
    gb.display.drawImage(
        mario.x,
        mario.y,
        mario.sheet,
        mario.w * (mario.orientation == MARIO_ORIENTATION_LEFT ? 1 : -1), // here is the trick!
        mario.h
    ); 
}

Codnpix

5 years ago

YES that was it ! And indeed I was a part of it ! I couldn't remember what discussion it was... thanks !

Codnpix

NEW 5 years ago

Steph Steph

YES that was it ! And indeed I was a part of it ! I couldn't remember what discussion it was... thanks !

Codnpix

NEW 5 years ago

In the drawImage reference the w2 and h2 optional parameters are presented with the basic functionnality to scale the image to the new specified size, but I think it would be a great idea to add this tip directly in the reference ! 

I don't think I could think myself that simply invert the value could reverse the image orientation. It sounds obvious when it's told but... Anyway, it would be great to talk about that example in the reference.

Steph

5 years ago

You're absolutely right!

That's good... I think it's moving at the Academy level and the reference documentation is part of the changes ;-)

Steph

NEW 5 years ago

Codnpix Codnpix

You're absolutely right!

That's good... I think it's moving at the Academy level and the reference documentation is part of the changes ;-)