@ -45,7 +45,6 @@ void Engine::Init() {
gluPerspective ( 45.0f , ( float ) Width ( ) / ( float ) Height ( ) , 0.1f , VIEW_DISTANCE ) ;
gluPerspective ( 45.0f , ( float ) Width ( ) / ( float ) Height ( ) , 0.1f , VIEW_DISTANCE ) ;
glShadeModel ( GL_SMOOTH ) ;
glShadeModel ( GL_SMOOTH ) ;
glHint ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ) ;
glHint ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ) ;
glDisable ( GL_BLEND ) ;
glDisable ( GL_BLEND ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
@ -167,7 +166,6 @@ void Engine::LoadResource() {
TextureAtlas : : TextureIndex StillQuarterBackRightShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_SSHOOT2 " BlueBackRightShootingRightShoot1.png " ) ; ////23
TextureAtlas : : TextureIndex StillQuarterBackRightShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_SSHOOT2 " BlueBackRightShootingRightShoot1.png " ) ; ////23
TextureAtlas : : TextureIndex StillBackShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_SSHOOT2 " BlueShootingBackRightShoot1.png " ) ; ////24
TextureAtlas : : TextureIndex StillBackShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_SSHOOT2 " BlueShootingBackRightShoot1.png " ) ; ////24
//JUMP
//JUMP
TextureAtlas : : TextureIndex JumpFront = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueFrontJumpRight.png " ) ; ////25
TextureAtlas : : TextureIndex JumpFront = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueFrontJumpRight.png " ) ; ////25
TextureAtlas : : TextureIndex JumpQuarterFrontLeft = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueLeftFrontJumpLeft.png " ) ; ////26
TextureAtlas : : TextureIndex JumpQuarterFrontLeft = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueLeftFrontJumpLeft.png " ) ; ////26
@ -178,7 +176,6 @@ void Engine::LoadResource() {
TextureAtlas : : TextureIndex JumpQuarterBackRight = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueRightBackJumpRight.png " ) ; ////31
TextureAtlas : : TextureIndex JumpQuarterBackRight = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueRightBackJumpRight.png " ) ; ////31
TextureAtlas : : TextureIndex JumpBack = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueBackJumpRight.png " ) ; ////32
TextureAtlas : : TextureIndex JumpBack = m_animeAtlas . AddTexture ( ANIME_PATH_JUMP " BlueBackJumpRight.png " ) ; ////32
//SHOOTINGJUMP SANS TIRER
//SHOOTINGJUMP SANS TIRER
TextureAtlas : : TextureIndex JumpFrontShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueFrontJumpRightShootingRight.png " ) ; ////33
TextureAtlas : : TextureIndex JumpFrontShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueFrontJumpRightShootingRight.png " ) ; ////33
TextureAtlas : : TextureIndex JumpQuarterFrontLeftShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueFrontLeftJumpLeftShootingLeft.png " ) ; ////34
TextureAtlas : : TextureIndex JumpQuarterFrontLeftShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueFrontLeftJumpLeftShootingLeft.png " ) ; ////34
@ -189,7 +186,6 @@ void Engine::LoadResource() {
TextureAtlas : : TextureIndex JumpQuarterBackRightShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueBackRightJumpRightShootingRight.png " ) ; ////39
TextureAtlas : : TextureIndex JumpQuarterBackRightShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueBackRightJumpRightShootingRight.png " ) ; ////39
TextureAtlas : : TextureIndex JumpBackShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueBackJumpRightShootingRight.png " ) ; ////40
TextureAtlas : : TextureIndex JumpBackShoot = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT1 " BlueBackJumpRightShootingRight.png " ) ; ////40
//SHOOTINGJUMP TIRER
//SHOOTINGJUMP TIRER
TextureAtlas : : TextureIndex JumpFrontShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueFrontJumpRightShootingRightShoot1.png " ) ; ////41
TextureAtlas : : TextureIndex JumpFrontShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueFrontJumpRightShootingRightShoot1.png " ) ; ////41
TextureAtlas : : TextureIndex JumpQuarterFrontLeftShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueFrontLeftJumpLeftShootingLeftShoot1.png " ) ; ////42
TextureAtlas : : TextureIndex JumpQuarterFrontLeftShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueFrontLeftJumpLeftShootingLeftShoot1.png " ) ; ////42
@ -200,8 +196,6 @@ void Engine::LoadResource() {
TextureAtlas : : TextureIndex JumpQuarterBackRightShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueBackRightJumpRightShootingRightShoot1.png " ) ; ////47
TextureAtlas : : TextureIndex JumpQuarterBackRightShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueBackRightJumpRightShootingRightShoot1.png " ) ; ////47
TextureAtlas : : TextureIndex JumpBackShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueBackJumpRightShootingRightShoot1.png " ) ; ////48
TextureAtlas : : TextureIndex JumpBackShootFire = m_animeAtlas . AddTexture ( ANIM_PATH_JSHOOT2 " BlueBackJumpRightShootingRightShoot1.png " ) ; ////48
if ( ! m_animeAtlas . Generate ( TEXTURE_SIZE , false ) ) {
if ( ! m_animeAtlas . Generate ( TEXTURE_SIZE , false ) ) {
std : : cout < < " Unable to generate texture atlas ... " < < std : : endl ;
std : : cout < < " Unable to generate texture atlas ... " < < std : : endl ;
abort ( ) ;
abort ( ) ;
@ -244,12 +238,23 @@ void Engine::LoadResource() {
std : : cout < < " Failed to load shader " < < std : : endl ;
std : : cout < < " Failed to load shader " < < std : : endl ;
exit ( 1 ) ;
exit ( 1 ) ;
}
}
// Settings
m_mainvolume = m_audio . GetMainVolume ( ) ;
m_options . SetMainVolume ( m_mainvolume ) ;
m_musicvolume = m_audio . GetMusicVolume ( ) ;
m_options . SetMusicVolume ( m_musicvolume ) ;
m_sfxvolume = m_audio . GetSfxVolume ( ) ;
m_options . SetSfxVolume ( m_sfxvolume ) ;
m_sensitivity = m_player . GetSensitivity ( ) ;
m_options . SetMouseSensitivity ( m_sensitivity ) ;
}
}
void Engine : : UnloadResource ( ) { }
void Engine : : UnloadResource ( ) { }
void Engine : : InstantDamage ( ) {
void Engine : : InstantDamage ( ) {
m_player . InflictDamage ( 0.10f ) ;
m_player . InflictDamage ( 0.10f ) ;
m_damage = false ;
m_damage = false ;
@ -720,6 +725,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
GLint viewport [ 4 ] ;
GLint viewport [ 4 ] ;
glGetIntegerv ( GL_VIEWPORT , viewport ) ;
glGetIntegerv ( GL_VIEWPORT , viewport ) ;
glDisable ( GL_STENCIL_TEST ) ;
glDisable ( GL_DEPTH_TEST ) ;
glDisable ( GL_DEPTH_TEST ) ;
glEnable ( GL_BLEND ) ;
glEnable ( GL_BLEND ) ;
@ -731,6 +737,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
glMatrixMode ( GL_MODELVIEW ) ;
glMatrixMode ( GL_MODELVIEW ) ;
glPushMatrix ( ) ;
glPushMatrix ( ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
m_textureLobbyMenu . Bind ( ) ;
m_textureLobbyMenu . Bind ( ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( 0 , 0 ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( 0 , 0 ) ;
@ -739,7 +746,6 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( 0 , Height ( ) ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( 0 , Height ( ) ) ;
glEnd ( ) ;
glEnd ( ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
if ( m_settingUsername ) {
if ( m_settingUsername ) {
SetPlayerUsername ( elapsedTime ) ;
SetPlayerUsername ( elapsedTime ) ;
@ -748,9 +754,20 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
SetServerAddress ( elapsedTime ) ;
SetServerAddress ( elapsedTime ) ;
}
}
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
m_textureOptBack . Bind ( ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width ( ) * 0.675 , Height ( ) * 0.15 ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( Width ( ) * 0.9 , Height ( ) * 0.15 ) ;
glTexCoord2f ( 1 , 1 ) ; glVertex2i ( Width ( ) * 0.9 , Height ( ) * 0.225 ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( Width ( ) * 0.675 , Height ( ) * 0.225 ) ;
glEnd ( ) ;
glViewport ( viewport [ 0 ] , viewport [ 1 ] , viewport [ 2 ] , viewport [ 3 ] ) ;
glViewport ( viewport [ 0 ] , viewport [ 1 ] , viewport [ 2 ] , viewport [ 3 ] ) ;
glEnable ( GL_STENCIL_TEST ) ;
glEnable ( GL_DEPTH_TEST ) ;
glEnable ( GL_DEPTH_TEST ) ;
glDisable ( GL_BLEND ) ;
glMatrixMode ( GL_PROJECTION ) ;
glMatrixMode ( GL_PROJECTION ) ;
glPopMatrix ( ) ;
glPopMatrix ( ) ;
@ -759,6 +776,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
}
}
void Engine : : SetPlayerUsername ( float elapsedTime ) {
void Engine : : SetPlayerUsername ( float elapsedTime ) {
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
m_textureLobbyIdentify . Bind ( ) ;
m_textureLobbyIdentify . Bind ( ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width ( ) * 0.6 , Height ( ) * 0.75 ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width ( ) * 0.6 , Height ( ) * 0.75 ) ;
@ -770,11 +788,10 @@ void Engine::SetPlayerUsername(float elapsedTime) {
glBlendFunc ( GL_SRC_ALPHA , GL_ONE ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE ) ;
HandlePlayerInput ( elapsedTime ) ;
HandlePlayerInput ( elapsedTime ) ;
glDisable ( GL_BLEND ) ;
glDisable ( GL_BLEND ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
}
void Engine : : SetServerAddress ( float elapsedTime ) {
void Engine : : SetServerAddress ( float elapsedTime ) {
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
m_textureLobbyServer . Bind ( ) ;
m_textureLobbyServer . Bind ( ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width ( ) * 0.6 , Height ( ) * 0.75 ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width ( ) * 0.6 , Height ( ) * 0.75 ) ;
@ -787,7 +804,6 @@ void Engine::SetServerAddress(float elapsedTime) {
HandlePlayerInput ( elapsedTime ) ;
HandlePlayerInput ( elapsedTime ) ;
glDisable ( GL_BLEND ) ;
glDisable ( GL_BLEND ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
}
void Engine : : DisplayPauseMenu ( float elapsedTime ) {
void Engine : : DisplayPauseMenu ( float elapsedTime ) {
@ -1003,7 +1019,6 @@ void Engine::DisplayOptionsMenu() {
glPushMatrix ( ) ;
glPushMatrix ( ) ;
m_textureOptionsMenu . Bind ( ) ;
m_textureOptionsMenu . Bind ( ) ;
glLoadIdentity ( ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( 0 , 0 ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( 0 , 0 ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( Width ( ) , 0 ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( Width ( ) , 0 ) ;
@ -1115,8 +1130,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
float principalTop = centerY + Height ( ) * 0.2f ;
float principalTop = centerY + Height ( ) * 0.2f ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , principalBottom , principalTop ) ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , principalBottom , principalTop ) ;
DrawSlider ( centerX , centerY , m_ volPrincipal , minBar , maxBar , principalBottom , principalTop ) ;
DrawSlider ( centerX , centerY , m_ mainvolume , minBar , maxBar , principalBottom , principalTop ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , principalBottom , minBar , maxBar , m_ volPrincipal ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , principalBottom , minBar , maxBar , m_ mainvolume ) ;
glEnable ( GL_BLEND ) ;
glEnable ( GL_BLEND ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
@ -1135,8 +1150,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
float musiqueTop = centerY + Height ( ) * 0.075f ;
float musiqueTop = centerY + Height ( ) * 0.075f ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , musiqueBottom , musiqueTop ) ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , musiqueBottom , musiqueTop ) ;
DrawSlider ( centerX , centerY , m_ volMusiqu e, minBar , maxBar , musiqueBottom , musiqueTop ) ;
DrawSlider ( centerX , centerY , m_ musicvolum e, minBar , maxBar , musiqueBottom , musiqueTop ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , musiqueBottom , minBar , maxBar , m_ volMusiqu e) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , musiqueBottom , minBar , maxBar , m_ musicvolum e) ;
glEnable ( GL_BLEND ) ;
glEnable ( GL_BLEND ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
@ -1155,8 +1170,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
float effectsTop = centerY - Height ( ) * 0.05f ;
float effectsTop = centerY - Height ( ) * 0.05f ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , effectsBottom , effectsTop ) ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , effectsBottom , effectsTop ) ;
DrawSlider ( centerX , centerY , m_ volEffets , minBar , maxBar , effectsBottom , effectsTop ) ;
DrawSlider ( centerX , centerY , m_ sfxvolume , minBar , maxBar , effectsBottom , effectsTop ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , effectsBottom , minBar , maxBar , m_ volEffets ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , effectsBottom , minBar , maxBar , m_ sfxvolume ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
}
@ -1174,10 +1189,10 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) {
glColor4f ( 1.0f , 1.0f , 1.0f , 0.5f ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 0.5f ) ;
glBindTexture ( GL_TEXTURE_2D , 0 ) ;
glBindTexture ( GL_TEXTURE_2D , 0 ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( centerX - Width ( ) * 0.16 , centerY + Height ( ) * 0.165 ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( Width( ) * 0.34 , Height ( ) * 0.46 ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( centerX + Width ( ) * 0.1 , centerY + Height ( ) * 0.165 ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( Width( ) * 0.6 , Height ( ) * 0.46 ) ;
glTexCoord2f ( 1 , 1 ) ; glVertex2i ( centerX + Width ( ) * 0.1 , centerY - Height ( ) * 0.04 ) ;
glTexCoord2f ( 1 , 1 ) ; glVertex2i ( Width( ) * 0.6 , Height ( ) * 0.67 ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( centerX - Width ( ) * 0.16 , centerY - Height ( ) * 0.04 ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( Width( ) * 0.34 , Height ( ) * 0.67 ) ;
glEnd ( ) ;
glEnd ( ) ;
glColor4f ( 0.0f , 0.0f , 0.0f , 1.0f ) ;
glColor4f ( 0.0f , 0.0f , 0.0f , 1.0f ) ;
@ -1243,6 +1258,7 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) {
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 ) ;
m_audio . CleanupSFX ( ) ;
if ( m_gamestate = = GameState : : SPLASH ) {
if ( m_gamestate = = GameState : : SPLASH ) {
if ( m_splashTime > 0.0f ) {
if ( m_splashTime > 0.0f ) {
@ -1280,6 +1296,11 @@ void Engine::Render(float elapsedTime) {
m_gamestate = GameState : : MAIN_MENU ;
m_gamestate = GameState : : MAIN_MENU ;
}
}
}
}
else if ( m_singleReady ) {
m_gamestate = GameState : : PLAY ;
m_audio . ToggleMusicState ( m_gamestate ) ;
m_startTime = std : : chrono : : high_resolution_clock : : now ( ) ;
}
return ;
return ;
}
}
@ -1331,11 +1352,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 ( ) , false , .8f ) ;
m_audio . Create3DAudioObj ( step , AUDIO_PATH " step.wav " , vstep , m_player . GetVelocity ( ) , false , m_sfxvolume ) ;
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 ( ) , false , 1.f ) ;
m_audio . Create3DAudioObj ( step , AUDIO_PATH " hit.wav " , m_player . GetPosition ( ) , m_player . GetVelocity ( ) , false , m_sfxvolume ) ;
break ;
break ;
default : break ;
default : break ;
}
}
@ -1364,7 +1385,7 @@ void Engine::Render(float elapsedTime) {
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 = BULLET_TIME ;
bulletTime = BULLET_TIME ;
m_audio . Create3DAudioObj ( m_powpow , AUDIO_PATH " pow.wav " , m_player . GetPOV ( ) , m_player . GetDirection ( ) * 10 , false , .5f ) ;
m_audio . Create3DAudioObj ( m_powpow , AUDIO_PATH " pow.wav " , m_player . GetPOV ( ) , m_player . GetDirection ( ) * 10 , false , m_sfxvolume ) ;
if ( m_flash ) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
if ( m_flash ) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
glClearColor ( .8f , .8f , .8f , 1.f ) ;
glClearColor ( .8f , .8f , .8f , 1.f ) ;
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 ) ;
@ -1418,7 +1439,7 @@ void Engine::Render(float elapsedTime) {
}
}
static bool died = false ;
static bool died = false ;
if ( ( m_player . GetPosition ( ) . y < - 1.7f | | m_player . AmIDead ( ) ) & & ! died ) {
if ( ( m_player . GetPosition ( ) . y < - 1.7f | | m_player . AmIDead ( ) ) & & ! died ) {
m_audio . Create3DAudioObj ( m_scream , AUDIO_PATH " scream.wav " , m_player . GetPOV ( ) , m_player . GetVelocity ( ) , false , 1.f ) ;
m_audio . Create3DAudioObj ( m_scream , AUDIO_PATH " scream.wav " , m_player . GetPOV ( ) , m_player . GetVelocity ( ) , false , m_sfxvolume ) ;
died = true ;
died = true ;
}
}
if ( m_player . GetPosition ( ) . y < - 21.f | | died ) {
if ( m_player . GetPosition ( ) . y < - 21.f | | died ) {
@ -1539,7 +1560,7 @@ void Engine::Render(float elapsedTime) {
RemotePlayer * rt = static_cast < RemotePlayer * > ( m_players [ out . id ] ) ;
RemotePlayer * rt = static_cast < RemotePlayer * > ( m_players [ out . id ] ) ;
rt - > Feed ( out ) ;
rt - > Feed ( out ) ;
if ( rt - > AmIDead ( ) ) {
if ( rt - > AmIDead ( ) ) {
m_audio . Create3DAudioObj ( m_scream , AUDIO_PATH " scream.wav " , m_player . GetPOV ( ) , m_player . GetVelocity ( ) , false , 1.f ) ;
m_audio . Create3DAudioObj ( m_scream , AUDIO_PATH " scream.wav " , m_player . GetPOV ( ) , m_player . GetVelocity ( ) , false , m_sfxvolume ) ;
}
}
}
}
break ;
break ;
@ -1569,7 +1590,7 @@ void Engine::Render(float elapsedTime) {
m_bullets [ 0 ] = bult ;
m_bullets [ 0 ] = bult ;
break ;
break ;
}
}
m_audio . Create3DAudioObj ( m_powpow , AUDIO_PATH " pow.wav " , bull . pos , bull . dir , false , 1.f ) ;
m_audio . Create3DAudioObj ( m_powpow , AUDIO_PATH " pow.wav " , bull . pos , bull . dir , false , m_sfxvolume ) ;
}
}
else SystemNotification ( " Bullet is kraput. " ) ;
else SystemNotification ( " Bullet is kraput. " ) ;
break ;
break ;
@ -1628,8 +1649,8 @@ void Engine::DisplayGameplayMenu(float centerX, float centerY) {
float sensibleTop = centerY + Height ( ) * 0.2f ;
float sensibleTop = centerY + Height ( ) * 0.2f ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , sensibleBottom , sensibleTop ) ;
DrawSliderBackground ( centerX , centerY , minBar , maxBar , sensibleBottom , sensibleTop ) ;
DrawSlider ( centerX , centerY , m_ volSensible , minBar , maxBar , sensibleBottom , sensibleTop ) ;
DrawSlider ( centerX , centerY , m_ sensitivity , minBar , maxBar , sensibleBottom , sensibleTop ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , sensibleBottom , minBar , maxBar , m_ volSensible ) ;
DisplayBarPercentValue ( centerX , centerY , percentPosX , sensibleBottom , minBar , maxBar , m_ sensitivity ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
glColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
}
@ -1649,15 +1670,23 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl
glEnable ( GL_BLEND ) ;
glEnable ( GL_BLEND ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE ) ;
glBlendFunc ( GL_SRC_ALPHA , GL_ONE ) ;
float percentage = ( value / ( maxVal - minVal ) ) * 100 ;
if ( m_selectedOption = = 0 ) {
if ( value < 0.0f ) {
value = 0.0f ;
}
}
else {
if ( value < 0.1f ) {
value = 0.1f ;
}
}
if ( percentage < 0.0f ) {
if ( value > 1.0f ) {
percentage = 0.0f ;
value = 1.0f ;
}
else if ( percentage > 100.0f ) {
percentage = 100.0f ;
}
}
float percentage = value * 100 ;
m_textureFont . Bind ( ) ;
m_textureFont . Bind ( ) ;
std : : ostringstream ss ;
std : : ostringstream ss ;
ss . str ( " " ) ;
ss . str ( " " ) ;
@ -1670,19 +1699,31 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl
}
}
void Engine : : DrawSlider ( float centerX , float centerY , float value , float minVal , float maxVal , float bottomSideValue , float topSideValue ) {
void Engine : : DrawSlider ( float centerX , float centerY , float value , float minVal , float maxVal , float bottomSideValue , float topSideValue ) {
if ( value < 0.0f ) {
float barLength = maxVal - minVal ;
value = 0.0f ;
if ( m_selectedOption = = 0 ) {
if ( value < 0.0f ) {
value = 0.0f ;
}
}
}
else if ( value > ( maxVal - minVal ) ) {
else {
value = ( maxVal - minVal ) ;
if ( value < 0.1f ) {
value = 0.1f ;
}
}
}
if ( value > = 0.0f & & value < = ( maxVal - minVal ) ) {
if ( value > 1.0f ) {
value = 1.0f ;
}
float scaledLength = minVal + value * barLength ;
if ( value > = 0.0f & & value < = 1.0f ) {
glColor4f ( 0.0f , 1.0f , 0.0f , 1.0f ) ;
glColor4f ( 0.0f , 1.0f , 0.0f , 1.0f ) ;
glBegin ( GL_QUADS ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( minVal , bottomSideValue ) ;
glTexCoord2f ( 0 , 0 ) ; glVertex2i ( minVal , bottomSideValue ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( minVal + value , bottomSideValue ) ;
glTexCoord2f ( 1 , 0 ) ; glVertex2i ( scaledLength , bottomSideValue ) ;
glTexCoord2f ( 1 , 1 ) ; glVertex2i ( minVal + value , topSideValue ) ;
glTexCoord2f ( 1 , 1 ) ; glVertex2i ( scaledLength , topSideValue ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( minVal , topSideValue ) ;
glTexCoord2f ( 0 , 1 ) ; glVertex2i ( minVal , topSideValue ) ;
glEnd ( ) ;
glEnd ( ) ;
}
}
@ -2067,9 +2108,16 @@ void Engine::HandlePlayerInput(float elapsedTime) {
m_currentInputString . size ( ) > 1 & &
m_currentInputString . size ( ) > 1 & &
m_currentInputString . size ( ) < 26 ) {
m_currentInputString . size ( ) < 26 ) {
m_username = m_currentInputString ;
m_username = m_currentInputString ;
m_player . SetUsername ( m_username ) ;
m_currentInputString = " " ;
m_currentInputString = " " ;
m_settingUsername = false ;
m_settingUsername = false ;
m_settingServer = true ;
if ( m_selectedMultiPlayer ) {
m_settingServer = true ;
}
else if ( m_selectedSinglePlayer ) {
m_singleReady = true ;
}
}
}
}
}
else if ( m_settingServer ) {
else if ( m_settingServer ) {
@ -2097,11 +2145,10 @@ void Engine::HandlePlayerInput(float elapsedTime) {
PrintText ( Width ( ) * 0.6f , Height ( ) * 0.4f , ss . str ( ) , 2.0f ) ;
PrintText ( Width ( ) * 0.6f , Height ( ) * 0.4f , ss . str ( ) , 2.0f ) ;
}
}
void Engine : : MouseMoveEvent ( int x , int y ) {
void Engine : : MouseMoveEvent ( int x , int y ) {
if ( m_gamestate = = GameState : : PLAY ) {
if ( m_gamestate = = GameState : : PLAY ) {
m_player . TurnLeftRight ( x - ( Width ( ) / 2 ) );
m_player . TurnLeftRight ( x - ( Width ( ) / 2 ) , m_sensitivity );
m_player . TurnTopBottom ( y - ( Height ( ) / 2 ) );
m_player . TurnTopBottom ( y - ( Height ( ) / 2 ) , m_sensitivity );
// 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
@ -2119,18 +2166,24 @@ void Engine::MouseMoveEvent(int x, int y) {
float centerY = Height ( ) * 0.5f ;
float centerY = Height ( ) * 0.5f ;
float leftBar = centerX - Width ( ) * 0.15f ;
float leftBar = centerX - Width ( ) * 0.15f ;
float rightBar = centerX + Width ( ) * 0.3f ;
float rightBar = centerX + Width ( ) * 0.3f ;
float barLength = rightBar - leftBar ;
float normalizedPosition = ( x - leftBar ) / barLength ;
if ( m_selectedOption = = 0 & & m_selectedOptAudioMainBar ) {
if ( m_selectedOption = = 0 & & m_selectedOptAudioMainBar ) {
m_volPrincipal = x - leftBar ;
m_mainvolume = normalizedPosition ;
m_audio . SetMainVolume ( m_mainvolume ) ;
}
}
else if ( m_selectedOption = = 0 & & m_selectedOptAudioMusicBar ) {
else if ( m_selectedOption = = 0 & & m_selectedOptAudioMusicBar ) {
m_volMusique = x - leftBar ;
m_musicvolume = normalizedPosition ;
m_audio . SetMusicVolume ( m_musicvolume ) ;
}
}
else if ( m_selectedOption = = 0 & & m_selectedOptAudioSfxBar ) {
else if ( m_selectedOption = = 0 & & m_selectedOptAudioSfxBar ) {
m_volEffets = x - leftBar ;
m_sfxvolume = normalizedPosition ;
m_audio . SetSfxVolume ( m_sfxvolume ) ;
}
}
else if ( m_selectedOption = = 2 & & m_selectedGameplaySensitivityBar ) {
else if ( m_selectedOption = = 2 & & m_selectedGameplaySensitivityBar ) {
m_ volSensible = x - leftBar ;
m_ sensitivity = normalizedPosition ;
}
}
}
}
}
}
@ -2176,19 +2229,23 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
float bottomThird = centerY + Height ( ) * 0.198f ;
float bottomThird = centerY + Height ( ) * 0.198f ;
if ( x > leftButton & & x < rightButton & & y > bottomFirst & & y < topFirst ) {
if ( x > leftButton & & x < rightButton & & y > bottomFirst & & y < topFirst ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
if ( m_selectedPlayOptions ) {
if ( m_selectedPlayOptions ) {
m_gamestate = GameState : : PLAY ;
m_gamestate = GameState : : LOBBY ;
m_audio . ToggleMusicState ( m_gamestate ) ;
m_selectedSinglePlayer = true ;
m_selectedMultiPlayer = false ;
m_settingUsername = true ;
}
}
else {
else {
m_selectedPlayOptions = true ;
m_selectedPlayOptions = true ;
}
}
}
}
else if ( x > leftButton & & x < rightButton & & y > bottomSecond & & y < topSecond ) {
else if ( x > leftButton & & x < rightButton & & y > bottomSecond & & y < topSecond ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
if ( m_selectedPlayOptions ) {
if ( m_selectedPlayOptions ) {
m_gamestate = GameState : : LOBBY ;
m_gamestate = GameState : : LOBBY ;
m_selectedMultiPlayer = true ;
m_selectedSinglePlayer = false ;
m_settingUsername = true ;
m_settingUsername = true ;
}
}
else {
else {
@ -2196,7 +2253,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
}
}
}
}
else if ( x > leftButton & & x < rightButton & & y > bottomThird & & y < topThird ) {
else if ( x > leftButton & & x < rightButton & & y > bottomThird & & y < topThird ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
if ( m_selectedPlayOptions ) {
if ( m_selectedPlayOptions ) {
m_selectedPlayOptions = false ;
m_selectedPlayOptions = false ;
}
}
@ -2227,25 +2284,26 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
float bottomBack = centerY + Height ( ) * 0.2f ;
float bottomBack = centerY + Height ( ) * 0.2f ;
if ( x > leftAudio & & x < rightAudio & & y > bottomAudio & & y < topAudio ) {
if ( x > leftAudio & & x < rightAudio & & y > bottomAudio & & y < topAudio ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_selectedOption = 0 ; // Volume
m_selectedOption = 0 ; // Volume
}
}
else if ( x > leftGraph & & x < rightGraph & & y > bottomGraph & & y < topGraph ) {
else if ( x > leftGraph & & x < rightGraph & & y > bottomGraph & & y < topGraph ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_selectedOption = 1 ; // Graphics
m_selectedOption = 1 ; // Graphics
}
}
else if ( x > leftGameplay & & x < rightGameplay & & y > bottomGameplay & & y < topGameplay ) {
else if ( x > leftGameplay & & x < rightGameplay & & y > bottomGameplay & & y < topGameplay ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_selectedOption = 2 ; // Gameplay
m_selectedOption = 2 ; // Gameplay
}
}
else if ( x > leftBack & & x < rightBack & & y > bottomBack & & y < topBack ) {
else if ( x > leftBack & & x < rightBack & & y > bottomBack & & y < topBack ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_gamestate = GameState : : MAIN_MENU ;
m_gamestate = GameState : : MAIN_MENU ;
}
}
// Audio
// Audio
float leftBar = centerX - Width ( ) * 0.15f ;
float leftBar = centerX - Width ( ) * 0.15f ;
float rightBar = centerX + Width ( ) * 0.3f ;
float rightBar = centerX + Width ( ) * 0.3f ;
float barLength = rightBar - leftBar ;
float topBarPrincipal = centerY - Height ( ) * 0.165f ;
float topBarPrincipal = centerY - Height ( ) * 0.165f ;
float bottomBarPrincipal = centerY - Height ( ) * 0.2f ;
float bottomBarPrincipal = centerY - Height ( ) * 0.2f ;
@ -2256,20 +2314,25 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
float topBarEffets = centerY + Height ( ) * 0.085f ;
float topBarEffets = centerY + Height ( ) * 0.085f ;
float bottomBarEffets = centerY + Height ( ) * 0.05f ;
float bottomBarEffets = centerY + Height ( ) * 0.05f ;
float normalizedPosition = ( x - leftBar ) / barLength ;
if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarPrincipal & & y < topBarPrincipal ) {
if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarPrincipal & & y < topBarPrincipal ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
m_volPrincipal = x - leftBar ;
m_selectedOptAudioMainBar = true ;
m_selectedOptAudioMainBar = true ;
m_mainvolume = normalizedPosition ;
m_audio . SetMainVolume ( m_mainvolume ) ;
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
}
}
else if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarMusique & & y < topBarMusique ) {
else if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarMusique & & y < topBarMusique ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
m_volMusique = x - leftBar ;
m_selectedOptAudioMusicBar = true ;
m_selectedOptAudioMusicBar = true ;
m_musicvolume = normalizedPosition ;
m_audio . SetMusicVolume ( m_musicvolume ) ;
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
}
}
else if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarEffets & & y < topBarEffets ) {
else if ( m_selectedOption = = 0 & & x > leftBar & & x < rightBar & & y > bottomBarEffets & & y < topBarEffets ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
m_volEffets = x - leftBar ;
m_selectedOptAudioSfxBar = true ;
m_selectedOptAudioSfxBar = true ;
m_sfxvolume = normalizedPosition ;
m_audio . SetSfxVolume ( m_sfxvolume ) ;
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
}
}
// Resolution
// Resolution
@ -2288,28 +2351,38 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
float topChkUHD = centerY + Height ( ) * 0.025f ;
float topChkUHD = centerY + Height ( ) * 0.025f ;
float bottomChkUHD = centerY ;
float bottomChkUHD = centerY ;
if ( m_selectedOption = = 1 & & leftChk & & x < rightChk & & y > bottomChkHD & & y < topChkHD ) {
if ( m_selectedOption = = 1 ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
if ( x > leftChk & & x < rightChk & & y > bottomChkHD & & y < topChkHD ) {
m_resolution = HD ;
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
ChangeResolution ( HD ) ;
}
else if ( x > leftChk & & x < rightChk & & y > bottomChkFHD & & y < topChkFHD ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
ChangeResolution ( FHD ) ;
}
else if ( x > leftChk & & x < rightChk & & y > bottomChkQHD & & y < topChkQHD ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
ChangeResolution ( QHD ) ;
}
else if ( x > leftChk & & x < rightChk & & y > bottomChkUHD & & y < topChkUHD ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
ChangeResolution ( UHD ) ;
}
}
}
else if ( m_selectedOption = = 1 & & x > leftChk & & x < rightChk & & y > bottomChkFHD & & y < topChkFHD ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
if ( normalizedPosition < 0.1f ) {
m_resolution = FHD ;
normalizedPosition = 0.1f ;
}
}
else if ( m_selectedOption = = 1 & & x > leftChk & & x < rightChk & & y > bottomChkQHD & & y < topChkQHD ) {
else if ( normalizedPosition > 1.0f ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
normalizedPosition = 1.0f ;
m_resolution = QHD ;
}
else if ( m_selectedOption = = 1 & & x > leftChk & & x < rightChk & & y > bottomChkUHD & & y < topChkUHD ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
m_resolution = UHD ;
}
}
// Gameplay
// Gameplay
if ( m_selectedOption = = 2 & & x > leftBar & & x < rightBar & & y > bottomBarPrincipal & & y < topBarPrincipal ) {
if ( m_selectedOption = = 2 & & x > leftBar & & x < rightBar & & y > bottomBarPrincipal & & y < topBarPrincipal ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " ) ;
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
m_volSensible = x - leftBar ;
m_selectedGameplaySensitivityBar = true ;
m_selectedGameplaySensitivityBar = true ;
m_sensitivity = normalizedPosition ;
m_player . SetSensitivity ( m_sensitivity ) ;
}
}
}
}
else if ( m_gamestate = = GameState : : PAUSE ) {
else if ( m_gamestate = = GameState : : PAUSE ) {
@ -2324,22 +2397,77 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
float bottomMainMenu = centerY - Height ( ) * 0.4415f ;
float bottomMainMenu = centerY - Height ( ) * 0.4415f ;
if ( x > leftResume & & x < rightResume & & y > bottomResume & & y < topResume ) {
if ( x > leftResume & & x < rightResume & & y > bottomResume & & y < topResume ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_gamestate = GameState : : PLAY ;
m_gamestate = GameState : : PLAY ;
m_audio . ToggleMusicState ( m_gamestate ) ;
m_audio . ToggleMusicState ( m_gamestate ) ;
}
}
else if ( x > leftMainMenu & & x < rightMainMenu & & y > bottomMainMenu & & y < topMainMenu ) {
else if ( x > leftMainMenu & & x < rightMainMenu & & y > bottomMainMenu & & y < topMainMenu ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " );
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume );
m_gamestate = GameState : : MAIN_MENU ;
m_gamestate = GameState : : MAIN_MENU ;
m_selectedPlayOptions = false ;
m_selectedPlayOptions = false ;
m_selectedSinglePlayer = false ;
m_selectedMultiPlayer = false ;
m_singleReady = false ;
m_multiReady = false ;
m_audio . ToggleMusicState ( m_gamestate ) ;
m_audio . ToggleMusicState ( m_gamestate ) ;
}
}
}
}
else if ( m_gamestate = = GameState : : LOBBY ) {
float leftBack = centerX + Width ( ) * 0.178f ;
float rightBack = centerX + Width ( ) * 0.397f ;
float topBack = centerY + Height ( ) * 0.346f ;
float bottomBack = centerY + Height ( ) * 0.275f ;
if ( leftBack & & x < rightBack & & y > bottomBack & & y < topBack ) {
m_audio . playSound ( AUDIO_PATH " snap.wav " , m_sfxvolume ) ;
m_gamestate = GameState : : MAIN_MENU ;
}
}
}
}
void Engine : : MouseReleaseEvent ( const MOUSE_BUTTON & button , int x , int y ) {
void Engine : : MouseReleaseEvent ( const MOUSE_BUTTON & button , int x , int y ) {
float centerX = Width ( ) * 0.5f ;
float centerY = Height ( ) * 0.5f ;
float leftBar = centerX - Width ( ) * 0.15f ;
float rightBar = centerX + Width ( ) * 0.3f ;
float barLength = rightBar - leftBar ;
float normalizedPosition = ( x - leftBar ) / barLength ;
if ( normalizedPosition > 1.0f ) {
normalizedPosition = 1.0f ;
}
switch ( button ) {
switch ( button ) {
case MOUSE_BUTTON_LEFT :
case MOUSE_BUTTON_LEFT :
if ( m_selectedOption = = 0 ) {
if ( normalizedPosition < 0.0f ) {
normalizedPosition = 0.0f ;
}
if ( m_selectedOptAudioMainBar ) {
m_mainvolume = normalizedPosition ;
m_audio . SetMainVolume ( m_mainvolume ) ;
}
else if ( m_selectedOptAudioMusicBar ) {
m_musicvolume = normalizedPosition ;
m_audio . SetMusicVolume ( m_musicvolume ) ;
}
else if ( m_selectedOptAudioSfxBar ) {
m_sfxvolume = normalizedPosition ;
m_audio . SetSfxVolume ( m_sfxvolume ) ;
}
}
else {
if ( m_selectedGameplaySensitivityBar ) {
if ( normalizedPosition < 0.1f ) {
normalizedPosition = 0.1f ;
}
m_sensitivity = normalizedPosition ;
m_player . SetSensitivity ( m_sensitivity ) ;
}
}
m_mouseL = false ;
m_mouseL = false ;
m_block = false ;
m_block = false ;
m_selectedOptAudioMainBar = false ;
m_selectedOptAudioMainBar = false ;
@ -2377,4 +2505,29 @@ bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool use
return true ;
return true ;
}
}
void Engine : : ChangeResolution ( Resolution resolution ) {
DeInit ( ) ;
switch ( resolution ) {
case HD :
OpenglContext : : InitWindow ( 1280 , 720 ) ;
m_resolution = HD ;
break ;
case FHD :
OpenglContext : : InitWindow ( 1920 , 1080 ) ;
m_resolution = FHD ;
break ;
case QHD :
OpenglContext : : InitWindow ( 2560 , 1440 ) ;
m_resolution = QHD ;
break ;
case UHD :
OpenglContext : : InitWindow ( 3840 , 2160 ) ;
m_resolution = UHD ;
break ;
}
Init ( ) ;
}