{"id":979,"date":"2010-05-13T14:32:42","date_gmt":"2010-05-13T14:32:42","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=979"},"modified":"2011-01-14T13:56:14","modified_gmt":"2011-01-14T13:56:14","slug":"breakout-part-2","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/05\/13\/breakout-part-2\/","title":{"rendered":"Breakout &#8211; Part 2"},"content":{"rendered":"<p><span id=\"zipfile\"><a href='http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/Assignment3_Code.zip'><\/a><\/span>Breakout &#8211; Part 2, I have broken it down into 2 parts because of the size of the source code and also the post in general, the first is the problem and solution and this is the solution in code and images. <\/p>\n<p>Here is the screen output of the start of the game.<\/p>\n<figure id=\"attachment_981\" aria-describedby=\"caption-attachment-981\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout1.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout1.jpg\" alt=\"Breakout  - the start\" title=\"breakout1\" width=\"400\" height=\"600\" class=\"size-medium wp-image-981\" \/><\/a><figcaption id=\"caption-attachment-981\" class=\"wp-caption-text\">Breakout  - the start<\/figcaption><\/figure>\n<p>Here is the screen output of the extra life coming down the screen, (the one in grey!!) and also the ball as well, can you catch them both ?<\/p>\n<figure id=\"attachment_982\" aria-describedby=\"caption-attachment-982\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout2.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout2.jpg\" alt=\"Breakout - extra life coming down\" title=\"breakout2\" width=\"400\" height=\"600\" class=\"size-medium wp-image-982\" \/><\/a><figcaption id=\"caption-attachment-982\" class=\"wp-caption-text\">Breakout - extra life coming down<\/figcaption><\/figure>\n<p>And here is the end of the game with the display information about how much you have scored.<\/p>\n<figure id=\"attachment_983\" aria-describedby=\"caption-attachment-983\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout3.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/breakout3.jpg\" alt=\"Breakout - the end\" title=\"breakout3\" width=\"400\" height=\"600\" class=\"size-medium wp-image-983\" \/><\/a><figcaption id=\"caption-attachment-983\" class=\"wp-caption-text\">Breakout - the end<\/figcaption><\/figure>\n<p>Here is the full source code from the break out assignment 3, I have included it in the zip file above and also the PDF of the assignment.<\/p>\n<pre lang=\"java\">\r\n\/*\r\n * File: Breakout.java\r\n * -------------------\r\n * Name:\r\n * Section Leader:\r\n * \r\n * This file will eventually implement the game of Breakout.\r\n *\/\r\n\r\nimport acm.graphics.*;\r\nimport acm.program.*;\r\nimport acm.util.*;\r\n\r\nimport java.applet.*;\r\nimport java.awt.*;\r\nimport java.awt.event.*;\r\n\r\npublic class Breakout extends GraphicsProgram implements MouseListener {\r\n\r\n\/** Width and height of application window in pixels *\/\r\n\tpublic static final int APPLICATION_WIDTH = 400;\r\n\tpublic static final int APPLICATION_HEIGHT = 600;\r\n\r\n\/** Dimensions of game board (usually the same) *\/\r\n\tprivate static final int WIDTH = APPLICATION_WIDTH;\r\n\tprivate static final int HEIGHT = APPLICATION_HEIGHT;\r\n\r\n\/** Dimensions of the paddle *\/\r\n\tprivate static final int PADDLE_WIDTH = 60;\r\n\tprivate static final int PADDLE_HEIGHT = 10;\r\n\r\n\/** Offset of the paddle up from the bottom *\/\r\n\tprivate static final int PADDLE_Y_OFFSET = 30;\r\n\r\n\/** Number of bricks per row *\/\r\n\tprivate static final int NBRICKS_PER_ROW = 10;\r\n\r\n\/** Number of rows of bricks *\/\r\n\tprivate static final int NBRICK_ROWS = 10;\r\n\r\n\/** Separation between bricks *\/\r\n\tprivate static final int BRICK_SEP = 4;\r\n\r\n\/** Width of a brick *\/\r\n\tprivate static final int BRICK_WIDTH =\r\n\t  (WIDTH - (NBRICKS_PER_ROW - 1) * BRICK_SEP) \/ NBRICKS_PER_ROW;\r\n\r\n\/** Height of a brick *\/\r\n\tprivate static final int BRICK_HEIGHT = 8;\r\n\r\n\/** Radius of the ball in pixels *\/\r\n\tprivate static final int BALL_RADIUS = 10;\r\n\r\n\/** Offset of the top brick row from the top *\/\r\n\tprivate static final int BRICK_Y_OFFSET = 70;\r\n\r\n\/** Number of turns *\/\r\n\tprivate static final int NTURNS = 3;\r\n\r\n\t\/** the starting pause delay between paddle hits **\/ \r\n\tprivate static final int PAUSE_DELAY = 20;\r\n\t\/** text size of the display text *\/\r\n\tprivate static final int TEXT_SIZE = 5;\r\n\t\/** ball speed *\/\r\n\tprivate static final double BALL_SPEED = 3.0;\r\n\t\/** extras - if you catch the extra score, this is the extra value *\/\r\n\tprivate static final int EXTRA_SCORE_VALUE = 100;\r\n\t\/** extras speed coming down the screen *\/\r\n\tprivate static final double EXTRAS_SPEED = 3.0;\r\n\t\r\n\tpublic void mouseMoved(MouseEvent e)\r\n\t{\r\n\t\tPoint movePos = e.getPoint();\r\n\t\tif (movePos.x < (WIDTH- PADDLE_WIDTH))\r\n\t\t\tpaddleObject.setLocation(movePos.x,HEIGHT - (PADDLE_Y_OFFSET + PADDLE_HEIGHT));\r\n\t}\r\n\t\r\n\t\/\/ setup the bricks, with different colours\r\n\tprivate void CreateBricks()\r\n\t{\r\n\/\/ if there is any more colours, rows or less then this could be a problem of creating the list of colours.\r\n\t\tcolours[0] = Color.RED;\r\n\t\tcolours[1] = Color.RED;\r\n\t\tcolours[2] = Color.ORANGE;\r\n\t\tcolours[3] = Color.ORANGE;\r\n\t\tcolours[4] = Color.YELLOW;\r\n\t\tcolours[5] = Color.YELLOW;\r\n\t\tcolours[6] = Color.GREEN;\r\n\t\tcolours[7] = Color.GREEN;\r\n\t\tcolours[8] = Color.CYAN;\r\n\t\tcolours[9] = Color.CYAN;\r\n\t\t\r\n\t\tint startX, startY = BRICK_Y_OFFSET;\r\n\t\tGRect bricks;\r\n\t\t\/\/ iRow = going downwards\r\n\t\tfor (int iRow =0; iRow < NBRICK_ROWS; iRow++)\r\n\t\t{\r\n\t\t\tstartX = BRICK_SEP;\r\n\t\t\t\/\/ iAisle = going across\r\n\t\t\tfor (int iAisle = 0; iAisle < NBRICKS_PER_ROW; iAisle++)\r\n\t\t\t{\r\n\t\t\t\tbricks = new GRect(startX,startY, BRICK_WIDTH,BRICK_HEIGHT);\r\n\t\t\t\tbricks.setFillColor(colours[iRow]);\r\n\t\t\t\tbricks.setFilled(true);\r\n\t\t\t\tbricks.setColor(colours[iRow]);\r\n\t\t\t\tadd(bricks);\r\n\t\t\t\tstartX += BRICK_WIDTH + BRICK_SEP;\r\n\t\t\t}\r\n\t\t\tstartY += BRICK_HEIGHT + BRICK_SEP;\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate void addPaddle()\r\n\t{\r\n\t\tpaddleObject = new GRect((WIDTH\/2) - (PADDLE_WIDTH\/2), HEIGHT - (PADDLE_Y_OFFSET + PADDLE_HEIGHT),\r\n\t\t\t\t\t\t\t\tPADDLE_WIDTH, PADDLE_HEIGHT);\r\n\t\tpaddleObject.setColor(Color.BLACK);\r\n\t\tpaddleObject.setFillColor(Color.BLACK);\r\n\t\tpaddleObject.setFilled(true);\r\n\t\tadd(paddleObject);\r\n\t}\r\n\t\r\n\tprivate void setUpBall()\r\n\t{\r\n\t\t\/\/ middle !!\r\n\t\tballX = WIDTH \/ 2;\r\n\t\tballY = HEIGHT \/ 2;\r\n\t\t\/\/ ballVX \/ VY are the velocity of movement \r\n\t\tballObject = new GOval(ballX, ballY, BALL_RADIUS, BALL_RADIUS);\r\n\t\tballObject.setFillColor(Color.BLACK);\r\n\t\tballObject.setFilled(true);\r\n\t\tadd(ballObject);\r\n\t\t\/\/ setup the ball to move a random direction\r\n\t\tballVX = rgen.nextDouble(1.0, 3.0);\r\n\t\tif (rgen.nextBoolean(0.5)) ballVX -= ballVX;\r\n\t\tballVY = BALL_SPEED;\r\n\t}\r\n\r\n\t\/\/ move the ball and check for collision around the screen, if gone to the bottom return true else false\r\n\tprivate Boolean moveBall()\r\n\t{\r\n\t\tGPoint ballPoint = ballObject.getLocation();\r\n\t\tif (ballPoint.getX() > WIDTH) ballVX = -ballVX;\r\n\t\tif (ballPoint.getX() <= 0) ballVX = -ballVX;\r\n\t\tif (ballPoint.getY() <= 0) ballVY = -ballVY;\r\n\t\tif (ballPoint.getY() > HEIGHT) return true;\/\/ballVY = -ballVY; \/\/ basically lost\r\n\t\tballObject.move(ballVX,ballVY);\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\t\/\/ get any Graphics Object surrounding the ball Object, be it the bat and ball, or bat and extras\r\n\tprivate GObject getCollidingObject(GObject ballObj)\r\n\t{\r\n\t\tif (!ballObj.isVisible()) return null;\r\n\t\tGPoint ballPoint = ballObj.getLocation();\r\n\t\tGObject coll;\r\n\t\tPoint addingPoints[] = new Point[4];\r\n\t\taddingPoints[0]= new Point(0,0);\r\n\t\taddingPoints[1]= new Point(0,BALL_RADIUS);\r\n\t\taddingPoints[2]= new Point(BALL_RADIUS,BALL_RADIUS);\r\n\t\taddingPoints[3]= new Point(BALL_RADIUS,0);\r\n\t\tfor (int i =0; i< 4; i++)\r\n\t\t{\r\n\t\t\tcoll = getElementAt(ballPoint.getX()+addingPoints[i].x, ballPoint.getY()+addingPoints[i].y);\r\n\t\t\tif (coll != null)\r\n\t\t\t\t\treturn coll;\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\t\/\/ display the text on the screen to give some information.\r\n\tprivate void displayText(String text)\r\n\t{\r\n\t\ttextDisplay = new GLabel(text,(WIDTH\/2 - (text.length() * TEXT_SIZE)), HEIGHT\/2);\r\n\t\ttextDisplay.setFont(Font.SANS_SERIF);\r\n\t\tadd(textDisplay);\r\n\t}\r\n\r\n\t\/\/ display the status , score and also lives left\r\n\tprivate void displayStatus()\r\n\t{\r\n\t\tif (status != null) remove(status);\r\n\t\tstatus = new GLabel(\"Score : \"+score +\" : Lives : \"+lifesLeft,WIDTH\/2, (BRICK_HEIGHT*2));\r\n\t\tadd(status);\r\n\t}\r\n\t\r\n\t\/\/ difference between two points.\r\n\tprivate GPoint differenceBetween(GPoint a, GPoint b)\r\n\t{\r\n\t\treturn new GPoint(a.getX() - b.getX(), a.getY() - b.getY());\r\n\t}\r\n\r\n\t\/\/ type = true - extra life, false - extra score (+100) \r\n\tprivate void generateExtra(Boolean type, GObject startingPoint)\r\n\t{\r\n\t\tif (type)\r\n\t\t{\r\n\t\t\t\/\/ create a extraLife object if not one already\r\n\t\t\textraLife.setLocation(startingPoint.getX(), startingPoint.getY());\r\n\t\t\textraLife.setColor(Color.MAGENTA);\r\n\t\t\textraLife.setFilled(true);\r\n\t\t\textraLife.setVisible(true);\r\n\t\t\tadd(extraLife);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t\/\/ create a extraScore object if not one already\r\n\t\t\textraScore.setLocation(startingPoint.getX(), startingPoint.getY());\r\n\t\t\textraScore.setColor(Color.GRAY);\r\n\t\t\textraScore.setFilled(true);\r\n\t\t\textraScore.setVisible(true);\r\n\t\t\tadd(extraScore);\r\n\t\t}\r\n\t}\r\n\t\r\n\t\/* move the extraLife\/Score if they are visible.*\/\r\n\tprivate void moveExtras()\r\n\t{\r\n\t\tif (extraLife.isVisible())\r\n\t\t{\r\n\t\t\textraLife.move(0, EXTRAS_SPEED);\r\n\t\t\tif (extraLife.getLocation().getY() > HEIGHT) remove(extraLife);\r\n\t\t}\r\n\t\tif (extraScore.isVisible())\r\n\t\t{\r\n\t\t\textraScore.move(0,EXTRAS_SPEED);\r\n\t\t\tif (extraScore.getLocation().getY() > HEIGHT) remove(extraScore);\r\n\t\t}\r\n\t}\r\n\/* Method: run() *\/\r\n\/** Runs the Breakout program. *\/\r\n\tpublic void run() {\r\n\t\t\/* You fill this in, along with any subsidiary methods *\/\r\n\t\tgetGCanvas().setSize(WIDTH, HEIGHT);\r\n\t\tGObject colliding;\r\n\t\tAudioClip bounceSound = MediaTools.loadAudioClip(\"bounce.au\");\r\n\t\tBoolean bottomHit, emptyBricks = true;\r\n\t\tint bricksLeft=0, paddleHit, randomExtra;\r\n\t\t\r\n\t\textraLife = new GOval(0, 0, BALL_RADIUS,BALL_RADIUS);\r\n\t\textraScore = new GOval(0,0, BALL_RADIUS, BALL_RADIUS);\r\n\t\tscore = 0;\r\n\t\tlifesLeft = NTURNS;\r\n\t\tpauseDelay = PAUSE_DELAY;\r\n\t\t\/\/ loop through for the amount of lives\r\n\t\twhile (lifesLeft > 0)\r\n\t\t{\r\n\t\t\t\/* setup the display and then ask the user to click to start *\/\r\n\t\t\t\r\n\t\t\tif (emptyBricks)\r\n\t\t\t{\r\n\t\t\t\t\/* clear the screen and rebuild the bricks, if come to the end of that level, or just starting*\/\r\n\t\t\t\tremoveAll();\r\n\t\t\t\tbricksLeft = NBRICKS_PER_ROW * NBRICK_ROWS;\r\n\t\t\t\tCreateBricks();\r\n\t\t\t\taddPaddle();\r\n\t\t\t\taddMouseListeners();\r\n\t\t\t\temptyBricks = false;\r\n\t\t\t}\r\n\t\t\tdisplayText(\"Click to start\");\r\n\t\t\tdisplayStatus();\r\n\t\t\twaitForClick();\r\n\t\t\tremove(textDisplay);\r\n\t\t\tsetUpBall();\r\n\t\t\tpaddleHit =0;\r\n\t\t\tbottomHit =false;\r\n\t\t\trandomExtra = rgen.nextInt(5);\r\n\t\t\t\/* end of setup display*\/\r\n\t\t\twhile (true)\r\n\t\t\t{\r\n\t\t\t\t\/\/ moveBall returns true if the bottom has been hit.\r\n\t\t\t\tif (moveBall()) {\r\n\t\t\t\t\tbottomHit = true;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tmoveExtras();\r\n\t\t\t\tcolliding = getCollidingObject(ballObject);\r\n\t\t\t\t\/\/ if the ball has collided with anything\r\n\t\t\t\tif (colliding != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!colliding.equals(paddleObject))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (!colliding.equals(status))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (randomExtra <=0)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\trandomExtra = rgen.nextInt(5);\r\n\t\t\t\t\t\t\t\t\/\/ create a extra life if next random extra is even else extra score\r\n\t\t\t\t\t\t\t\tif ((randomExtra % 2)==0)\r\n\t\t\t\t\t\t\t\t\tgenerateExtra(true,colliding);\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\tgenerateExtra(false,colliding);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\/\/ delete the object that we just collided with, e.g. the brick\r\n\t\t\t\t\t\t\tif (colliding.getClass().getSimpleName().equalsIgnoreCase(\"GRect\"))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\/\/ decrement the randomExtra \r\n\t\t\t\t\t\t\t\trandomExtra--;\r\n\t\t\t\t\t\t\t\t\/\/ increment the score by finding out the colour of brick that we hit.\r\n\t\t\t\t\t\t\t\tColor collidColor = colliding.getColor();\r\n\t\t\t\t\t\t\t\tfor (int i = (NBRICK_ROWS-1); i > 0; i--)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tscore++;\r\n\t\t\t\t\t\t\t\t\tif (colours[i] == collidColor) break;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tdisplayStatus();\r\n\t\t\t\t\t\t\t\tremove(colliding);\r\n\t\t\t\t\t\t\t\t\/* if no more bricks.. exit *\/\r\n\t\t\t\t\t\t\t\tbricksLeft--;\r\n\t\t\t\t\t\t\t\tif (bricksLeft == 0) \r\n\t\t\t\t\t\t\t\t{ \r\n\t\t\t\t\t\t\t\t\temptyBricks = true; \r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\/*\/\/another way of checking to see if there is any GRects left.!!.\r\n\t\t\t\t\t\t\t\temptyBricks = true;\r\n\t\t\t\t\t\t\t\tfor (int i =0; i < getElementCount(); i++)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (getElement(i).getClass().getSimpleName().equalsIgnoreCase(\"GRect\"))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (!getElement(i).getClass().equals(paddleObject))\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\temptyBricks= false;\r\n\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (emptyBricks) break;\r\n\t\t\t\t\t\t\t\t *\/\r\n\t\t\t\t\t\t\t\tballVY = -ballVY;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\/\/ handle the increase of speed (less delay)\r\n\t\t\t\t\t\tpaddleHit++;\r\n\t\t\t\t\t\tif ((paddleHit % 7) ==0) pauseDelay--;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tbounceSound.play();\r\n\t\t\t\t\t\tGPoint difBetween = differenceBetween(ballObject.getLocation(), colliding.getLocation());\r\n\t\t\t\t\t\tballVX = (difBetween.getX() - (PADDLE_WIDTH\/2))\/2;\r\n\t\t\t\t\t\tballVY = -(difBetween.getY()\/BALL_SPEED);\r\n\t\t\t\t\t\t\/\/ for when the ball may try and bounce of the side of the bat and then the wall!!.\r\n\t\t\t\t\t\tif (ballVY == 0.0) ballVY = 1.0;\r\n\t\t\t\t\t\t\/\/ move in the opposite direction\r\n\t\t\t\t\t\tballVY = -ballVY;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\/* extra items *\/\r\n\t\t\t\tcolliding = getCollidingObject(extraLife);\r\n\t\t\t\tif (colliding != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (colliding.equals(paddleObject))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\textraLife.setVisible(false);\r\n\t\t\t\t\t\tlifesLeft++;\r\n\t\t\t\t\t\tdisplayStatus();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcolliding = getCollidingObject(extraScore);\r\n\t\t\t\tif (colliding != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (colliding.equals(paddleObject))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\textraScore.setVisible(false);\r\n\t\t\t\t\t\tscore+=EXTRA_SCORE_VALUE;\r\n\t\t\t\t\t\tdisplayStatus();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tpause(pauseDelay);\r\n\t\t\t}\r\n\t\t\tif (bottomHit) \r\n\t\t\t{\r\n\t\t\t\tlifesLeft--;\r\n\t\t\t\tdisplayStatus();\r\n\t\t\t\tif (lifesLeft > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tdisplayText(\"Bottom hit : lives left = \" + lifesLeft);\r\n\t\t\t\t}\r\n\t\t\t\telse \r\n\t\t\t\t\tdisplayText(\"End of Game : your score \" + score);\r\n\t\t\t}\r\n\t\t\tif (emptyBricks)\r\n\t\t\t\tdisplayText(\"Yeppy you do it!! click to start again\");\r\n\t\t\twaitForClick();\r\n\t\t\tremove(textDisplay);\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate GRect paddleObject;\r\n\tprivate GOval ballObject, extraScore, extraLife;\r\n\tprivate GLabel textDisplay, status;\r\n\tprivate double ballVX, ballVY, ballX, ballY;\r\n\tprivate int lifesLeft, score, pauseDelay;\r\n\tprivate RandomGenerator rgen = RandomGenerator.getInstance();\r\n\tprivate Color colours[] = new Color[NBRICK_ROWS];\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Breakout &#8211; Part 2, I have broken it down into 2 parts because of the size of the source code and also the post in general, the first is the problem and solution and this is the solution in code and images. Here is the screen output of the start of the game. Here is &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/05\/13\/breakout-part-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Breakout &#8211; Part 2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[210],"class_list":["post-979","post","type-post","status-publish","format-standard","hentry","category-java","tag-breakout"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=979"}],"version-history":[{"count":14,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/979\/revisions"}],"predecessor-version":[{"id":1332,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/979\/revisions\/1332"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}