diff --git a/SQCSim-common/bullet.cpp b/SQCSim-common/bullet.cpp
index 52824d5..5c4e6c4 100644
--- a/SQCSim-common/bullet.cpp
+++ b/SQCSim-common/bullet.cpp
@@ -1,10 +1,9 @@
#include "bullet.h"
#include "world.h"
-Bullet::Bullet(Player& player) {
- m_startpos = m_currentpos = player.GetPOV() + player.GetDirection();
- m_velocity = player.GetDirection();
-}
+Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {}
+
+Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_tid(tid) {}
Bullet::~Bullet() {}
@@ -31,6 +30,10 @@ void Bullet::Transpose(int& x, int& z) {
m_startpos.z -= z * CHUNK_SIZE_Z;
}
-Vector3f& Bullet::getPos() {
+Vector3f Bullet::getPos() {
return m_currentpos;
}
+
+uint64_t Bullet::getTeamID(){
+ return m_tid;
+}
diff --git a/SQCSim-common/bullet.h b/SQCSim-common/bullet.h
index 599eab6..d17000e 100644
--- a/SQCSim-common/bullet.h
+++ b/SQCSim-common/bullet.h
@@ -1,23 +1,26 @@
#ifndef BULLET_H__
#define BULLET_H__
-
-#include "player.h"
+#include "define.h"
+#include "vector3.h"
class World;
class Bullet {
public:
- Bullet(Player& player);
+ Bullet(Vector3f pos, Vector3f dir);
+ Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
~Bullet();
bool Update(World* world, float elapsedtime);
void Transpose(int& x, int& z);
- Vector3f& getPos();
+ Vector3f getPos();
+ uint64_t getTeamID();
private:
- Vector3f m_startpos;
- Vector3f m_currentpos;
- Vector3f m_velocity;
+ Vector3f m_startpos,
+ m_currentpos,
+ m_velocity;
+ uint64_t m_tid = 0;
};
#endif // BULLET_H__
diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj
index 005bcc5..02c2b51 100644
--- a/SQCSim2021/SQCSim2021.vcxproj
+++ b/SQCSim2021/SQCSim2021.vcxproj
@@ -20,7 +20,6 @@
-
@@ -38,7 +37,6 @@
-
diff --git a/SQCSim2021/SQCSim2021.vcxproj.filters b/SQCSim2021/SQCSim2021.vcxproj.filters
index ec7b7d6..0e371d0 100644
--- a/SQCSim2021/SQCSim2021.vcxproj.filters
+++ b/SQCSim2021/SQCSim2021.vcxproj.filters
@@ -56,9 +56,6 @@
Fichiers d%27en-tête
-
- Fichiers d%27en-tête
-
@@ -106,8 +103,5 @@
Fichiers sources
-
- Fichiers sources
-
\ No newline at end of file
diff --git a/SQCSim2021/bullet.cpp b/SQCSim2021/bullet.cpp
deleted file mode 100644
index 38f4901..0000000
--- a/SQCSim2021/bullet.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "bullet.h"
-#include "world.h"
-
-Bullet::Bullet(Player& player) {
- m_startpos = m_currentpos = player.GetPOV() + player.GetDirection();
- m_velocity = player.GetDirection();
-}
-
-Bullet::~Bullet() {}
-
-bool Bullet::Update(World* world, Transformation& tran, float elapsedtime) {
- for (int x = 0; x < 1000; ++x) {
- m_currentpos += m_velocity * elapsedtime;
-
- if (!world->ChunkAt(m_currentpos))
- return true;
- else if (world->BlockAt(m_currentpos) != BTYPE_AIR) {
- world->ChangeBlockAtPosition(BTYPE_AIR, m_currentpos);
- return true;
- }
- else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true;
- }
-
- return false;
-}
-
-void Bullet::Transpose(int& x, int& z) {
- m_currentpos.x -= x * CHUNK_SIZE_X;
- m_currentpos.z -= z * CHUNK_SIZE_Z;
- m_startpos.x -= x * CHUNK_SIZE_X;
- m_startpos.z -= z * CHUNK_SIZE_Z;
-}
diff --git a/SQCSim2021/bullet.h b/SQCSim2021/bullet.h
deleted file mode 100644
index ce706f8..0000000
--- a/SQCSim2021/bullet.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef BULLET_H__
-#define BULLET_H__
-
-#include "audio.h"
-#include "player.h"
-#include "vertexbuffer.h"
-#include "texture.h"
-
-class World;
-
-class Bullet {
-public:
- Bullet(Player& player);
- ~Bullet();
-
- bool Update(World* world, Transformation& tran, float elapsedtime);
- void Transpose(int& x, int& z);
-
-private:
- Vector3f m_startpos;
- Vector3f m_currentpos;
- Vector3f m_velocity;
-
-};
-
-#endif // BULLET_H__
-
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index 5f21e66..6599890 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -374,12 +374,12 @@ void Engine::Render(float elapsedTime) {
else if (bulletTime <= 0.f) {
for (int x = 0; x < MAX_BULLETS; ++x) // Ajouter une balle dans l'array (aussi connu sous le nom de "faire pow pow").
if (!m_bullets[x]) {
- m_bullets[x] = new Bullet(m_player);
+ m_bullets[x] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
break;
}
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la première balle de l'array.
m_bullets[0]->~Bullet();
- m_bullets[0] = new Bullet(m_player);
+ m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
}
bulletTime = .1f;
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "windowsaccount.wav", m_player.GetPOV(), m_player.GetDirection() * 10, .5f);
@@ -396,7 +396,7 @@ void Engine::Render(float elapsedTime) {
for (int x = 0; x < MAX_BULLETS; ++x) // Array de bullets en jeu.
if (m_bullets[x])
- if (m_bullets[x]->Update(&m_world, all, elapsedTime)) {
+ if (m_bullets[x]->Update(&m_world, elapsedTime)) {
m_bullets[x]->~Bullet();
m_bullets[x] = nullptr;
}
diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h
index 5220cf8..8c525b6 100644
--- a/SQCSim2021/engine.h
+++ b/SQCSim2021/engine.h
@@ -5,8 +5,8 @@
#include
#include "../SQCSim-common/array2d.h"
#include "../SQCSim-common/blockinfo.h"
+#include "../SQCSim-common/bullet.h"
#include "define.h"
-#include "bullet.h"
#include "openglcontext.h"
#include "texture.h"
#include "transformation.h"
diff --git a/SQCSim2021/world.h b/SQCSim2021/world.h
index d2b0dc1..0b88748 100644
--- a/SQCSim2021/world.h
+++ b/SQCSim2021/world.h
@@ -7,7 +7,7 @@
#include
#include "../SQCSim-common/vector3.h"
#include "../SQCSim-common/array2d.h"
-#include "bullet.h"
+#include "../SQCSim-common/bullet.h"
#include "define.h"
#include "player.h"
#include "chunk.h"