Hi!
This is a solution
Shared with Dropbox
The code:
// Animation example by: Luis lopez martinez. 27/05/2020.
// luislopezmartinez1979@gmail.com
// UTILS_gameLibZero is a litle part of game engine called "gameLibZero" for processing.
// Enjoy it!
int st = 0; // main state machine..
PImage[] img; // images for game..
int[] seq_00 = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5}; // animation sequence..
int[] seq_01 = {5,5,5,5,4,4,4,4,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,0}; // animation sequence..
int anima = 0; // animation iterator..
//------------------------------------------------------------------------------------
void setup(){
size(640, 360);
img = loadImages("images");
}
//------------------------------------------------------------------------------------
void draw(){
background(0);
switch(st){
case 0:
if(key(_LEFT)){
anima = (anima+1)%seq_00.length;
screenDrawGraphic(img[seq_00[anima]], 320, 180, 0, 100, 100, 255);
}
if(key(_RIGHT)){
anima = (anima+1)%seq_01.length;
screenDrawGraphic(img[seq_01[anima]], 320, 180, 0, 100, 100, 255);
}
if(!key(_LEFT) && !key(_RIGHT)){
screenDrawGraphic(img[0], 320, 180, 0, 100, 100, 255);
}
break;
case 10:
break;
}
}
//------------------------------------------------------------------------------------
This code includes a litle collection of minimal function set to draw graphics easy on screen and check multi key system
Enjoy it man!