Class Obstacle

  • All Implemented Interfaces:
    CollisionCallBack
    Direct Known Subclasses:
    Weather

    public class Obstacle
    extends Entity
    implements CollisionCallBack
    // Added for Assessment 2 Requirements // A class for obstacles in the game world, both trigger or contact.
    • Constructor Detail

      • Obstacle

        public Obstacle​(java.lang.String texName,
                        boolean trigger,
                        float damage)
        Generate an obstacle which only triggers a hit on initial collision and does not break.
        Parameters:
        texName - The texture to show for the obstacle.
        trigger - True if the obstacle is trigger, otherwise is contact.
        damage - The damage that the obstacle does per 'hit'
      • Obstacle

        public Obstacle​(java.lang.String texName,
                        boolean trigger,
                        float damage,
                        float hitRate,
                        int hitLimit)
        Generate an obstacle.
        Parameters:
        texName - The texture to show for the obstacle.
        trigger - True if the obstacle is trigger, otherwise is contact.
        damage - The damage that the obstacle does per 'hit'
        hitRate - The rate at which 'hits' occur while colliding
        hitLimit - The number of 'hits' required to break the obstacle
    • Method Detail

      • kill

        public void kill()
        Sets the obstacle to be removed on next update
      • update

        public void update()
        Runs once per frame
        Overrides:
        update in class Entity
      • BeginContact

        public void BeginContact​(CollisionInfo info)
        Takes the collision info and verifies the results of the collision
        Specified by:
        BeginContact in interface CollisionCallBack
        Parameters:
        info - the info linked to the collision
      • EnterTrigger

        public void EnterTrigger​(CollisionInfo info)
        Takes the collision info and verifies the results of the collision
        Specified by:
        EnterTrigger in interface CollisionCallBack
        Parameters:
        info - the info linked to the collision