OS Windows support

master
Vectozavr 2021-10-09 17:41:12 +07:00
parent 58535b1dd7
commit 758685fe57
862 changed files with 121424 additions and 222 deletions

0
Bonus.cpp Executable file → Normal file
View File

2
Bonus.h Executable file → Normal file
View File

@ -5,7 +5,7 @@
#ifndef SHOOTER_BONUS_H
#define SHOOTER_BONUS_H
#include "World.h"
#include "engine/World.h"
#include "Player.h"
class Bonus : public RigidBody {

8
CMakeLists.txt Executable file → Normal file
View File

@ -3,11 +3,11 @@ project(shooter)
set(CMAKE_CXX_STANDARD 20)
include_directories(engine)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(shooter
# game:
main.cpp
Source.cpp
Player.cpp
Player.h
Client.cpp
@ -94,12 +94,12 @@ add_executable(shooter
engine/network/UDPSocket.h
engine/network/config.h
engine/animation/AFunction.h
)
engine/Consts.h)
if(APPLE OR UNIX)
include_directories(/usr/local/include)
else()
set(SFML_DIR "C:/Libraries/SFML/lib/cmake/SFML")
set(SFML_DIR "SFML/lib/cmake/SFML")
set(SFML_STATIC_LIBRARIES TRUE)
endif()

3
Client.cpp Executable file → Normal file
View File

@ -5,7 +5,7 @@
#include "Client.h"
#include <utility>
#include "utils/Log.h"
#include "engine/utils/Log.h"
#include "Bonus.h"
void Client::updatePacket() {
@ -71,7 +71,6 @@ void Client::processDisconnect(sf::Uint16 targetId) {
void Client::processCustomPacket(MsgType type, sf::Packet& packet) {
int buff[3];
sf::Uint16 buffId[2];
double dbuff[10];
std::string tmp, tmp2;

2
Client.h Executable file → Normal file
View File

@ -5,7 +5,7 @@
#ifndef SHOOTER_CLIENT_H
#define SHOOTER_CLIENT_H
#include "network/ClientUDP.h"
#include "engine/network/ClientUDP.h"
#include "Player.h"
class Client : public ClientUDP {

14
Player.cpp Executable file → Normal file
View File

@ -3,9 +3,9 @@
//
#include "Player.h"
#include "Screen.h"
#include "ResourceManager.h"
#include "utils/Log.h"
#include "engine/Screen.h"
#include "engine/ResourceManager.h"
#include "engine/utils/Log.h"
void Player::rotateWeaponsRelativePoint(const Point4D& point4D, const Point4D& v, double val) {
for(auto& weapon : _weapons)
@ -13,12 +13,12 @@ void Player::rotateWeaponsRelativePoint(const Point4D& point4D, const Point4D& v
}
void Player::playDeath() {
_deathSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/classic_hurt.ogg"));
_deathSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/classic_hurt.ogg"));
_deathSound.play();
}
void Player::playKill() {
_killSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/kill.ogg"));
_killSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/kill.ogg"));
_killSound.play();
}
@ -90,7 +90,7 @@ void Player::nextWeapon() {
_removeWeaponCallBack(_weapons[_selectedWeapon]);
_selectedWeapon = (_selectedWeapon + 1) % _weapons.size();
_addWeaponCallBack(_weapons[_selectedWeapon]);
Log::log("_selected _selectedWeapon " + std::to_string(_selectedWeapon));
Log::log("selectedWeapon " + std::to_string(_selectedWeapon));
_changeWeaponSound.play();
}
}
@ -104,7 +104,7 @@ void Player::previousWeapon() {
else
_selectedWeapon = _weapons.size() - 1;
_addWeaponCallBack(_weapons[_selectedWeapon]);
Log::log("_selected _selectedWeapon " + std::to_string(_selectedWeapon));
Log::log("selectedWeapon " + std::to_string(_selectedWeapon));
_changeWeaponSound.play();
}
}

16
Player.h Executable file → Normal file
View File

@ -7,9 +7,9 @@
#include <SFML/Audio/Sound.hpp>
#include <utility>
#include <ResourceManager.h>
#include "Camera.h"
#include "World.h"
#include "engine/ResourceManager.h"
#include "engine/Camera.h"
#include "engine/World.h"
#include "weapon/Ak47.h"
#include "weapon/Shotgun.h"
#include "weapon/Gun.h"
@ -41,7 +41,7 @@ private:
std::string _name = "im";
std::vector<std::shared_ptr<Weapon>> _weapons;
uint8_t _selectedWeapon = 0;
size_t _selectedWeapon = 0;
std::function<void(sf::Uint16 targetId, double)> _damagePlayerCallBack;
std::function<void(const Point4D&, const Point4D&)> _addTraceCallBack;
@ -53,16 +53,16 @@ private:
std::function<std::pair<Point4D, std::string>(const Point4D&, const Point4D&)> _rayCastFunction;
public:
Player() {
loadObj("../obj/cube.obj", "", Point4D{0.5, 1.9, 0.5});
loadObj("obj/cube.obj", "", Point4D{0.5, 1.9, 0.5});
setAcceleration(Point4D{0, -_g, 0});
setCollision(true);
setVisible(false);
setColor({240, 168, 168});
_changeWeaponSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/weapons/change_weapon.ogg"));
_changeWeaponSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/weapons/change_weapon.ogg"));
_fullHealthSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/fullHealth.ogg"));
_fullAbilitySound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/fullAbility.ogg"));
_fullHealthSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/fullHealth.ogg"));
_fullAbilitySound.setBuffer(*ResourceManager::loadSoundBuffer("sound/fullAbility.ogg"));
setCollisionCallBack([this](const std::string& objName, std::shared_ptr<RigidBody> obj) {collisionWithObject(objName, obj);});
};

View File

@ -3,19 +3,19 @@
//
#include "PlayerController.h"
#include "utils/Log.h"
#include "animation/AColor.h"
#include "animation/AFunction.h"
#include "animation/AWait.h"
#include "animation/ATranslate.h"
#include "animation/ATranslateToPoint.h"
#include "animation/Timeline.h"
#include "engine/utils/Log.h"
#include "engine/animation/AColor.h"
#include "engine/animation/AFunction.h"
#include "engine/animation/AWait.h"
#include "engine/animation/ATranslate.h"
#include "engine/animation/ATranslateToPoint.h"
#include "engine/animation/Timeline.h"
PlayerController::PlayerController(std::shared_ptr<Player> player,
std::shared_ptr<Keyboard> keyboard,
std::shared_ptr<Mouse> mouse) : _player(player), _keyboard(keyboard), _mouse(mouse) {
_slowMoSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/slow_mo.ogg"));
_unSlowMoSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/unslow_mo.ogg"));
_slowMoSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/slow_mo.ogg"));
_unSlowMoSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/unslow_mo.ogg"));
}
void PlayerController::update() {
@ -47,25 +47,25 @@ void PlayerController::update() {
std::shared_ptr<Object> camera = _player->attached("camera");
if(_inRunning) {
if (!Timeline::isInAnimList("camera_hor_oscil")) {
Timeline::animate("camera_hor_oscil", new ATranslate(camera, -camera->left() / 6, 0.3,Animation::LoopOut::None, Animation::cos));
Timeline::animate("camera_hor_oscil", new ATranslate(camera, -camera->left() / 6, 0.3,Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_hor_oscil", new AWait(0));
Timeline::animate("camera_hor_oscil", new ATranslate(camera, camera->left() / 6, 0.3, Animation::LoopOut::None, Animation::cos));
Timeline::animate("camera_hor_oscil", new ATranslate(camera, camera->left() / 6, 0.3, Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, -Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::cos));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, -Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_vert_oscil", new AWait(0));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None,Animation::cos));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_vert_oscil", new AWait(0));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, -Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::cos));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, -Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_vert_oscil", new AWait(0));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::cos));
Timeline::animate("camera_vert_oscil", new ATranslate(camera, Point4D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos));
Timeline::animate("camera_init", new ATranslateToPoint( camera, _player->position() + Point4D{0, 1.8, 0}, 0.3, Animation::None, Animation::cos));
Timeline::animate("camera_init", new ATranslateToPoint( camera, _player->position() + Point4D{0, 1.8, 0}, 0.3, Animation::LoopOut::None, Animation::InterpolationType::cos));
}
} else if(inRunning_old && !_inRunning) {
Timeline::deleteAnimationList("camera_hor_oscil");
Timeline::deleteAnimationList("camera_vert_oscil");
Timeline::deleteAnimationList("camera_init");
Timeline::animate("camera_init", new ATranslateToPoint( camera, _player->position() + Point4D{0, 1.8, 0}, 0.15, Animation::None, Animation::cos));
Timeline::animate("camera_init", new ATranslateToPoint( camera, _player->position() + Point4D{0, 1.8, 0}, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos));
}
// Left and right
@ -111,8 +111,18 @@ void PlayerController::update() {
}
if (Keyboard::isKeyPressed(sf::Keyboard::Space) && _player->inCollision()) {
_player->addVelocity(Point4D{0, std::abs(_player->collisionNormal().y()) * sqrt(2 * _g * _jumpHeight) * coeff, 0});
_player->translate(Point4D{0, Time::deltaTime() * _walkSpeed * 2 * coeff, 0});
// if we just want to jump, we have to add particular speed
if (!_isSliding)
_player->addVelocity(Point4D{ 0, std::abs(_player->collisionNormal().y()) * sqrt(2 * -_player->acceleration().y() * _jumpHeight) * coeff, 0 });
// if we want to slide, we have to add speed * 60/fps to make it independent on frame rate
else
_player->addVelocity(Point4D{ 0, std::abs(_player->collisionNormal().y()) * sqrt(2 * -_player->acceleration().y() * _jumpHeight) * coeff * 60.0 / Time::fps(), 0 });
_player->translate(Point4D{ 0, Time::deltaTime() * _walkSpeed * 2 * coeff * 60.0 / Time::fps(), 0 });
_isSliding = true;
} else {
_isSliding = false;
}
// Mouse movement
@ -124,10 +134,10 @@ void PlayerController::update() {
double rotationLeft = displacement.y() / 1000.0;
// You can only see in range [-90 : 90] grad
if (_player->headAngle() + rotationLeft > M_PI / 2)
rotationLeft = M_PI / 2 - _player->headAngle();
if (_player->headAngle() + rotationLeft < -M_PI / 2)
rotationLeft = -M_PI / 2 - _player->headAngle();
if (_player->headAngle() + rotationLeft > Consts::PI / 2)
rotationLeft = Consts::PI / 2 - _player->headAngle();
if (_player->headAngle() + rotationLeft < -Consts::PI / 2)
rotationLeft = -Consts::PI / 2 - _player->headAngle();
_player->setHeadAngle(_player->headAngle() + rotationLeft);
_player->rotateWeaponsRelativePoint(_player->position() + Point4D{0, 1.8, 0}, _player->left(), rotationLeft);
@ -149,8 +159,8 @@ void PlayerController::update() {
}
if ((_inRunning || _player->velocity().sqrAbs() > 3) && _player->inCollision() && _walkSound.getStatus() != sf::Sound::Status::Playing) {
int soundNum = round((double) rand() / RAND_MAX * 5) + 1;
_walkSound.setBuffer(*ResourceManager::loadSoundBuffer("../sound/stonestep" + std::to_string(soundNum) + ".ogg"));
int soundNum = (int)((double) rand() / RAND_MAX * 5) + 1;
_walkSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/stonestep" + std::to_string(soundNum) + ".ogg"));
_walkSound.play();
}
}

View File

@ -6,8 +6,8 @@
#define SHOOTER_PLAYERCONTROLLER_H
#include "Player.h"
#include "Keyboard.h"
#include "Mouse.h"
#include "engine/Keyboard.h"
#include "engine/Mouse.h"
class PlayerController {
private:
@ -16,11 +16,10 @@ private:
std::shared_ptr<Mouse> _mouse;
bool _inRunning = false;
bool _isSliding = false;
double _slowMoCoefficient = 5;
bool _isInSlowMo = false;
double _g = 35;
sf::Sound _slowMoSound;
sf::Sound _unSlowMoSound;
sf::Sound _walkSound;

0
README.md Executable file → Normal file
View File

BIN
SFML/bin/openal32.dll Normal file

Binary file not shown.

BIN
SFML/bin/sfml-audio-2.dll Normal file

Binary file not shown.

BIN
SFML/bin/sfml-audio-d-2.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
SFML/bin/sfml-network-2.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
SFML/bin/sfml-system-2.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
SFML/bin/sfml-window-2.dll Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,98 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SFML - Simple and Fast Multimedia Library</title>
<meta http-equiv="Content-Type" content="text/html;"/>
<meta charset="utf-8"/>
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
</head>
<body>
<div id="banner-container">
<div id="banner">
<span id="sfml">SFML 2.5.1</span>
</div>
</div>
<div id="content">
<!-- Generated by Doxygen 1.8.14 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_c0a853e81d6f1c1f0a3eb7a27dc24256.html">SFML</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> </div>
<div class="headertitle">
<div class="title">GpuPreference.hpp File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Headers.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;SFML/Config.hpp&gt;</code><br />
</div>
<p><a href="GpuPreference_8hpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ab0233c2d867cbd561036ed2440a4fec0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="GpuPreference_8hpp.html#ab0233c2d867cbd561036ed2440a4fec0">SFML_DEFINE_DISCRETE_GPU_PREFERENCE</a></td></tr>
<tr class="memdesc:ab0233c2d867cbd561036ed2440a4fec0"><td class="mdescLeft">&#160;</td><td class="mdescRight">A macro to encourage usage of the discrete GPU. <a href="#ab0233c2d867cbd561036ed2440a4fec0">More...</a><br /></td></tr>
<tr class="separator:ab0233c2d867cbd561036ed2440a4fec0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Headers. </p>
<p>File containing SFML_DEFINE_DISCRETE_GPU_PREFERENCE </p>
<p class="definition">Definition in file <a class="el" href="GpuPreference_8hpp_source.html">GpuPreference.hpp</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ab0233c2d867cbd561036ed2440a4fec0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab0233c2d867cbd561036ed2440a4fec0">&#9670;&nbsp;</a></span>SFML_DEFINE_DISCRETE_GPU_PREFERENCE</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE</td>
</tr>
</table>
</div><div class="memdoc">
<p>A macro to encourage usage of the discrete GPU. </p>
<p>In order to inform the Nvidia/AMD driver that an SFML application could benefit from using the more powerful discrete GPU, special symbols have to be publicly exported from the final executable.</p>
<p>SFML defines a helper macro to easily do this.</p>
<p>Place SFML_DEFINE_DISCRETE_GPU_PREFERENCE in the global scope of a source file that will be linked into the final executable. Typically it is best to place it where the main function is also defined. </p>
<p class="definition">Definition at line <a class="el" href="GpuPreference_8hpp_source.html#l00069">69</a> of file <a class="el" href="GpuPreference_8hpp_source.html">GpuPreference.hpp</a>.</p>
</div>
</div>
</div><!-- contents -->
</div>
<div id="footer-container">
<div id="footer">
SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
Copyright &copy; Laurent Gomila &nbsp;::&nbsp;
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> &nbsp;::&nbsp;
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More