Exemplo n.º 1
0
void Protocol::ReceiveTankPosition(QByteArray array)
{
    struct PTankData *data;
    data = (struct PTankData *) array.data();
    Tank* t = scene->getTank(data->id);
    t->setPos(data->x, data->y);
    t->setRotation(data->angle);
    t->setSendValue(false);

    if(data->move_up == 1) {
        t->MoveFoward(true);
    } else {
        t->MoveFoward(false);
    }

    if(data->move_right == 1) {
        t->RotateRight(true);
    } else {
        t->RotateRight(false);
    }

    if(data->move_left == 1) {
        t->RotateLeft(true);
    } else {
        t->RotateLeft(false);
    }

    if(data->fire_on == 1) {
        t->Fire();
    }
}