Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class enemy {
- constructor() {
- foostate = new stateFoo(this);
- barstate = new stateBar(this);
- // more states.
- // assign a default state:
- currentstate = foostate;
- }
- // called each frame.
- update() {
- currentstate->run();
- }
- setState(newstate) {
- currentstate = newstate;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment