breakout: bonuses in bricks, how?
I was thinking on how I can make my game of breakout more exciting when I figured I can put bonuses in bricks. For example ounce the ball destroys a brick a bonus of 200 points might be flying down. The problem is that I'm not sure how to implement this. I have a level editor that when I place a brick in a certain spot it stores the number 1 in a 2d array. Any ideas on how I can implement a bonus system into the level editor?
I don't do any game programming usually, but I'm pretty sure you can just assign some sort of marker to whatever brick (be it random or chosen) that would make either a random or set item/bonus fall down in the paddle's direction.
I don't say that would be very hard to implement.
I don't say that would be very hard to implement.
You could give your array another depth ([x][y] for existance, non existance, and [z] for triggers). 0th depth could be existance, 1st depth could be points, 2nd depth could be special items, etc.
Or you could use some sort of random generator in realtime. Nobody would really notice, and it would add more excitement and replayability.
Or you could use some sort of random generator in realtime. Nobody would really notice, and it would add more excitement and replayability.
Instead of storing an 2D array of ints, you could use a 1D array of structs which hold all kinds of properties for your tiles. By doing this you can extend the tiles any way you like and you're also not bound to a fixed grid.
Something like this:
Something like this:
struct s_tile { int x,y; int type; int bonusitems; bool CheckCollision();};std::vector<s_tile> Tiles;
There's no need to 'mark' a brick as containing a bonus. Each time a brick is broken you can generate an evenly distributed random number between say 1 and 100, if the number is less than the percentage of bricks you want to have bonuses then the brick has a bonus.
AND you could assign different probabilities of getting each bonus to each different brick color, thus no need for extra data ('cept for a separate table of colors/probabilities). This will give the player clues as to which bricks may contain stuff.
Note, if you were to tag each individual brick with a bonus, another matrix dimension is overkill since that will give you brick[x][y][z] and what you want is two values per [x][y]. Sure, you could only allocate for z=0 and z=1 but....better just make a matrix of structs, and store whatever data you want for each brick, like mentioned above. And bonus! you can mix datatypes.
Note, if you were to tag each individual brick with a bonus, another matrix dimension is overkill since that will give you brick[x][y][z] and what you want is two values per [x][y]. Sure, you could only allocate for z=0 and z=1 but....better just make a matrix of structs, and store whatever data you want for each brick, like mentioned above. And bonus! you can mix datatypes.
Aside from creating the struct mentioned above, just assign ints to a 2d array so that 0 = brick cleared, 1 = normal brick, 50 = 50 point brick, etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement