- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
void Snake::turnSnake(const int key)
{
QPoint pos = components_of_snake.last().topLeft();
QPoint temp = pos;
bool wasTurned = false;
if((key == Qt::Key_Right) && (side_turn != LEFT))
{
side_turn = RIGHT;
pos.rx() += SIZE_OF_COMPONENT;
wasTurned = true;
}
else if((key == Qt::Key_Left) && (side_turn != RIGHT))
{
side_turn = LEFT;
pos.rx() -= SIZE_OF_COMPONENT;
wasTurned = true;
}
else if((key == Qt::Key_Up) && (side_turn != DOWN))
{
side_turn = UP;
pos.ry() -= SIZE_OF_COMPONENT;
wasTurned = true;
}
else if((key == Qt::Key_Down) && (side_turn != UP))
{
side_turn = DOWN;
pos.ry() += SIZE_OF_COMPONENT;
wasTurned = true;
}
if(wasTurned)
{
components_of_snake.last().moveTo(pos);
_cathUpHead(temp);
}
}
guest 26.09.2014 02:24 # 0
guest 26.09.2014 20:56 # −2
guest 26.09.2014 21:45 # −1
guest 30.09.2014 20:17 # −2