degats dans bullet
This commit is contained in:
		| @@ -7,11 +7,29 @@ Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_cur | ||||
|  | ||||
| Bullet::~Bullet() {} | ||||
|  | ||||
| bool Bullet::Update(World* world, float elapsedtime, int perframe) { | ||||
| bool Bullet::Update(World* world, float elapsedtime, int perframe, std::map<uint64_t, Player*> mapPlayer) { | ||||
| 	int max = 100 / perframe; | ||||
| 	float damage = 0.57f; | ||||
| 	for (int x = 0; x < max; ++x) { | ||||
| 		m_currentpos += m_velocity * elapsedtime; | ||||
|  | ||||
| 		 | ||||
| 		std::map<uint64_t, Player*>::iterator it = mapPlayer.begin(); | ||||
|  | ||||
| 		while (it != mapPlayer.end()) | ||||
| 		{ | ||||
| 			 | ||||
| 			Player* player = it->second; | ||||
| 			Vector3f playerPos = player->GetPosition(); | ||||
| 			if (playerPos == m_currentpos) | ||||
| 			{ | ||||
| 				player->InflictDamage(damage); | ||||
| 				return true; | ||||
| 			} | ||||
| 			it++; | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 		if (!world->ChunkAt(m_currentpos)) | ||||
| 			return true; | ||||
| 		else if (world->BlockAt(m_currentpos) != BTYPE_AIR) { | ||||
| @@ -20,7 +38,7 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe) { | ||||
| 		} | ||||
| 		else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true; | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user