// class for the dude I control int STATE_MOVE = 0; int STATE_TALK = 1; int STATE_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("boy_run"); idle = loadAnimation("boy_idle"); talk = loadAnimation("boy_talk"); state = STATE_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 == STATE_MOVE) { move.display(xpos, ypos, time, true, s, flip); } if (state == STATE_IDLE) { idle.display(xpos,ypos,time,true,s,flip); } if (state == STATE_TALK) { talk.display(xpos,ypos,time,true,s,flip); } } void Draw(int time, int s) { if (movementKeys[0] || movementKeys[1]) { state = STATE_MOVE; boolean moved = false; if (wallhit != -1 && movementKeys[0]) { flip = false; xpos -= 1*s; moved = true; } if (wallhit != 1 && movementKeys[1]) { flip = true; xpos += 1*s; moved = true; } if (moved) move.display(xpos, ypos, time, true, s, flip); else state = STATE_IDLE; } else { if (state == STATE_MOVE) state = STATE_IDLE; } if (state == STATE_IDLE) { idle.display(xpos,ypos,time,true,s,flip); } if (state == STATE_TALK) { talk.display(xpos,ypos,time,true,s,flip); } wallhit = 0; } }