Class GameObj


  • public class GameObj
    extends Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      javafx.scene.paint.Color colour
      Height of object
      int dirX
      Colour of object
      int dirY
      Direction X (1, 0 or -1)
      int height
      Width of object
      int topX
      Can be seen on the screen (change to false when the brick gets hit)
      int topY
      Position - top left corner X
      boolean visible
      state variables for a game object
      int width
      position - top left corner Y
    • Constructor Summary

      Constructors 
      Constructor Description
      GameObj​(int x, int y, int w, int h, javafx.scene.paint.Color c)
      Direction Y (1, 0 or -1)
    • Field Detail

      • visible

        public boolean visible
        state variables for a game object
      • topX

        public int topX
        Can be seen on the screen (change to false when the brick gets hit)
      • topY

        public int topY
        Position - top left corner X
      • width

        public int width
        position - top left corner Y
      • height

        public int height
        Width of object
      • colour

        public javafx.scene.paint.Color colour
        Height of object
      • dirX

        public int dirX
        Colour of object
      • dirY

        public int dirY
        Direction X (1, 0 or -1)
    • Constructor Detail

      • GameObj

        public GameObj​(int x,
                       int y,
                       int w,
                       int h,
                       javafx.scene.paint.Color c)
        Direction Y (1, 0 or -1)
    • Method Detail

      • moveX

        public void moveX​(int units)
        move in x axis
      • moveY

        public void moveY​(int units)
        move in y axis
      • changeDirectionX

        public void changeDirectionX()
        change direction of movement in x axis (-1, 0 or +1)
      • changeDirectionY

        public void changeDirectionY()
        change direction of movement in y axis (-1, 0 or +1)
      • hitBy

        public boolean hitBy​(GameObj obj)
        Detect collision between this object and the argument object It's easiest to work out if they do NOT overlap, and then return the opposite