I am making a game in C++;
And I ran into a slight problem with it, as would be expected, but I can't figure it out.
*SOLVED*
Pretty much, each square meter is divided into a 100 by 100 pixel area. Each of those areas has its own temperature and whatnot. The gases move based on the temperatures, from higher to lower.
Collision checking is only done inside of each area, to make the game run faster (not really an issue right now, but). Once it leaves an area, it is supposed to transfer to the area it just entered. However, it isn't doing this.
*NOT SOLVED*
Objects move 5 times too slow.
Sorry about the strange formatting;
float time_change = delta_time / 1000.0f;
// stuff
this->x += this->x_vel * time_change;
this->y += this->y_vel * time_change;
if (((int)(this->x / 100) != this->area_x) && ((int)(this->y / 100) != this->area_y)) //if no longer in the same area, move it
{
transfer = modify.area[this->area_x][this->area_y].all[this->ID];
modify.area[this->area_x][this->area_y].all.erase(modify.area[this->area_x][this->area_y].all.begin() + this->ID);
this->area_x = this->x / 100;
this->area_y = this->y / 100;
if (((this->area_x >= 0) && (this->area_x < 15)) && ((this->area_y >= 0) && (this->area_y < 15)))
{
this->ID = modify.area[this->area_x][this->area_y].all.size();
modify.area[this->area_x][this->area_y].all.push_back(transfer);
}
else
{
//move area
}
}
if ((this->area_x >= 0) && (this->area_x < 15))
{
if ((this->area_y >= 0) && (this->area_y < 15))
{
this->ID = modify.area[this->area_x][this->area_y].all.size();
modify.area[this->area_x][this->area_y].all.push_back(transfer);
}
}
}
UPDATE 1: It likely has something to do with time_change, because if I "hold" the window, therefore increasing the time_change, it does collide properly with the object, which means it properly transferred areas.
In the same area is that objects generally move 5 times too slow, for some unknown reason.
Thanks in advance.