Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //********************************************* Klasa Mapy ********************************************************
- //------------------------------------- Draw Entity ------------------------------------------
- void GameplayScreen::DrawEntity(SDL_Renderer * renderer)
- {
- for (int i = 0; i < vEntity.size(); i++)
- {
- for (int j = 0; j < vEntity[i].size(); j++)
- {
- vEntity[i][j]->Draw(renderer, vBlock[vEntity[i][j]->getBlockID()]->GetSprite()->getTexture());
- }
- }
- }
- //------------------------------------- Update Entity --------------------------------------------
- void GameplayScreen::UpdateEntity()
- {
- for (int i = 0; i < vEntity.size(); i++)
- {
- for (int j = 0; j < vEntity[i].size(); j++)
- {
- vEntity[i][j]->Upadate();
- }
- }
- for (int i = 0; i < vEntity.size(); i++)
- {
- for (int j = 0; j < vEntity[i].size(); j++)
- {
- if (vEntity[i][j]->entityState == -1)
- {
- delete vEntity[i][j];
- vEntity[i].erase(vEntity[i].begin() + j);
- continue;
- }
- }
- }
- }
- //----------------------------------- Dodaje broΕ ---------------------------------------------------
- void GameplayScreen::addPlayerGun(int x, int y, int moveDirection)
- {
- vEntity[4].push_back(new PlayerGun(x, y, moveDirection));
- }
- //*************************************** Klasa broni ************************************************
- PlayerGun::PlayerGun(int posX, int posY, int moveDirection)
- {
- this->posX = posY;
- this->posY = posY;
- this->moveDirection = moveDirection;
- this->moveSpeed = 6;
- this->hitBoxX = 16;
- this->hitBoxY = 16;
- this->blockID = 4;
- }
- void PlayerGun::Draw(SDL_Renderer * renderer, Texture* bulletTxt)
- {
- SDL_Rect srcRect;
- srcRect.x = (int)posX + (int)System::getManager()->GetGame()->getPosX();
- srcRect.y = (int)posY;
- srcRect.w = hitBoxX;
- srcRect.h = hitBoxY;
- bulletTxt->Draw(srcRect, renderer, !moveDirection);
- }
- void PlayerGun::Upadate()
- {
- UpdatePosX();
- }
- void PlayerGun::UpdatePosX()
- {
- if (moveDirection)
- {
- posX -= moveSpeed;
- }
- else
- {
- posX += moveSpeed;
- }
- }
- //************************************************ Dodawanie Broni do Postaci ***************************************
- void Player::CreateBullet()
- {
- if (playerGunState == 1)
- {
- System::getManager->GetGame()->addPlayerGun(posX - System::getManager->GetGame()->getPosX() + 32, posY + getHitBoxY() / 2, !moveDirection);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement