Jump to content
  • Advertisement
phil67rpg

C++ win32 breakout

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

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......

Edited by fleabay

Share this post


Link to post
Share on other sites
Posted (edited)

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

Edited by Nypyren

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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;

Share this post


Link to post
Share on other sites
Posted (edited)

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);
	}

 

Edited by phil67rpg

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!