// class for the dude I control int FSTATE_MOVE = 0; int FSTATE_TALK = 1; int FSTATE_IDLE = 2; class Dude { float xpos, ypos; boolean flip; Animation move, idle, talk; int state; Dude(float x, float y) { xpos = x; ypos = y; move = loadAnimation("guywalk"); idle = loadAnimation("guyidle"); talk = loadAnimation("emerge2"); state = FSTATE_IDLE; flip = true; } void Update() // separate from draw? { } int wallhit = 0; void WallHit(int dir) { wallhit = dir; } void DrawNoInput(int time, int s) { if (state == FSTATE_MOVE) { move.display(xpos, ypos, time, true, s, flip); } if (state == FSTATE_IDLE) { idle.display(xpos,ypos,time,true,s,flip); } if (state == FSTATE_TALK) { talk.display(xpos,ypos,time,true,s,flip); } } void Draw(int time, int s) { if (keysDown[KEY_RIGHT] || keysDown[KEY_LEFT]) { state = FSTATE_MOVE; boolean moved = false; if (wallhit != -1 && keysDown[KEY_LEFT]) { flip = false; xpos -= 1*s; moved = true; } if (wallhit != 1 && keysDown[KEY_RIGHT]) { flip = true; xpos += 1*s; moved = true; } if (moved) move.display(xpos, ypos, time, true, s, flip); else state = FSTATE_IDLE; } else { if (state == FSTATE_MOVE) state = FSTATE_IDLE; } if (state == FSTATE_IDLE) { idle.display(xpos,ypos,time,true,s,flip); } if (state == FSTATE_TALK) { talk.display(xpos,ypos,time,true,s,flip); } wallhit = 0; } }