File tree Expand file tree Collapse file tree 4 files changed +67
-41
lines changed
Expand file tree Collapse file tree 4 files changed +67
-41
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,7 @@ namespace State
376376 {
377377 // ^omit
378378 friend class StandingState ;
379+ friend class JumpingState ;
379380 // ^omit
380381 public:
381382 virtual void handleInput (Input input)
@@ -511,9 +512,29 @@ namespace State
511512 };
512513 // ^heroine-static-states
513514
515+ class Heroine
516+ {
517+ friend class JumpingState ;
518+ public:
519+ void setGraphics (Animate animate) {}
520+ private:
521+ HeroineState* state_;
522+ };
523+
514524 class StandingState : public HeroineState {};
515525 class DuckingState : public HeroineState {};
516- class JumpingState : public HeroineState {};
526+ class JumpingState : public HeroineState {
527+ void handleInput (Heroine& heroine, Input input)
528+ {
529+ // ^jump
530+ if (input == PRESS_B)
531+ {
532+ heroine.state_ = &HeroineState::jumping;
533+ heroine.setGraphics (IMAGE_JUMP);
534+ }
535+ // ^jump
536+ }
537+ };
517538 class DivingState : public HeroineState {};
518539 }
519540
You can’t perform that action at this time.
0 commit comments