Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f8680a318a | ||
|
f4d4f1eca0 | ||
|
793da52871 | ||
|
18a5d98c57 | ||
|
81240c6f70 | ||
|
f1ddd67655 | ||
|
9cbf20ba21 | ||
|
f2095f6e5b | ||
|
93062e49e2 | ||
|
c85f7df15e | ||
|
cddc59d6cf | ||
|
965e78309e | ||
|
0452920697 | ||
|
8be8852596 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -373,3 +373,8 @@ 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/*
|
||||||
|
!/SQCSim-srv/cmake/CMakeLists.txt
|
||||||
|
/SQCSim2021/cmake/*
|
||||||
|
!/SQCSim2021/cmake/CMakeLists.txt
|
||||||
|
/SQCSim2021/SQCSim-client
|
||||||
|
@@ -7,8 +7,9 @@ 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) {
|
bool Bullet::Update(World* world, float elapsedtime, int perframe) {
|
||||||
for (int x = 0; x < 1000; ++x) {
|
int max = 100 / perframe;
|
||||||
|
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))
|
||||||
@@ -30,10 +31,14 @@ void Bullet::Transpose(int& x, int& z) {
|
|||||||
m_startpos.z -= z * CHUNK_SIZE_Z;
|
m_startpos.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f Bullet::getPos() {
|
Vector3f Bullet::getPos() const {
|
||||||
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,9 +12,10 @@ 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);
|
bool Update(World* world, float elapsedtime, int perframe);
|
||||||
void Transpose(int& x, int& z);
|
void Transpose(int& x, int& z);
|
||||||
Vector3f getPos();
|
Vector3f getPos() const;
|
||||||
|
Vector3f getVel() const;
|
||||||
uint64_t getTeamID();
|
uint64_t getTeamID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -53,6 +53,7 @@ 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
|
||||||
|
@@ -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], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
|
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
UpdateWorld(player_pos, blockinfo);
|
UpdateWorld(player_pos, blockinfo);
|
||||||
//TransposeWorld(player_pos, bullets);
|
//TransposeWorld(player_pos, bullets);
|
||||||
}
|
}
|
||||||
|
@@ -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], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
|
||||||
void GetScope(unsigned int& x, unsigned int& y);
|
void GetScope(unsigned int& x, unsigned int& y);
|
||||||
|
|
||||||
|
30
SQCSim-srv/cmake/CMakeLists.txt
Normal file
30
SQCSim-srv/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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)
|
@@ -85,7 +85,7 @@ int Server::Ready() {
|
|||||||
|
|
||||||
while (!readystart) {
|
while (!readystart) {
|
||||||
sockaddr_in sockad;
|
sockaddr_in sockad;
|
||||||
int addrlen = sizeof(sockad);
|
unsigned 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::Timestamp() {
|
inline std::string Server::LogTimestamp() {
|
||||||
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::Timestamp() {
|
|||||||
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 << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
m_logfile << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
||||||
break;
|
break;
|
||||||
case LOG_DEST::CONSOLE:
|
case LOG_DEST::CONSOLE:
|
||||||
default:
|
default:
|
||||||
std::cout << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
std::cout << LogTimestamp() << (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 Timestamp();
|
std::string LogTimestamp();
|
||||||
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);
|
||||||
|
|
||||||
|
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
Audio::Audio() {
|
Audio::Audio() {
|
||||||
m_engine = irrklang::createIrrKlangDevice();
|
m_engine = irrklang::createIrrKlangDevice();
|
||||||
m_engine->setDopplerEffectParameters(1);
|
m_engine->setDopplerEffectParameters(10);
|
||||||
m_engine->setRolloffFactor(1);
|
m_engine->setRolloffFactor(2);
|
||||||
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(1);
|
m_engine->setRolloffFactor(2);
|
||||||
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,10 +28,11 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume = 1) {
|
irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) {
|
||||||
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), false, false, true, irrklang::ESM_NO_STREAMING, true);
|
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->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,24 +1,30 @@
|
|||||||
#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);
|
||||||
|
|
||||||
void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume);
|
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
|
||||||
|
|
||||||
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
||||||
|
|
||||||
|
68
SQCSim2021/cmake/CMakeLists.txt
Normal file
68
SQCSim2021/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
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}
|
||||||
|
)
|
||||||
|
|
@@ -6,23 +6,30 @@
|
|||||||
#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 640
|
#define BASE_WIDTH 640
|
||||||
#define BASE_HEIGHT 480
|
#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/"
|
||||||
|
0
SQCSim2021/docs/analyse_preliminaire.md
Normal file
0
SQCSim2021/docs/analyse_preliminaire.md
Normal file
1
SQCSim2021/docs/analyse_serveur.md
Normal file
1
SQCSim2021/docs/analyse_serveur.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
@@ -28,6 +28,56 @@ 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()
|
void Engine::DrawMenu()
|
||||||
{
|
{
|
||||||
static const int sTitle = 400;
|
static const int sTitle = 400;
|
||||||
@@ -223,6 +273,8 @@ void Engine::DrawMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -256,8 +308,10 @@ 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";
|
||||||
@@ -279,6 +333,8 @@ 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();
|
||||||
@@ -294,6 +350,7 @@ void Engine::LoadResource() {
|
|||||||
|
|
||||||
LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png");
|
LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png");
|
||||||
LoadTexture(MenuBGTexture, 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(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
||||||
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
|
||||||
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
|
||||||
@@ -645,7 +702,10 @@ int Engine::GetCountdown(float elapsedTime) {
|
|||||||
void Engine::Render(float elapsedTime) {
|
void Engine::Render(float elapsedTime) {
|
||||||
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);
|
||||||
|
|
||||||
if (m_gamestate == GameState::PLAY)
|
m_time_SplashScreen += elapsedTime;
|
||||||
|
if(m_time_SplashScreen < 2)
|
||||||
|
DrawSplachScreen();
|
||||||
|
else if (m_gamestate == GameState::PLAY)
|
||||||
{
|
{
|
||||||
HideCursor();
|
HideCursor();
|
||||||
CenterMouse(); //D<>placement de centermouse dans l'action de jouer
|
CenterMouse(); //D<>placement de centermouse dans l'action de jouer
|
||||||
@@ -680,11 +740,11 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (leftright)
|
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);
|
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);
|
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);
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false,.8f);
|
||||||
leftright = !leftright;
|
leftright = !leftright;
|
||||||
break;
|
break;
|
||||||
case Player::Sound::FALL:
|
case Player::Sound::FALL:
|
||||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f);
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false,1.f);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@@ -717,24 +777,27 @@ void Engine::Render(float elapsedTime) {
|
|||||||
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.
|
for (int x = 0; x < MAX_BULLETS; ++x) { // Array de bullets en jeu.
|
||||||
if (m_bullets[x])
|
if (m_bullets[x]) {
|
||||||
if (m_bullets[x]->Update(&m_world, elapsedTime)) {
|
for (int b = 0; b < BULLET_UPDATES_PER_FRAME; ++b)
|
||||||
|
if (m_bullets[x]->Update(&m_world, elapsedTime, BULLET_UPDATES_PER_FRAME)) {
|
||||||
m_bullets[x]->~Bullet();
|
m_bullets[x]->~Bullet();
|
||||||
|
if (m_whoosh[x])
|
||||||
|
m_whoosh[x]->drop();
|
||||||
m_bullets[x] = nullptr;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_wrenderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
m_wrenderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
@@ -748,13 +811,14 @@ void Engine::Render(float elapsedTime) {
|
|||||||
|
|
||||||
static bool fell = false;
|
static bool fell = false;
|
||||||
if (m_player.GetPosition().y < 1.7f && !fell) {
|
if (m_player.GetPosition().y < 1.7f && !fell) {
|
||||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f);
|
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false,1.f);
|
||||||
fell = true;
|
fell = true;
|
||||||
}
|
}
|
||||||
else if (m_player.GetPosition().y < -20.f) {
|
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.
|
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
|
||||||
fell = false;
|
fell = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
||||||
{
|
{
|
||||||
@@ -818,6 +882,8 @@ 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
|
||||||
@@ -867,6 +933,17 @@ 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;
|
||||||
|
@@ -25,6 +25,7 @@ public:
|
|||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
virtual void DrawMenu();
|
virtual void DrawMenu();
|
||||||
|
virtual void DrawSplachScreen();
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
virtual void LoadResource();
|
virtual void LoadResource();
|
||||||
@@ -71,8 +72,9 @@ 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,
|
||||||
irrklang::ISound* m_scream;
|
* 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));
|
||||||
|
|
||||||
@@ -86,9 +88,13 @@ private:
|
|||||||
Texture MenuStartTexture;
|
Texture MenuStartTexture;
|
||||||
Texture MenuQuitTexture;
|
Texture MenuQuitTexture;
|
||||||
Texture MenuOptionsTexture;
|
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;
|
||||||
|
BIN
SQCSim2021/media/audio/noise.wav
Normal file
BIN
SQCSim2021/media/audio/noise.wav
Normal file
Binary file not shown.
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
SQCSim2021/media/textures/sc2.png
Normal file
BIN
SQCSim2021/media/textures/sc2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 195 KiB |
@@ -9,6 +9,7 @@ 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;
|
||||||
@@ -22,12 +23,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;
|
sf::Event Event;
|
||||||
while (m_app.pollEvent(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();
|
||||||
@@ -51,7 +53,7 @@ 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);
|
||||||
@@ -68,7 +70,7 @@ bool OpenglContext::Start(const std::string& title, int width, int height, bool
|
|||||||
|
|
||||||
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
|
||||||
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
|
||||||
if(waitTime > 0)
|
if (waitTime > 0)
|
||||||
{
|
{
|
||||||
sf::sleep(sf::seconds(waitTime));
|
sf::sleep(sf::seconds(waitTime));
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#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
|
||||||
@@ -31,7 +32,6 @@ 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();
|
||||||
|
|
||||||
|
@@ -211,3 +211,4 @@ void WorldRenderer::UpdateWorld(World* origin, const Vector3f& player, BlockInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user