C++ using DirectX, need help with code please

I am creating a brick breaker type game, and when the ball hits the bricks the bricks aren't dissapearing (like they should once I call the target.Destroy method.

The code gets to the destroy method and it actually does change the Alpha channel of the colour to 0.0f, however when I run the game it isn't changing it for some reason.

If you want any more code just ask, new to this posting.

Any ideas why? thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//Ball.Cpp file
for each (Target target in targetRow)
  {
	  if ( target.IntersectsWith(this->boundingBox))
	  {
		  //Deal with ball's response to collision
		  this->velocity.y = this->velocity.y * -1.0f;
		  this->position.y = target.GetBottomEdge() + 1;
		  this->boundingBox.X = this->position.x;
		  this->boundingBox.Y = this->position.y;

		  //Deal with Target's response to collision
		  //Sent the Target a message to disappear - need a new method     on Target
		  target.Destroy();
	  }
  }

//Target.cpp file
//Initialize method
void Target::Initialize(wstring filePathName 
		       , ComPtr<ID3D11Device1> d3dDevice
		       , ComPtr<ID3D11DeviceContext1> d3dDeviceContext
			, Vector2 startPosition
			, Rect collison)
{
	ThrowIfFailed(
		CreateWICTextureFromFile(d3dDevice.Get(),
                d3dDeviceContext.Get(),
		filePathName.c_str(), 0, &this->texture)
		);


	this->position = startPosition;
	this->boundingBox = collison;
}

//Destroy method
void Target::Destroy()
{
	this->tint.w = 0.0f;
}

//SpriteGame.cpp file
  //Draw a row of Target sprites across the top of the screen
  //First, calculate how many 32x32 pixels sprites will fit onto the screen
  int numberOfTargets = (int)(this->windowBounds.Width / this->targetWidth);
  //Next, create this many Target objects and store them in a std::vector

  for ( int i = 0; i < numberOfTargets ; i++)
  {
    //Add a Target object to the back of the vector
    this->targetRow.push_back(Target());
    //Get a local reference to this newly added target object
    Target& target = this->targetRow.back();
    //Call the initialise method on the newly added Target object
    target.Initialize(L"Assets/Brick.png"
                      , this->d3dDevice
                      , this->d3dDeviceContext
                      , Vector2((float)(i * 32), 80.0f)
		      , Rect((float)(i * 32), 80.0f, 32.0f, 32.0f)
		      );
  }
Last edited on
Bump.
Topic archived. No new replies allowed.