Hi,
I am a starting to learn to code with DirectX in C++, and have hit a bug for which I am unable to find a solution.
In this part of my code, I am attempting to fill a vector of objects (models with x,y,z positions, rotations and scaling) to create a 2D map of square tiles (First block of code).
Once these have been put in the vector, I call a loop to render the objects one by one.
After using the debugger, I can assure you that the X and Y values are correct at the rendering stage, and that all tiles have a pointer to their respective model.
In order to try to debug this problem, I have added a piece of code to make it so that squares with even X values are stones, and squares with odd X values are grass.
In the image #1, I have changed the values of my loop so that the map tiles X and Y values have an interval of [-4,3].
In the image #2, I have changed the values of my loop so that the map tiles X and Y values have an interval of [-3,3].
I have also tried increasing the jump in my loops so that they increase by 2 each time, but it didn't fix the issue.
Looking at this problem, I can only think that I am missing a key piece of information about DirectX that is causing this bug.
Thank you for your time.
EDIT:
In the event that somebody would like to have a look at the full code, my project is on Github.
The crucial pieces of information are (I think) in the WorldClass Initialize() function, or in the GraphicsClass Render() function.
https://github.com/Zilmerx/GameProjectFinal
Code #1 :
// Test #2.
for (int y = -3; y <= 3; y++) // -3 to 3, 7 values.
{
for (int x = -3; x <= 3; x++) // -3 to 3, 7 values.
{
std::unique_ptr<ObjectClass> obj;
if (x % 2 == 0) // Is Even
{
obj = std::make_unique<ObjectClass>(model1);
}
else // Is Odd
{
obj = std::make_unique<ObjectClass>(model2);
}
obj->SetPosition(x, y);
obj->Initialize();
m_Map.push_back(std::move(obj));
}
}
Image #1
Image #2