Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Java breakout game, multiple hits per brick ? (https://www.askmehelpdesk.com/showthread.php?t=832132)

  • May 7, 2017, 09:41 AM
    vitaliA
    Java breakout game, multiple hits per brick ?
    Hello


    I am trying to make a program as part of my assignment, a breakout game.
    There are plenty of tutorials for this game.
    However, the challenge we've been given is that one row need to have the bricks that take 3 hits before they are destroyed, the other row 2 hits per brick and last row 1 hit per brick.
    I was trying to figure out different ways to do it, though in the end I though to figure out how to identify each brick by its coordinates in order to be able to manipulate it further is the best way. Though I am not sure it is the best approach for this problem.
    Unfortunately, there is not much information about multiple hits per brick for this game out there.
    If someone can guide me or help me to figure out how to solve this problem I will be very grateful.

    What I was recommended to do is to have a hit counter property in the brick class which I used to create bricks individually.


    I have a method that calculates the intersection of a ball and a brick (by using Rectangle intersects). At the moment that method is called in a loop without anything else.
    Here I am having trouble of grabbing a brick from the array, pass it to the brick collision method and to reduce the number of hits of that particular brick.


    As I have a for loop that goes up to the length of my array, it checks one value after another. But what I need to figure out is, instead of having a loop that increments one by one, how to do it another way where I can identify what brick has been hit in the array and to reduce the number of hits in the property of that instance.

    Regards
    Vitali
  • May 7, 2017, 10:36 AM
    joypulv
    This sent me back to about 1977, the first time I played any game on a computer that was not a terminal. It was a Mac and it was breakout.

    Doesn't Java allow you assign each hit to a storage place set aside for each id, and have IF statements at each location, that return null or delete when the condition for that row is met?
    I'm thinking in Excel macros, sorry. I really don't have a clue.
  • May 7, 2017, 10:58 AM
    vitaliA
    I am not even sure what you mean. We have been studying Java for only a year and we've been given this assignment without thorough knowledge. Basically I have to learn it almost from scratch apart of the basics, thus I am really confused with all of this and in particular with my problem in the game. It took me days to figure out how everything works and to find best solution while I was trying to build it. Though I am far from understanding everything about the logic here :(
  • May 7, 2017, 12:10 PM
    joypulv
    Google 'java help boards.'

  • All times are GMT -7. The time now is 01:52 AM.