Skip to content

Commit 5473fc0

Browse files
committed
checkborder fix
1 parent ed8472f commit 5473fc0

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

SimulationModel/Cell.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ void Cell::checkSpeed(Vect2D<float>& speed)
7373

7474
void Cell::checkBorder()
7575
{
76-
if (position.x >= parentField->fieldSize.x) {
76+
if (position.x >= parentField->fieldSize.x - this->size / 2) {
7777
position.x = (parentField->fieldSize.x - 1) - this->size / 2;
78-
speed.x = -0.5;
78+
speed.x = -0.2 * speed.x;
7979
};
80-
if (position.y >= parentField->fieldSize.y) {
80+
if (position.y >= parentField->fieldSize.y - this->size / 2) {
8181
position.y = (parentField->fieldSize.y - 1) - this->size / 2;
82-
speed.y = -0.5;
82+
speed.y = -0.2 * speed.y;
8383
};
84-
if (position.x < 0) {
84+
if (position.x < 0 + this->size / 2) {
8585
position.x = 0 + this->size / 2;
86-
speed.x = 0.5;
86+
speed.x = -0.2 * speed.x;
8787
};
88-
if (position.y < 0) {
88+
if (position.y < 0 + this->size / 2) {
8989
position.y = 0 + this->size / 2;
90-
speed.y = 0.5;
90+
speed.y = -0.2 * speed.y;
9191
};
9292
}
9393

0 commit comments

Comments
 (0)