Advertisement

win32 breakout

Started by July 05, 2019 10:15 PM
31 comments, last by jbadams 5 years, 5 months ago

I have very simple question. how do I black out a brick when  the ball hits it, I want the ball to bounce off the brick and then erase the brick and the next time I want the ball to pass through where the brick was at. I am doing this game in win32 because I want to get good at direct x , this a launching platform.

There are plenty of Breakout tutorials on the web that will walk you through step-by-step. Why are you not using them?

Also, you have a thread from 3 or so months ago that answered this question over and over and over......

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

Advertisement

You know how you have code which draws the brick and checks if the ball hits it?  Stop doing that.

13 hours ago, Nypyren said:

You know how you have code which draws the brick and checks if the ball hits it?  Stop doing that.

can you explain what to do more specifically.

foreach (brick in bricks) draw brick;

if (brick is hit) bounce ball and remove brick from bricks;

or

foreach (place where a brick could be) if (a brick exists there) draw it;

if (ball reaches place and brick is there) bounce ball and remove brick from place;

here is my code for drawing bricks,should I make changes to it?  I was thinking about  using a list for my bricks.


	for(int i=0; i<=725;i+=225)
	{
	DrawBitmap_one("red.bmp", i, 200);
	}
	for(int i=75; i<=725;i+=225)
	{
	DrawBitmap_two("green.bmp", i, 200);
	}
	for(int i=150; i<=725;i+=225)
	{
	DrawBitmap_three("blue.bmp", i, 200);
	}

	for(int i=0; i<=725;i+=225)
	{
	DrawBitmap_two("green.bmp", i, 165);
	}
	for(int i=75; i<=725;i+=225)
	{
	DrawBitmap_three("blue.bmp", i, 165);
	}
	for(int i=150; i<=725;i+=225)
	{
	DrawBitmap_one("red.bmp", i, 165);
	}

	for(int i=0; i<=725;i+=225)
	{
	DrawBitmap_three("blue.bmp", i, 130);
	}
	for(int i=75; i<=725;i+=225)
	{
	DrawBitmap_one("red.bmp", i, 130);
	}
	for(int i=150; i<=725;i+=225)
	{
	DrawBitmap_two("green.bmp", i, 130);
	}

 

Advertisement

Since bricks may disappear during the game, you need a value for each brick that says whether it (still) exists. If a value for a brick says "brick doesn't exist", you skip drawing that brick.

Alongside a list of bricks, you could have a list of such values.

so I should use a list?

Yiou're coding in c++ right? List would work, a vector would also work. There are a few differences between both, but I don't think you should worry about that at this stage. Whatever you prefer is fine.

If you're coding C#, then definitely a list.

I am coding in c++,  should I use a list or a vector?

This topic is closed to new replies.

Advertisement