void DrawMinimap() { D3DCOLOR MapColor = D3DCOLOR_ARGB(255, 0, 0, 0); D3DCOLOR TrashColor = D3DCOLOR_ARGB(255, 255, 0, 0); D3DCOLOR PlayerColor = D3DCOLOR_ARGB(255, 0, 0, 255); RECT mapRect; mapRect.left=0; mapRect.right=100; mapRect.top=0; mapRect.bottom=100; D3DXVECTOR3 mapPos(25, 25, 0); spriteMap->Begin(NULL); spriteMap->Draw(texMap, &mapRect, NULL, &mapPos, MapColor); spriteMap->End(); mapRect.left=0; mapRect.right=10; mapRect.top=0; mapRect.bottom=10; D3DXVECTOR3 playerPos(TheCamera.GetPosition().x / 4 + 75,TheCamera.GetPosition().z / 4 + 75, 0 ); D3DXVECTOR3 pcenter(5, 5, 0); spritePlayer->Begin(NULL); spritePlayer->Draw(texMap, &mapRect, &pcenter, &playerPos, PlayerColor); spritePlayer->End(); mapRect.left=0; mapRect.right=5; mapRect.top=0; mapRect.bottom=5; D3DXVECTOR3 trashPos; D3DXVECTOR3 tcenter(2.5, 2.5, 0); for(int i = 0; i < 10; i++) { if(BoolTrash[i]) { trashPos.x = TrashPositions[i].x / 4 + 75; trashPos.y = TrashPositions[i].z / 4 + 75; trashPos.z = 0; spriteTrash[i]->Begin(NULL); spriteTrash[i]->Draw(texMap, &mapRect, &tcenter, &trashPos, TrashColor); spriteTrash[i]->End(); } } }
Bullet* Cannon::Shoot(Enemy *enemy, long elapsed) { if (elapsed - lastshot < shotinterval) return 0; int xa = this->pixmap.size().width() - this->SizeX; int ya = this->pixmap.size().height() - this->SizeY; QVector2D tcenter(center.x() - xa * 0.5, center.y() - ya * 0.5); QVector2D target = GetInterSect(enemy->center, enemy->next_checkpoint, Bullet::speed, Enemy::speed, tcenter, enemy->center); if (target.isNull()) target = GetInterSect2((enemy->center - enemy->next_checkpoint).length(), enemy->next_checkpoint, enemy->next_checkpoint2, Bullet::speed, Enemy::speed, tcenter, enemy->center); if (target.isNull() || (this->center - target).length() > this->range) return 0; lastshot = elapsed; Bullet*b = new Bullet(tcenter, target, elapsed, QPixmap("bullet.png")); b->enemy = enemy; return b; }