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