void CGameMessage::update(float dt) { showScore(); showHp(); showLife(); showMissile(); }
void manageMissiles() { if (!proj.present) return; struct timeval now; gettimeofday(&now, NULL); int x = proj.x, y = proj.y; int elapsed_time = time_diff(now, proj.shootTime); int distance_travelled = elapsed_time * projectile_speed; if (proj.direction == 0) x += distance_travelled; else if (proj.direction == 1) x -= distance_travelled; else if (proj.direction == 2) y += distance_travelled; else if (proj.direction == 3) y -= distance_travelled; if (MY_X_LOC == x && MY_Y_LOC == y) return; if (M->maze_[x][y]) { // hit wall clearProjectile(); return; } for (int i = 0; i < 8; i++) { if (M->mazeRats_[i].playing && M->mazeRats_[i].x.value() == x && y == M->mazeRats_[i].y.value()) { MW244BPacket p; makePacket(&p,'a',Mapping_indexToId.find(i)->second, updateSeqNo); proj.prev_x = x; proj.prev_y = y; sendPacketToPlayers(p); updateSeqNo = false; checkingzero = 0; RatIndexType ratId(i); kills = Mapping_indexToId.find(i)->second; clearProjectile(); M->scoreIs( M->score().value() + 11 ); UpdateScoreCard(0); DrawString("You have tagged a player!",25,200,250); ClearRatPosition(ratId); } } if (proj.prev_x == 0 && proj.prev_y == 0) proj.prev_x = proj.prev_y = 1; showMissile(x, y, proj.direction, proj.prev_x, proj.prev_y, true); proj.prev_x = x; proj.prev_y = y; if (updateSeqNo && join) { MW244BPacket p; makePacket(&p,'t',-1, updateSeqNo); sendPacketToPlayers(p); } }