Class GameObj
- java.lang.Object
-
- GameObj
-
public class GameObj extends Object
-
-
Field Summary
Fields Modifier and Type Field Description javafx.scene.paint.ColorcolourHeight of objectintdirXColour of objectintdirYDirection X (1, 0 or -1)intheightWidth of objectinttopXCan be seen on the screen (change to false when the brick gets hit)inttopYPosition - top left corner Xbooleanvisiblestate variables for a game objectintwidthposition - 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeDirectionX()change direction of movement in x axis (-1, 0 or +1)voidchangeDirectionY()change direction of movement in y axis (-1, 0 or +1)booleanhitBy(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 oppositevoidmoveX(int units)move in x axisvoidmoveY(int units)move in y axis
-
-
-
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)
-
-
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
-
-