Skip to content

Instantly share code, notes, and snippets.

@niiicolai
Created October 15, 2019 13:31
Show Gist options
  • Select an option

  • Save niiicolai/d3b7272112611e81aad12778e95d3de4 to your computer and use it in GitHub Desktop.

Select an option

Save niiicolai/d3b7272112611e81aad12778e95d3de4 to your computer and use it in GitHub Desktop.
class Humanoid extends GameObject {
public HealthController healthCtrl;
public Animator animator;
Humanoid(PVector _position, PVector _size,
float _maxHealth, AnimationState[] animationStates) {
// Execute GameObject constructor
super(_position, _size);
// Set required components
boxCollider = new BoxCollider(this);
healthCtrl = new HealthController(_maxHealth);
animator = new Animator(animationStates);
}
public void display() {
// Execute play() on the animator in order to play the
// current animation
animator.play();
// Draws an image based on the current animation image
image(animator.animationImage(), position.x, position.y,
size.x, size.y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment