Skip to content

Commit 4b1821f

Browse files
committed
Fix #252.
1 parent b9d575f commit 4b1821f

File tree

4 files changed

+67
-41
lines changed

4 files changed

+67
-41
lines changed

code/cpp/state.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)