Compare commits
7 Commits
L-CSplash
...
sqc-14_cla
Author | SHA1 | Date | |
---|---|---|---|
|
889884490b | ||
|
bd817f9f7d | ||
|
57d60e02a7 | ||
|
ae201846b1 | ||
|
67a49a4cad | ||
|
d7e55c8446 | ||
|
183c5f186a |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -373,8 +373,5 @@ FodyWeavers.xsd
|
|||||||
/x64/Release/SQCSim2023.exe
|
/x64/Release/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2023.exe
|
/x64/Debug/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2021.pdb
|
/x64/Debug/SQCSim2021.pdb
|
||||||
/SQCSim-srv/cmake/*
|
SQCSim2021/SQCSim2021.vcxproj.filters
|
||||||
!/SQCSim-srv/cmake/CMakeLists.txt
|
SQCSim2021/SQCSim2021.vcxproj
|
||||||
/SQCSim2021/cmake/*
|
|
||||||
!/SQCSim2021/cmake/CMakeLists.txt
|
|
||||||
/SQCSim2021/SQCSim-client
|
|
||||||
|
@@ -7,9 +7,8 @@ Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_cur
|
|||||||
|
|
||||||
Bullet::~Bullet() {}
|
Bullet::~Bullet() {}
|
||||||
|
|
||||||
bool Bullet::Update(World* world, float elapsedtime, int perframe) {
|
bool Bullet::Update(World* world, float elapsedtime) {
|
||||||
int max = 100 / perframe;
|
for (int x = 0; x < 1000; ++x) {
|
||||||
for (int x = 0; x < max; ++x) {
|
|
||||||
m_currentpos += m_velocity * elapsedtime;
|
m_currentpos += m_velocity * elapsedtime;
|
||||||
|
|
||||||
if (!world->ChunkAt(m_currentpos))
|
if (!world->ChunkAt(m_currentpos))
|
||||||
@@ -31,14 +30,10 @@ void Bullet::Transpose(int& x, int& z) {
|
|||||||
m_startpos.z -= z * CHUNK_SIZE_Z;
|
m_startpos.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f Bullet::getPos() const {
|
Vector3f Bullet::getPos() {
|
||||||
return m_currentpos;
|
return m_currentpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f Bullet::getVel() const {
|
|
||||||
return m_velocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Bullet::getTeamID(){
|
uint64_t Bullet::getTeamID(){
|
||||||
return m_tid;
|
return m_tid;
|
||||||
}
|
}
|
||||||
|
@@ -12,10 +12,9 @@ public:
|
|||||||
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|
||||||
bool Update(World* world, float elapsedtime, int perframe);
|
bool Update(World* world, float elapsedtime);
|
||||||
void Transpose(int& x, int& z);
|
void Transpose(int& x, int& z);
|
||||||
Vector3f getPos() const;
|
Vector3f getPos();
|
||||||
Vector3f getVel() const;
|
|
||||||
uint64_t getTeamID();
|
uint64_t getTeamID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -53,7 +53,6 @@ typedef uint64_t Timestamp;
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#define INVALID_SOCKET -1
|
#define INVALID_SOCKET -1
|
||||||
|
@@ -33,7 +33,11 @@ namespace netprot {
|
|||||||
bool jumping,
|
bool jumping,
|
||||||
shooting,
|
shooting,
|
||||||
hit,
|
hit,
|
||||||
powerup;
|
powerup,
|
||||||
|
dead,
|
||||||
|
still,
|
||||||
|
jumpshot,
|
||||||
|
running;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Input { // cli -> srv UDP ~frame
|
struct Input { // cli -> srv UDP ~frame
|
||||||
|
@@ -8,6 +8,8 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
|
|||||||
m_username = "Zelda Bee-Bop56";
|
m_username = "Zelda Bee-Bop56";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player::~Player() {}
|
||||||
|
|
||||||
void Player::TurnLeftRight(float value) {
|
void Player::TurnLeftRight(float value) {
|
||||||
m_rotY += value;
|
m_rotY += value;
|
||||||
if (m_rotY > 360) m_rotY = 0;
|
if (m_rotY > 360) m_rotY = 0;
|
||||||
@@ -206,3 +208,9 @@ void Player::Teleport(int& x, int& z) {
|
|||||||
m_position.x -= x * CHUNK_SIZE_X;
|
m_position.x -= x * CHUNK_SIZE_X;
|
||||||
m_position.z -= z * CHUNK_SIZE_Z;
|
m_position.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Player::getId() const { return id; }
|
||||||
|
|
||||||
|
Vector3f Player::InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now) {
|
||||||
|
return Vector3f();
|
||||||
|
}
|
||||||
|
@@ -12,6 +12,8 @@ public:
|
|||||||
enum Sound { NOSOUND, STEP, FALL };
|
enum Sound { NOSOUND, STEP, FALL };
|
||||||
|
|
||||||
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
||||||
|
~Player();
|
||||||
|
|
||||||
void TurnLeftRight(float value);
|
void TurnLeftRight(float value);
|
||||||
void TurnTopBottom(float value);
|
void TurnTopBottom(float value);
|
||||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||||
@@ -26,12 +28,13 @@ public:
|
|||||||
float GetHP() const;
|
float GetHP() const;
|
||||||
void Teleport(int& x, int& z);
|
void Teleport(int& x, int& z);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Vector3f m_position;
|
Vector3f m_position;
|
||||||
Vector3f m_velocity;
|
Vector3f m_velocity;
|
||||||
Vector3f m_direction;
|
Vector3f m_direction;
|
||||||
|
|
||||||
std::string m_username;
|
std::string m_username;
|
||||||
|
uint64_t id = 0;
|
||||||
|
|
||||||
float m_rotX = 0;
|
float m_rotX = 0;
|
||||||
float m_rotY = 0;
|
float m_rotY = 0;
|
||||||
@@ -40,6 +43,9 @@ private:
|
|||||||
float m_hp;
|
float m_hp;
|
||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
|
|
||||||
|
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //_PLAYER_H__
|
#endif //_PLAYER_H__
|
||||||
|
|
||||||
|
@@ -130,7 +130,7 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
|
|||||||
y = m_center[1];
|
y = m_center[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void World::Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
UpdateWorld(player_pos, blockinfo);
|
UpdateWorld(player_pos, blockinfo);
|
||||||
//TransposeWorld(player_pos, bullets);
|
//TransposeWorld(player_pos, bullets);
|
||||||
}
|
}
|
||||||
@@ -407,4 +407,4 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int World::GettbDeleted() const { return m_tbDeleted.size(); }
|
int World::GettbDeleted() const { return m_tbDeleted.size(); }
|
@@ -30,7 +30,7 @@ public:
|
|||||||
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
|
|
||||||
void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
void Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
|
||||||
void GetScope(unsigned int& x, unsigned int& y);
|
void GetScope(unsigned int& x, unsigned int& y);
|
||||||
|
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.18.4)
|
|
||||||
|
|
||||||
project(SQCSim-Server VERSION 0.1)
|
|
||||||
|
|
||||||
add_compile_options("-Wno-narrowing")
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_STANDARD_REQUIRED True)
|
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../out")
|
|
||||||
|
|
||||||
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
|
|
||||||
|
|
||||||
add_library(SQCSim-common
|
|
||||||
"${SQCSIM_COMMON_DIR}blockinfo.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}bullet.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}chunk.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}netprotocol.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}opensimplex.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}player.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}transformation.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}world.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(SQCSim-server
|
|
||||||
"../connection.cpp"
|
|
||||||
"../server.cpp"
|
|
||||||
"../main.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(SQCSim-server PUBLIC SQCSim-common)
|
|
@@ -14,4 +14,4 @@
|
|||||||
typedef unsigned char LogDest;
|
typedef unsigned char LogDest;
|
||||||
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
|
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
|
||||||
|
|
||||||
#endif
|
#endif
|
@@ -85,7 +85,7 @@ int Server::Ready() {
|
|||||||
|
|
||||||
while (!readystart) {
|
while (!readystart) {
|
||||||
sockaddr_in sockad;
|
sockaddr_in sockad;
|
||||||
unsigned int addrlen = sizeof(sockad);
|
int addrlen = sizeof(sockad);
|
||||||
SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen);
|
SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen);
|
||||||
|
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
@@ -140,7 +140,7 @@ void Server::Run() {
|
|||||||
Log("Partie en cours...", false, false);
|
Log("Partie en cours...", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string Server::LogTimestamp() {
|
inline std::string Server::Timestamp() {
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
@@ -162,11 +162,11 @@ inline std::string Server::LogTimestamp() {
|
|||||||
void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) {
|
void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) {
|
||||||
switch (m_log) {
|
switch (m_log) {
|
||||||
case LOG_DEST::LOGFILE:
|
case LOG_DEST::LOGFILE:
|
||||||
m_logfile << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
m_logfile << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
||||||
break;
|
break;
|
||||||
case LOG_DEST::CONSOLE:
|
case LOG_DEST::CONSOLE:
|
||||||
default:
|
default:
|
||||||
std::cout << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
std::cout << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ private:
|
|||||||
|
|
||||||
World* m_world = nullptr;
|
World* m_world = nullptr;
|
||||||
|
|
||||||
std::string LogTimestamp();
|
std::string Timestamp();
|
||||||
void Log(std::string str, bool is_error, bool is_fatal);
|
void Log(std::string str, bool is_error, bool is_fatal);
|
||||||
void buildIdList(size_t size);
|
void buildIdList(size_t size);
|
||||||
|
|
||||||
|
@@ -25,13 +25,14 @@
|
|||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
<ClInclude Include="mesh.h" />
|
<ClInclude Include="mesh.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
|
<ClInclude Include="remoteplayer.h" />
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
<ClInclude Include="textureatlas.h" />
|
<ClInclude Include="textureatlas.h" />
|
||||||
<ClInclude Include="tool.h" />
|
<ClInclude Include="tool.h" />
|
||||||
<ClInclude Include="vertexbuffer.h" />
|
<ClInclude Include="vertexbuffer.h" />
|
||||||
<ClInclude Include="worldrenderer.h" />
|
<ClInclude Include="renderer.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="audio.cpp" />
|
<ClCompile Include="audio.cpp" />
|
||||||
@@ -40,13 +41,14 @@
|
|||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="mesh.cpp" />
|
<ClCompile Include="mesh.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
|
<ClCompile Include="remoteplayer.cpp" />
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
<ClCompile Include="textureatlas.cpp" />
|
<ClCompile Include="textureatlas.cpp" />
|
||||||
<ClCompile Include="tool.cpp" />
|
<ClCompile Include="tool.cpp" />
|
||||||
<ClCompile Include="vertexbuffer.cpp" />
|
<ClCompile Include="vertexbuffer.cpp" />
|
||||||
<ClCompile Include="worldrenderer.cpp" />
|
<ClCompile Include="renderer.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
||||||
|
@@ -47,7 +47,10 @@
|
|||||||
<ClInclude Include="mesh.h">
|
<ClInclude Include="mesh.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="worldrenderer.h">
|
<ClInclude Include="renderer.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="remoteplayer.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -88,7 +91,10 @@
|
|||||||
<ClCompile Include="mesh.cpp">
|
<ClCompile Include="mesh.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="worldrenderer.cpp">
|
<ClCompile Include="renderer.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="remoteplayer.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
Audio::Audio() {
|
Audio::Audio() {
|
||||||
m_engine = irrklang::createIrrKlangDevice();
|
m_engine = irrklang::createIrrKlangDevice();
|
||||||
m_engine->setDopplerEffectParameters(10);
|
m_engine->setDopplerEffectParameters(1);
|
||||||
m_engine->setRolloffFactor(2);
|
m_engine->setRolloffFactor(1);
|
||||||
m_engine->setDefault3DSoundMinDistance(.1);
|
m_engine->setDefault3DSoundMinDistance(1);
|
||||||
m_engine->setDefault3DSoundMaxDistance(1000);
|
m_engine->setDefault3DSoundMaxDistance(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Audio::Audio(const char * music) {
|
Audio::Audio(const char * music) {
|
||||||
m_engine = irrklang::createIrrKlangDevice();
|
m_engine = irrklang::createIrrKlangDevice();
|
||||||
m_engine->setDopplerEffectParameters(1);
|
m_engine->setDopplerEffectParameters(1);
|
||||||
m_engine->setRolloffFactor(2);
|
m_engine->setRolloffFactor(1);
|
||||||
m_engine->setDefault3DSoundMinDistance(.1);
|
m_engine->setDefault3DSoundMinDistance(1);
|
||||||
m_engine->setDefault3DSoundMaxDistance(1000);
|
m_engine->setDefault3DSoundMaxDistance(1000);
|
||||||
m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING);
|
m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING);
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,10 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) {
|
|||||||
irrklang::vec3df(vel.x, vel.y, vel.z));
|
irrklang::vec3df(vel.x, vel.y, vel.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) {
|
void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume = 1) {
|
||||||
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true);
|
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), false, false, true, irrklang::ESM_NO_STREAMING, true);
|
||||||
sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z));
|
sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z));
|
||||||
sound->setVolume(volume);
|
sound->setVolume(volume);
|
||||||
return sound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume = 1) {
|
void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume = 1) {
|
||||||
|
@@ -1,30 +1,24 @@
|
|||||||
#ifndef AUDIO_H__
|
#ifndef AUDIO_H__
|
||||||
#define AUDIO_H__
|
#define AUDIO_H__
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <irrKlang.h>
|
#include <irrKlang.h>
|
||||||
#include <ik_ISoundSource.h>
|
#include <ik_ISoundSource.h>
|
||||||
#else
|
|
||||||
#include "./external/irrKlang-64bit-1.6.0/include/irrKlang.h"
|
|
||||||
#include "./external/irrKlang-64bit-1.6.0/include/ik_ISoundSource.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../SQCSim-common/vector3.h"
|
#include "../SQCSim-common/vector3.h"
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
|
|
||||||
class Audio {
|
class Audio {
|
||||||
private:
|
private:
|
||||||
|
irrklang::ISoundEngine* m_engine;
|
||||||
irrklang::ISound* m_music;
|
irrklang::ISound* m_music;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Audio();
|
Audio();
|
||||||
Audio(const char* music);
|
Audio(const char* music);
|
||||||
~Audio();
|
~Audio();
|
||||||
irrklang::ISoundEngine* m_engine;
|
|
||||||
|
|
||||||
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
||||||
|
|
||||||
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
|
void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume);
|
||||||
|
|
||||||
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
||||||
|
|
||||||
@@ -35,4 +29,4 @@ public:
|
|||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
@@ -1,68 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.18.4)
|
|
||||||
|
|
||||||
project(SQCSim-Client VERSION 0.8)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_STANDARD_REQUIRED True)
|
|
||||||
|
|
||||||
set(CMAKE_BUILD_DIRECTORY "./build")
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")
|
|
||||||
|
|
||||||
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
|
|
||||||
set(SQCSIM_EXTERN_DIR "../external/")
|
|
||||||
|
|
||||||
find_package(SFML COMPONENTS system window graphics REQUIRED)
|
|
||||||
find_package(DevIL REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
|
|
||||||
find_library(IRRKLANG_LIBRARY
|
|
||||||
NAMES libIrrKlang.so
|
|
||||||
PATHS "${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/lib/linux-gcc-64/")
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/include/
|
|
||||||
${SFML_INCLUDE_DIRS}
|
|
||||||
${IL_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
add_library(SQCSim-common
|
|
||||||
"${SQCSIM_COMMON_DIR}blockinfo.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}bullet.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}chunk.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}netprotocol.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}opensimplex.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}player.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}transformation.cpp"
|
|
||||||
"${SQCSIM_COMMON_DIR}world.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(SQCSim-client
|
|
||||||
"../audio.cpp"
|
|
||||||
"../connector.cpp"
|
|
||||||
"../engine.cpp"
|
|
||||||
"../mesh.cpp"
|
|
||||||
"../openglcontext.cpp"
|
|
||||||
"../shader.cpp"
|
|
||||||
"../skybox.cpp"
|
|
||||||
"../texture.cpp"
|
|
||||||
"../textureatlas.cpp"
|
|
||||||
"../tool.cpp"
|
|
||||||
"../vertexbuffer.cpp"
|
|
||||||
"../worldrenderer.cpp"
|
|
||||||
"../main.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(SQCSim-client PUBLIC SQCSim-common
|
|
||||||
${IRRKLANG_LIBRARY}
|
|
||||||
sfml-system
|
|
||||||
sfml-window
|
|
||||||
sfml-graphics
|
|
||||||
GL
|
|
||||||
GLU
|
|
||||||
GLEW
|
|
||||||
${IL_LIBRARIES}
|
|
||||||
${ILU_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
@@ -17,6 +17,8 @@ public:
|
|||||||
|
|
||||||
//void SendInput();
|
//void SendInput();
|
||||||
//int Sync();
|
//int Sync();
|
||||||
|
|
||||||
|
// void updateRemotePlayers(std::map<RemotePlayers> rplayers);
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA m_wsaData;
|
WSADATA m_wsaData;
|
||||||
|
@@ -6,34 +6,26 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include "../SQCSim-common/define.h"
|
#include "../SQCSim-common/define.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <GL/glew.h>
|
||||||
#include <gl/GL.h>
|
#include <gl/GL.h>
|
||||||
#include <gl/GLU.h>
|
#include <gl/GLU.h>
|
||||||
#else
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <climits>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NETWORK_TEST false
|
#define NETWORK_TEST false
|
||||||
#define SRV_ADDR "127.0.0.1"
|
#define SRV_ADDR "127.0.0.1"
|
||||||
#define COUNTDOWN 300
|
#define COUNTDOWN 300
|
||||||
|
|
||||||
#define BULLET_UPDATES_PER_FRAME 20
|
#define BASE_WIDTH 1920
|
||||||
|
#define BASE_HEIGHT 1080
|
||||||
#define BASE_WIDTH 640
|
|
||||||
#define BASE_HEIGHT 480
|
|
||||||
|
|
||||||
|
|
||||||
#define TEXTURE_PATH "./media/textures/"
|
#define TEXTURE_PATH "./media/textures/"
|
||||||
#define SHADER_PATH "./media/shaders/"
|
#define SHADER_PATH "./media/shaders/"
|
||||||
#define AUDIO_PATH "./media/audio/"
|
#define AUDIO_PATH "./media/audio/"
|
||||||
#define CHUNK_PATH "./media/chunks/"
|
#define CHUNK_PATH "./media/chunks/"
|
||||||
#define MENU_ITEM_PATH "./media/menu_items/"
|
|
||||||
|
|
||||||
#endif // DEFINE_H__
|
#endif // DEFINE_H__
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
|
|
@@ -28,253 +28,7 @@ Engine::~Engine() {
|
|||||||
m_world.GetChunks().Get(x, y)->~Chunk();
|
m_world.GetChunks().Get(x, y)->~Chunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DrawSplachScreen()
|
|
||||||
{
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
|
|
||||||
// Définir la matrice de projection en mode orthographique
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(-Width() / 2, Width() / 2, -Height() / 2, Height() / 2, -1, 1);
|
|
||||||
|
|
||||||
// Définir la matrice de modèle-vue
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
// L'image sera centrée autour de l'origine (0, 0, 0)
|
|
||||||
int imageWidth = Width(); // Remplacez par la largeur de votre image
|
|
||||||
int imageHeight = Height(); // Remplacez par la hauteur de votre image
|
|
||||||
|
|
||||||
// Texture
|
|
||||||
SplachScreenTexture.Bind();
|
|
||||||
|
|
||||||
// Dessiner un quadrilatère centré
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(-imageWidth / 2, -imageHeight / 2);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(imageWidth / 2, -imageHeight / 2);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(imageWidth / 2, imageHeight / 2);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(-imageWidth / 2, imageHeight / 2);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Activer la transparence
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
// Restaurer les matrices précédentes
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Engine::DrawMenu()
|
|
||||||
{
|
|
||||||
static const int sTitle = 400;
|
|
||||||
static const int sButton = 225;
|
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
MenuBGTexture.Bind();
|
|
||||||
glLoadIdentity();
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 0);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(800, 0);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(800, 600);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 600);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
if (m_gamestate != GameState::OPTIONS)
|
|
||||||
{
|
|
||||||
MenuTitleTexture.Bind();
|
|
||||||
glTranslated(200, 300, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sTitle, 200);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sTitle, 300);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 300);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
MenuStartTexture.Bind();
|
|
||||||
glTranslated(80, -225, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 100);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 100);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
/*MenuResumeTexture.Bind();
|
|
||||||
glTranslated(0, -100, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();*/
|
|
||||||
|
|
||||||
/*MenuOptionsTexture.Bind();
|
|
||||||
glTranslated(0, -100, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();*/
|
|
||||||
|
|
||||||
MenuQuitTexture.Bind();
|
|
||||||
glTranslated(0, -100, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 100);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 100);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*MenuOptionsTexture.Bind();
|
|
||||||
glTranslated(200, 0, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 0);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sTitle, 0);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sTitle, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
WireFrameTexture.Bind();
|
|
||||||
glTranslated(0, 300, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
OnOffBtnTexture.Bind();
|
|
||||||
glTranslated(200, 0, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
glTranslated(-400, -300, 0);
|
|
||||||
|
|
||||||
MusicTexture.Bind();
|
|
||||||
glTranslated(200, 200, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
OnOffBtnTexture.Bind();
|
|
||||||
glTranslated(200, 0, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 125);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 125);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
BackBtnTexture.Bind();
|
|
||||||
glTranslated(-375, 175, 0);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2i(0, 140);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2i(sButton, 140);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2i(sButton, 200);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2i(0, 200);
|
|
||||||
glEnd();*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//glEnable(GL_LIGHTING);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
ShowCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::Init() {
|
void Engine::Init() {
|
||||||
|
|
||||||
|
|
||||||
GLenum glewErr = glewInit();
|
GLenum glewErr = glewInit();
|
||||||
if (glewErr != GLEW_OK) {
|
if (glewErr != GLEW_OK) {
|
||||||
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
||||||
@@ -299,7 +53,6 @@ void Engine::Init() {
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glBlendEquation(GL_FUNC_SUBTRACT);
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Objet de skybox avec sa propre texture et son propre shader!
|
// Objet de skybox avec sa propre texture et son propre shader!
|
||||||
m_skybox.Init(0.2f);
|
m_skybox.Init(0.2f);
|
||||||
@@ -308,24 +61,22 @@ void Engine::Init() {
|
|||||||
//m_audio.ToggleMusicState();
|
//m_audio.ToggleMusicState();
|
||||||
|
|
||||||
// Array pour les balles.
|
// Array pour les balles.
|
||||||
for (int x = 0; x < MAX_BULLETS; ++x) {
|
for (int x = 0; x < MAX_BULLETS; ++x)
|
||||||
m_bullets[x] = nullptr;
|
m_bullets[x] = nullptr;
|
||||||
m_whoosh[x] = nullptr; // = m_audio.m_engine.m_audio.m_engine->addSoundSourceFromFile(AUDIO_PATH "noise.ogg", irrklang::ESM_AUTO_DETECT, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t seed = SEED;
|
uint64_t seed = SEED;
|
||||||
std::string playname = "La Chienne <20> Jacques";
|
std::string playname = "La Chienne <20> Jacques";
|
||||||
if (NETWORK_TEST) { // Test connexion r<>seau.
|
if (NETWORK_TEST) { // Test connexion r<>seau.
|
||||||
if (!m_conn.Init()) {
|
if (!m_conn.Init()) {
|
||||||
if (!m_conn.Connect(SRV_ADDR, playname)) {
|
if (!m_conn.Connect(SRV_ADDR, playname)) {
|
||||||
// setup jeu en r<>seau.
|
// setup jeu en r<>seau.
|
||||||
std::cout << "ID re<72>u du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
std::cout << "ID re<72>u du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
||||||
std::cout << "Seed re<72>u du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
std::cout << "Seed re<72>u du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
||||||
seed = m_conn.getSeed();
|
seed = m_conn.getSeed();
|
||||||
}
|
}
|
||||||
else std::cout << "Erreur de connexion." << std::endl;
|
else std::cout << "Erreur de connexion." << std::endl;
|
||||||
}
|
}
|
||||||
else std::cout << "Erreur de cr<63>ation de socket." << std::endl;
|
else std::cout << "Erreur de cr<63>ation de socket." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_world.SetSeed(seed);
|
m_world.SetSeed(seed);
|
||||||
@@ -333,8 +84,6 @@ void Engine::Init() {
|
|||||||
// Init Chunks
|
// Init Chunks
|
||||||
m_world.GetChunks().Reset(nullptr);
|
m_world.GetChunks().Reset(nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Gestion de souris.
|
// Gestion de souris.
|
||||||
CenterMouse();
|
CenterMouse();
|
||||||
HideCursor();
|
HideCursor();
|
||||||
@@ -346,14 +95,8 @@ void Engine::LoadResource() {
|
|||||||
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
||||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
||||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
||||||
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", true);
|
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
|
||||||
|
|
||||||
LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png");
|
|
||||||
LoadTexture(MenuBGTexture, MENU_ITEM_PATH "test.png");
|
|
||||||
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
|
||||||
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
|
||||||
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
|
||||||
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
|
||||||
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
||||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
||||||
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
||||||
@@ -445,6 +188,8 @@ void Engine::ProcessNotificationQueue() {
|
|||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PrintText(xOffset, y, scale, it->message);
|
PrintText(xOffset, y, scale, it->message);
|
||||||
|
|
||||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
@@ -491,7 +236,6 @@ void Engine::DisplayCrosshair() {
|
|||||||
void Engine::DisplayCurrentItem() {
|
void Engine::DisplayCurrentItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Engine::DisplayHud(int timer) {
|
void Engine::DisplayHud(int timer) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -505,7 +249,7 @@ void Engine::DisplayHud(int timer) {
|
|||||||
float playerHp = m_player.GetHP();
|
float playerHp = m_player.GetHP();
|
||||||
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
|
||||||
|
|
||||||
// Arri<72>re-plan (Barre HP)
|
// Arri<72>re-plan (Barre HP)
|
||||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
|
||||||
@@ -514,7 +258,7 @@ void Engine::DisplayHud(int timer) {
|
|||||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//TODO: Associer avec m<>chanique de vie du joueur
|
//TODO: Associer avec m<>chanique de vie du joueur
|
||||||
|
|
||||||
// Barre HP
|
// Barre HP
|
||||||
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
|
||||||
@@ -525,7 +269,7 @@ void Engine::DisplayHud(int timer) {
|
|||||||
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
glVertex2f(fPosX, fPosY); // Haut-Gauche
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// Barre <20>quip
|
// Barre <20>quip
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
|
||||||
@@ -546,7 +290,7 @@ void Engine::DisplayHud(int timer) {
|
|||||||
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
|
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
// Username
|
// Username
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@@ -583,7 +327,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
|||||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
||||||
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
|
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
||||||
PrintText(x, Height() / 48, scale, ss.str());
|
PrintText(x, Height() / 48, scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Direction : " << m_player.GetDirection();
|
ss << " Direction : " << m_player.GetDirection();
|
||||||
@@ -608,7 +352,6 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@@ -700,132 +443,112 @@ int Engine::GetCountdown(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Engine::Render(float elapsedTime) {
|
void Engine::Render(float elapsedTime) {
|
||||||
|
//static float gameTime = elapsedTime;
|
||||||
|
static irrklang::ISound* step; // Pour les sons de pas.
|
||||||
|
static float pollTime = 0;
|
||||||
|
static float bulletTime = 0;
|
||||||
|
static BlockType bloc = 1;
|
||||||
|
|
||||||
|
if (elapsedTime > 0.1f) return;
|
||||||
|
|
||||||
|
//gameTime += elapsedTime;
|
||||||
|
pollTime += elapsedTime;
|
||||||
|
|
||||||
|
Transformation all;
|
||||||
|
Transformation skybox;
|
||||||
|
Vector3f vstep;
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
m_time_SplashScreen += elapsedTime;
|
// Transformations initiales
|
||||||
if(m_time_SplashScreen < 2)
|
glMatrixMode(GL_MODELVIEW);
|
||||||
DrawSplachScreen();
|
glLoadIdentity();
|
||||||
else if (m_gamestate == GameState::PLAY)
|
|
||||||
{
|
|
||||||
HideCursor();
|
|
||||||
CenterMouse(); //D<>placement de centermouse dans l'action de jouer
|
|
||||||
|
|
||||||
//static float gameTime = elapsedTime;
|
if (bulletTime > 0.f) bulletTime -= elapsedTime;
|
||||||
static irrklang::ISound* step; // Pour les sons de pas.
|
if (bulletTime < 0.f) bulletTime = 0.f;
|
||||||
static float pollTime = 0;
|
|
||||||
static float bulletTime = 0;
|
|
||||||
static BlockType bloc = 1;
|
|
||||||
|
|
||||||
if (elapsedTime > 0.1f) return;
|
static bool leftright = false;
|
||||||
|
if (pollTime >= .005f) {
|
||||||
//gameTime += elapsedTime;
|
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime);
|
||||||
pollTime += elapsedTime;
|
switch (snd) {
|
||||||
|
case Player::Sound::STEP:
|
||||||
Transformation all;
|
if (leftright)
|
||||||
Transformation skybox;
|
vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x);
|
||||||
Vector3f vstep;
|
else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x);
|
||||||
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), .8f);
|
||||||
// Transformations initiales
|
leftright = !leftright;
|
||||||
glMatrixMode(GL_MODELVIEW);
|
break;
|
||||||
glLoadIdentity();
|
case Player::Sound::FALL:
|
||||||
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f);
|
||||||
if (bulletTime > 0.f) bulletTime -= elapsedTime;
|
break;
|
||||||
if (bulletTime < 0.f) bulletTime = 0.f;
|
default: break;
|
||||||
|
|
||||||
static bool leftright = false;
|
|
||||||
if (pollTime >= .005f) {
|
|
||||||
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime);
|
|
||||||
switch (snd) {
|
|
||||||
case Player::Sound::STEP:
|
|
||||||
if (leftright)
|
|
||||||
vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x);
|
|
||||||
else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x);
|
|
||||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false,.8f);
|
|
||||||
leftright = !leftright;
|
|
||||||
break;
|
|
||||||
case Player::Sound::FALL:
|
|
||||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false,1.f);
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
|
|
||||||
// son vecteur de v<>locit<69> (pour l'effet Doppler)
|
|
||||||
pollTime = 0;
|
|
||||||
}
|
}
|
||||||
|
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
|
||||||
|
// son vecteur de v<>locit<69> (pour l'effet Doppler)
|
||||||
|
pollTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m_player.ApplyTransformation(all);
|
m_player.ApplyTransformation(all);
|
||||||
|
|
||||||
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
||||||
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
|
||||||
|
|
||||||
if (m_mouseWU) bloc++;
|
if (m_mouseWU) bloc++;
|
||||||
else if (m_mouseWD) bloc--;
|
else if (m_mouseWD) bloc--;
|
||||||
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
|
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
|
||||||
else if (bloc == BTYPE_AIR) bloc = BTYPE_LAST; // La selection de BTYPE_LAST <20>quipe l'arme.
|
else if (bloc == BTYPE_AIR) bloc = BTYPE_LAST; // La selection de BTYPE_LAST <20>quipe l'arme.
|
||||||
m_mouseWU = m_mouseWD = false;
|
m_mouseWU = m_mouseWD = false;
|
||||||
|
|
||||||
if (m_mouseL) {
|
if (m_mouseL) {
|
||||||
if (bloc != BTYPE_LAST)
|
if (bloc != BTYPE_LAST)
|
||||||
m_world.ChangeBlockAtCursor(bloc, m_player.GetPosition(), m_player.GetDirection(), m_block);
|
m_world.ChangeBlockAtCursor(bloc, m_player.GetPosition(), m_player.GetDirection(), m_block);
|
||||||
else if (bulletTime <= 0.f) {
|
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").
|
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]) {
|
if (!m_bullets[x]) {
|
||||||
m_bullets[x] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
m_bullets[x] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
|
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
|
||||||
m_bullets[0]->~Bullet();
|
m_bullets[0]->~Bullet();
|
||||||
m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
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);
|
||||||
|
if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
|
||||||
|
glClearColor(.8f, .8f, .8f, 1.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_mouseR)
|
else if (m_mouseR)
|
||||||
m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player.GetPosition(), m_player.GetDirection(), m_block);
|
m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player.GetPosition(), m_player.GetDirection(), m_block);
|
||||||
|
|
||||||
|
for (int x = 0; x < MAX_BULLETS; ++x) // Array de bullets en jeu.
|
||||||
|
if (m_bullets[x])
|
||||||
|
if (m_bullets[x]->Update(&m_world, elapsedTime)) {
|
||||||
|
m_bullets[x]->~Bullet();
|
||||||
|
m_bullets[x] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
|
|
||||||
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
|
ProcessNotificationQueue();
|
||||||
|
DrawHud(elapsedTime, bloc);
|
||||||
|
|
||||||
for (int x = 0; x < MAX_BULLETS; ++x) { // Array de bullets en jeu.
|
static bool fell = false;
|
||||||
if (m_bullets[x]) {
|
if (m_player.GetPosition().y < 1.7f && !fell) {
|
||||||
for (int b = 0; b < BULLET_UPDATES_PER_FRAME; ++b)
|
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f);
|
||||||
if (m_bullets[x]->Update(&m_world, elapsedTime, BULLET_UPDATES_PER_FRAME)) {
|
fell = true;
|
||||||
m_bullets[x]->~Bullet();
|
|
||||||
if (m_whoosh[x])
|
|
||||||
m_whoosh[x]->drop();
|
|
||||||
m_bullets[x] = nullptr;
|
|
||||||
m_whoosh[x] = nullptr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!m_whoosh[x]) {
|
|
||||||
m_whoosh[x] = m_audio.Create3DAudioObj(m_whoosh[x], AUDIO_PATH "noise.wav", m_bullets[x]->getPos(), m_bullets[x]->getVel(), true, (m_bullets[x]->getPos() - m_player.GetPosition()).Length());
|
|
||||||
}
|
|
||||||
else m_audio.Render3DAudioObj(m_whoosh[x], m_bullets[x]->getPos(), m_bullets[x]->getVel(), 5 - (m_bullets[x]->getPos() - m_player.GetPosition()).Length());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (m_player.GetPosition().y < -20.f) {
|
||||||
m_wrenderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
|
||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
fell = false;
|
||||||
m_wrenderer.UpdateWorld(&m_world, m_player.GetPosition(), m_blockinfo);
|
|
||||||
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
|
||||||
|
|
||||||
ProcessNotificationQueue();
|
|
||||||
DrawHud(elapsedTime, bloc);
|
|
||||||
|
|
||||||
static bool fell = false;
|
|
||||||
if (m_player.GetPosition().y < 1.7f && !fell) {
|
|
||||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false,1.f);
|
|
||||||
fell = true;
|
|
||||||
}
|
|
||||||
else if (m_player.GetPosition().y < -20.f) {
|
|
||||||
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
|
|
||||||
fell = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
|
||||||
{
|
|
||||||
DrawMenu();
|
|
||||||
}
|
|
||||||
else if (m_gamestate == GameState::QUIT)
|
|
||||||
Stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::KeyPressEvent(unsigned char key) {
|
void Engine::KeyPressEvent(unsigned char key) {
|
||||||
@@ -851,15 +574,14 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 36: // ESC - Quitter
|
case 36: // ESC - Quitter
|
||||||
m_gamestate = GameState::MAIN_MENU;
|
Stop();
|
||||||
//Stop();
|
|
||||||
break;
|
break;
|
||||||
case 57: // Space - Sauter
|
case 57: // Space - Sauter
|
||||||
if (!m_keySpace) {
|
if (!m_keySpace) {
|
||||||
m_keySpace = true;
|
m_keySpace = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 94: // F10 - Plein <20>cran
|
case 94: // F10 - Plein <20>cran
|
||||||
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
||||||
//SetFullscreen(!IsFullscreen());
|
//SetFullscreen(!IsFullscreen());
|
||||||
break;
|
break;
|
||||||
@@ -869,7 +591,7 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
break;
|
break;
|
||||||
case 10: // K - Debugging DisplayNotification()
|
case 10: // K - Debugging DisplayNotification()
|
||||||
m_keyK = true;
|
m_keyK = true;
|
||||||
m_messageNotification = "notifications systeme peuvent <20>tre affich<63>";
|
m_messageNotification = "notifications systeme peuvent <20>tre affich<63>";
|
||||||
break;
|
break;
|
||||||
case 11: // L - Debugging DisplayNotification()
|
case 11: // L - Debugging DisplayNotification()
|
||||||
m_keyL = true;
|
m_keyL = true;
|
||||||
@@ -882,8 +604,6 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
break;
|
break;
|
||||||
case 8: // I - Ignorer
|
case 8: // I - Ignorer
|
||||||
break;
|
break;
|
||||||
case 15: // P - Ignorer
|
|
||||||
break;
|
|
||||||
case 17: // R - Ignorer
|
case 17: // R - Ignorer
|
||||||
break;
|
break;
|
||||||
case 19: // T - Ignorer
|
case 19: // T - Ignorer
|
||||||
@@ -933,17 +653,6 @@ void Engine::KeyReleaseEvent(unsigned char key) {
|
|||||||
case 12: // M - Toggle music
|
case 12: // M - Toggle music
|
||||||
m_audio.ToggleMusicState();
|
m_audio.ToggleMusicState();
|
||||||
break;
|
break;
|
||||||
case 15:
|
|
||||||
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.GetPOV() - Vector3f(1.f, 0.f, 1.f), Vector3f(1.f,0.f,1.f));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
|
|
||||||
m_bullets[0]->~Bullet();
|
|
||||||
m_bullets[0] = new Bullet(m_player.GetPOV() - Vector3f(1.f, 0.f, 1.f), Vector3f(1.f, 0.f, 1.f));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 17: // R - Toggle skybox
|
case 17: // R - Toggle skybox
|
||||||
m_isSkybox = !m_isSkybox;
|
m_isSkybox = !m_isSkybox;
|
||||||
break;
|
break;
|
||||||
@@ -974,47 +683,35 @@ void Engine::MouseMoveEvent(int x, int y) {
|
|||||||
m_player.TurnLeftRight(x - (Width() / 2));
|
m_player.TurnLeftRight(x - (Width() / 2));
|
||||||
m_player.TurnTopBottom(y - (Height() / 2));
|
m_player.TurnTopBottom(y - (Height() / 2));
|
||||||
|
|
||||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||||
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
||||||
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
|
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
|
||||||
// MouseMoveEvent, etc
|
// MouseMoveEvent, etc
|
||||||
if (x == (Width() / 2) && y == (Height() / 2))
|
if (x == (Width() / 2) && y == (Height() / 2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CenterMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||||
m_mousemx = x;
|
switch (button) {
|
||||||
m_mousemy = y;
|
case MOUSE_BUTTON_LEFT:
|
||||||
|
m_mouseL = true;
|
||||||
if (m_gamestate == GameState::PLAY)
|
break;
|
||||||
{
|
case MOUSE_BUTTON_RIGHT:
|
||||||
switch (button) {
|
m_mouseR = true;
|
||||||
case MOUSE_BUTTON_LEFT:
|
break;
|
||||||
m_mouseL = true;
|
case MOUSE_BUTTON_MIDDLE:
|
||||||
break;
|
m_mouseC = true;
|
||||||
case MOUSE_BUTTON_RIGHT:
|
break;
|
||||||
m_mouseR = true;
|
case MOUSE_BUTTON_WHEEL_UP:
|
||||||
break;
|
m_mouseWU = true;
|
||||||
case MOUSE_BUTTON_MIDDLE:
|
break;
|
||||||
m_mouseC = true;
|
case MOUSE_BUTTON_WHEEL_DOWN:
|
||||||
break;
|
m_mouseWD = true;
|
||||||
case MOUSE_BUTTON_WHEEL_UP:
|
break;
|
||||||
m_mouseWU = true;
|
case MOUSE_BUTTON_NONE: break;
|
||||||
break;
|
|
||||||
case MOUSE_BUTTON_WHEEL_DOWN:
|
|
||||||
m_mouseWD = true;
|
|
||||||
break;
|
|
||||||
case MOUSE_BUTTON_NONE: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (m_gamestate == GameState::MAIN_MENU)
|
|
||||||
{
|
|
||||||
if ((m_mousemx >= 285 && m_mousemx <= 490) && (m_mousemy >= 150 && m_mousemy <= 250))
|
|
||||||
m_gamestate = GameState::PLAY;
|
|
||||||
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 300 && m_mousemy <= 400))
|
|
||||||
m_gamestate = GameState::QUIT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,14 +18,12 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "worldrenderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
virtual void DrawMenu();
|
|
||||||
virtual void DrawSplachScreen();
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
virtual void LoadResource();
|
virtual void LoadResource();
|
||||||
@@ -62,7 +60,7 @@ private:
|
|||||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||||
|
|
||||||
World m_world = World();
|
World m_world = World();
|
||||||
WorldRenderer m_wrenderer = WorldRenderer();
|
Renderer m_renderer = Renderer();
|
||||||
|
|
||||||
Texture m_textureSkybox;
|
Texture m_textureSkybox;
|
||||||
Texture m_textureFont;
|
Texture m_textureFont;
|
||||||
@@ -72,29 +70,15 @@ private:
|
|||||||
Skybox m_skybox;
|
Skybox m_skybox;
|
||||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||||
|
|
||||||
irrklang::ISound* m_powpow,
|
irrklang::ISound* m_powpow;
|
||||||
* m_scream;
|
irrklang::ISound* m_scream;
|
||||||
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
|
||||||
|
|
||||||
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
//Menu
|
|
||||||
enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
|
||||||
GameState m_gamestate = GameState::MAIN_MENU;
|
|
||||||
Texture MenuTitleTexture;
|
|
||||||
Texture MenuBGTexture;
|
|
||||||
Texture MenuStartTexture;
|
|
||||||
Texture MenuQuitTexture;
|
|
||||||
Texture MenuOptionsTexture;
|
|
||||||
Texture SplachScreenTexture;
|
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
float m_time = 0;
|
float m_time = 0;
|
||||||
float m_time_SplashScreen = 0;
|
|
||||||
float m_Width = 0;
|
|
||||||
float m_Height = 0;
|
|
||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
@@ -121,9 +105,6 @@ private:
|
|||||||
bool m_mouseC = false;
|
bool m_mouseC = false;
|
||||||
bool m_mouseWU = false;
|
bool m_mouseWU = false;
|
||||||
bool m_mouseWD = false;
|
bool m_mouseWD = false;
|
||||||
//Pour trouver ou est la souris
|
|
||||||
float m_mousemx = 0;
|
|
||||||
float m_mousemy = 0;
|
|
||||||
|
|
||||||
std::string m_messageNotification = "";
|
std::string m_messageNotification = "";
|
||||||
};
|
};
|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 7.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 289 KiB |
@@ -7,7 +7,7 @@ void main()
|
|||||||
texel = texture2D(tex,gl_TexCoord[0].st);
|
texel = texture2D(tex,gl_TexCoord[0].st);
|
||||||
|
|
||||||
texel *= light;
|
texel *= light;
|
||||||
texel.a = 255.;
|
texel.a = 255;
|
||||||
gl_FragColor = texel;
|
gl_FragColor = texel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 195 KiB |
@@ -9,7 +9,6 @@ OpenglContext::~OpenglContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OpenglContext::Start(const std::string& title, int width, int height, bool fullscreen)
|
bool OpenglContext::Start(const std::string& title, int width, int height, bool fullscreen)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
@@ -23,14 +22,13 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
|||||||
|
|
||||||
while (m_app.isOpen())
|
while (m_app.isOpen())
|
||||||
{
|
{
|
||||||
|
clock.restart();
|
||||||
|
|
||||||
clock.restart();
|
sf::Event Event;
|
||||||
|
while (m_app.pollEvent(Event))
|
||||||
sf::Event Event;
|
{
|
||||||
while (m_app.pollEvent(Event))
|
switch(Event.type)
|
||||||
{
|
{
|
||||||
switch (Event.type)
|
|
||||||
{
|
|
||||||
case sf::Event::Closed:
|
case sf::Event::Closed:
|
||||||
m_app.close();
|
m_app.close();
|
||||||
break;
|
break;
|
||||||
@@ -53,29 +51,29 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
|||||||
MouseReleaseEvent(ConvertMouseButton(Event.mouseButton.button), Event.mouseButton.x, Event.mouseButton.y);
|
MouseReleaseEvent(ConvertMouseButton(Event.mouseButton.button), Event.mouseButton.x, Event.mouseButton.y);
|
||||||
break;
|
break;
|
||||||
case sf::Event::MouseWheelMoved:
|
case sf::Event::MouseWheelMoved:
|
||||||
if (Event.mouseWheel.delta > 0)
|
if(Event.mouseWheel.delta > 0)
|
||||||
MousePressEvent(MOUSE_BUTTON_WHEEL_UP, Event.mouseButton.x, Event.mouseButton.y);
|
MousePressEvent(MOUSE_BUTTON_WHEEL_UP, Event.mouseButton.x, Event.mouseButton.y);
|
||||||
else
|
else
|
||||||
MousePressEvent(MOUSE_BUTTON_WHEEL_DOWN, Event.mouseButton.x, Event.mouseButton.y);
|
MousePressEvent(MOUSE_BUTTON_WHEEL_DOWN, Event.mouseButton.x, Event.mouseButton.y);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_app.setActive();
|
m_app.setActive();
|
||||||
Render(m_lastFrameTime);
|
Render(m_lastFrameTime);
|
||||||
m_app.display();
|
m_app.display();
|
||||||
|
|
||||||
|
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||||
|
|
||||||
|
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
||||||
|
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
||||||
|
if(waitTime > 0)
|
||||||
|
{
|
||||||
|
sf::sleep(sf::seconds(waitTime));
|
||||||
|
|
||||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
||||||
|
}
|
||||||
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
|
||||||
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
|
||||||
if (waitTime > 0)
|
|
||||||
{
|
|
||||||
sf::sleep(sf::seconds(waitTime));
|
|
||||||
|
|
||||||
m_lastFrameTime = clock.getElapsedTime().asSeconds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadResource();
|
UnloadResource();
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "texture.h"
|
|
||||||
|
|
||||||
// Documentation de SFML: http://www.sfml-dev.org/documentation/index-fr.php
|
// Documentation de SFML: http://www.sfml-dev.org/documentation/index-fr.php
|
||||||
class OpenglContext
|
class OpenglContext
|
||||||
@@ -32,6 +31,7 @@ public:
|
|||||||
virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
||||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y) = 0;
|
||||||
|
|
||||||
|
|
||||||
bool Start(const std::string& title, int width, int height, bool fullscreen);
|
bool Start(const std::string& title, int width, int height, bool fullscreen);
|
||||||
bool Stop();
|
bool Stop();
|
||||||
|
|
||||||
|
70
SQCSim2021/remoteplayer.cpp
Normal file
70
SQCSim2021/remoteplayer.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include "remoteplayer.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
|
RemotePlayer::RemotePlayer() : Player(Vector3f(0, 0, 0), 0, 0), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemotePlayer::Init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemotePlayer::Feed(const netprot::Output out) {
|
||||||
|
|
||||||
|
current.position = out.position;
|
||||||
|
current.direction = out.direction;
|
||||||
|
current.states = out.states;
|
||||||
|
current.id = out.id;
|
||||||
|
|
||||||
|
//a revoir pour le jump et le shoot en meme temps lorsque les test seront possible
|
||||||
|
|
||||||
|
if (current.position != previous.position)
|
||||||
|
{
|
||||||
|
Vector3f positionDelta = current.position - previous.position;
|
||||||
|
m_position = current.position + positionDelta;
|
||||||
|
m_direction = current.direction;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(current.direction != previous.direction)
|
||||||
|
{
|
||||||
|
m_direction = current.direction;
|
||||||
|
current.direction = current.direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.states.shooting) {
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::SHOOTING;
|
||||||
|
}
|
||||||
|
else if (current.states.jumping) {
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::JUMPING;
|
||||||
|
}
|
||||||
|
else if (current.states.dead) {
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::DEAD;
|
||||||
|
}
|
||||||
|
else if(current.states.powerup){
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::POWERUP;
|
||||||
|
}
|
||||||
|
else if (current.states.still) {
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::STILL;
|
||||||
|
}
|
||||||
|
else if (current.states.running) {
|
||||||
|
//true;
|
||||||
|
m_animstate = Anim::RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
previous.direction = current.direction;
|
||||||
|
previous.position = current.position;
|
||||||
|
previous.states = current.states;
|
||||||
|
previous.id = current.id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
25
SQCSim2021/remoteplayer.h
Normal file
25
SQCSim2021/remoteplayer.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef REMOTEPLAYER_H__
|
||||||
|
#define REMOTEPLAYER_H__
|
||||||
|
#include "../SQCSim-common/player.h"
|
||||||
|
#include "../SQCSim-common/netprotocol.h"
|
||||||
|
#include "define.h"
|
||||||
|
#include "textureatlas.h"
|
||||||
|
#include "shader.h"
|
||||||
|
|
||||||
|
class RemotePlayer : public Player {
|
||||||
|
public:
|
||||||
|
enum Anim { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 };
|
||||||
|
|
||||||
|
RemotePlayer();
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void Feed(const netprot::Output out);
|
||||||
|
|
||||||
|
private:
|
||||||
|
netprot::Output current, previous;
|
||||||
|
float m_aminacc;
|
||||||
|
Anim m_animstate;
|
||||||
|
uint64_t m_team_id;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
@@ -1,13 +1,13 @@
|
|||||||
#include "worldrenderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
WorldRenderer::WorldRenderer() {
|
Renderer::Renderer() {
|
||||||
m_meshes.Reset(nullptr);
|
m_meshes.Reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldRenderer::~WorldRenderer() {
|
Renderer::~Renderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) {
|
void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const {
|
||||||
rendercount = 0;
|
rendercount = 0;
|
||||||
Vector3f angle;
|
Vector3f angle;
|
||||||
Vector3f cursor;
|
Vector3f cursor;
|
||||||
@@ -107,7 +107,7 @@ void WorldRenderer::RenderWorld(World* origin, int& rendercount, const Vector3f&
|
|||||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||||
};
|
};
|
||||||
|
|
||||||
void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
int cx = player.x;
|
int cx = player.x;
|
||||||
int cy = player.z;
|
int cy = player.z;
|
||||||
static int frameUpdate = 2;
|
static int frameUpdate = 2;
|
||||||
@@ -212,3 +212,8 @@ void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const {
|
||||||
|
}
|
30
SQCSim2021/renderer.h
Normal file
30
SQCSim2021/renderer.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef RENDERER_H__
|
||||||
|
#define RENDERER_H__
|
||||||
|
#include <future>
|
||||||
|
#include <thread>
|
||||||
|
#include "../SQCSim-common/world.h"
|
||||||
|
#include "../SQCSim-common/transformation.h"
|
||||||
|
#include "define.h"
|
||||||
|
#include "mesh.h"
|
||||||
|
#include "textureatlas.h"
|
||||||
|
#include "shader.h"
|
||||||
|
#include "remoteplayer.h"
|
||||||
|
|
||||||
|
class Renderer {
|
||||||
|
private:
|
||||||
|
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
||||||
|
|
||||||
|
TextureAtlas* m_playertext = nullptr;
|
||||||
|
Shader* m_playershader = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Renderer();
|
||||||
|
~Renderer();
|
||||||
|
|
||||||
|
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
|
||||||
|
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas) const;
|
||||||
|
void RenderPlayer(Player* player, Transformation tran) const;
|
||||||
|
void RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const;
|
||||||
|
};
|
||||||
|
#endif
|
@@ -1,23 +0,0 @@
|
|||||||
#ifndef WORLDRENDERER_H__
|
|
||||||
#define WORLDRENDERER_H__
|
|
||||||
#include <future>
|
|
||||||
#include <thread>
|
|
||||||
#include "../SQCSim-common/world.h"
|
|
||||||
#include "../SQCSim-common/transformation.h"
|
|
||||||
#include "define.h"
|
|
||||||
#include "mesh.h"
|
|
||||||
#include "textureatlas.h"
|
|
||||||
#include "shader.h"
|
|
||||||
|
|
||||||
class WorldRenderer {
|
|
||||||
private:
|
|
||||||
Array2d<Mesh*> m_meshes = Array2d<Mesh*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
|
||||||
|
|
||||||
public:
|
|
||||||
WorldRenderer();
|
|
||||||
~WorldRenderer();
|
|
||||||
|
|
||||||
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation& world, Shader& shader, TextureAtlas& atlas);
|
|
||||||
void UpdateWorld(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
|
||||||
};
|
|
||||||
#endif
|
|
Reference in New Issue
Block a user