Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program player and enemy behaviour #105

Open
Glebanister opened this issue May 13, 2022 · 0 comments · May be fixed by #110
Open

Program player and enemy behaviour #105

Glebanister opened this issue May 13, 2022 · 0 comments · May be fixed by #110
Assignees

Comments

@Glebanister
Copy link
Collaborator

Glebanister commented May 13, 2022

The task is to create a StateMachine for the hero and for the enemies.

Some common notes:

  • Each State Machine controls one entity: a hero or one of the enemies.
  • These state machines will be inheritors of StateMachine.
  • In their constructors, they should accept IDs of the corresponding Mob.
  • In their constructors, they should accept all settings of the Mob: attack radius, the force of the attack, initial health points, etc.
  • In their constructors, they should initialize the State Machine by using the add_state and add_transition methods of the StateMachine parent class.
  • The state machines should be placed in this folder: core/event/management/controller/statemachine/

During this task, you may want to create RadiusFilter, KeyPressedTransition, KeyHeldTransition and maybe something else as well.

Note, that Mob can perform an attack, it can jump and probably something else. So, you may want to create some helper functions to not repeat the logic of the attack twice (in each controller).

In some states you may want to change the image of the entity. It will be done in the issue #106

The attack and the jump are states of the StateMachine. Hence, they are kinds of the Controller. So, you will need to create a couple of Controllers and put them into core/event/management/controller:

  • Bounce makes some PhysicalEntity bounce off the ground. In the constructor, it should accept the parameters of the jump (the module of the impulse, for example) and the Image, which should be set when the jump is performed. In the control function it applies an impulse to the corresponding PhysicalEntity and changes its image.
  • AttackInRadius makes mob attack its enemies. Let's assume, that enemies may hit enemies as well. In the constructor, it accepts the radius of the attack and the force and the id of the entity, which performs the attack and the Image, which will represent the visual view of an attack. In the control function, it filters all entities in the given radius with `RadiusFilter, decreases their health points and sets the mob's image to the given one.
  • Walk makes some PhysicalEntity walk, or just move in one direction. It accepts walk animation - Image, speed and direction (would be nice to create enum Walk::Direction with two values: Left, Right). In control, just applies an impulse to move the object.
  • Idle makes an entity just do nothing. It should accept the animation of 'not doing nothing'.

Maybe I have missed some states, but these are essential.

I have drawn an example of the state machine for the hero, which can jump, walk and attack. You may check it out here: hero-statemachine.drawio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants