-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add client test and add directory for server and client
- Loading branch information
michaeldomanek
authored and
michaeldomanek
committed
Mar 15, 2021
1 parent
748f5f9
commit 0e896a6
Showing
30 changed files
with
239 additions
and
146 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "robotProperties.h" | ||
|
||
#include "asio.hpp" | ||
#include <SFML/Graphics.hpp> | ||
|
||
#include <string> | ||
|
||
using namespace std; | ||
using namespace asio; | ||
using namespace asio::ip; | ||
|
||
class Connection { | ||
private: | ||
|
||
public: | ||
Connection(string port, RobotProperties prop) { | ||
|
||
tcp::iostream strm{"localhost", port}; | ||
|
||
try { | ||
if (strm) { | ||
strm << prop.getName() << endl; | ||
strm.close(); | ||
} | ||
} catch (asio::system_error& e) { | ||
// return 0; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "connection.h" | ||
|
||
#include "CLI11.hpp" | ||
// todo: remvoe cli11 from client | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char* argv[]) { | ||
CLI::App app("Daytime Server"); | ||
|
||
string port{"1113"}; | ||
app.add_option("-p,--port", port, "port to connect to"); | ||
|
||
string name{"name"}; | ||
app.add_option("-n,--name", name, "name", true); | ||
|
||
CLI11_PARSE(app, argc, argv); | ||
|
||
RobotProperties properties{name, sf::Color::Blue}; | ||
|
||
Connection c{port, properties}; | ||
|
||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "robot.h" | ||
#include "bulletConfiguration.h" | ||
|
||
#include <SFML/Graphics.hpp> | ||
|
||
class Bullet { | ||
private: | ||
sf::Sprite sprite; | ||
float speed; | ||
float damage; | ||
Robot* attacker; | ||
sf::Vector2f movement; | ||
sf::Vector2f getMoveVector(float speed); | ||
public: | ||
Bullet(sf::Sprite turret, Robot* attacker, BulletConfiguration config); | ||
|
||
void move(); | ||
sf::Sprite getSprite(); | ||
Robot* getAttacker(); | ||
float getDamage(); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "bullet.h" | ||
#include "robot.h" | ||
|
||
#include <math.h> | ||
#include <SFML/Graphics.hpp> | ||
|
||
using namespace std; | ||
|
||
Bullet::Bullet(sf::Sprite turret, Robot* attacker, BulletConfiguration config): | ||
speed(config.getSpeed()), | ||
damage(config.getDamage()), | ||
attacker(attacker) | ||
{ | ||
const unsigned int size{config.getSize()}; | ||
|
||
sf::Texture tex; | ||
tex.create(size, size); | ||
|
||
sprite.setTexture(tex); | ||
sprite.setPosition(turret.getPosition()); | ||
sprite.setRotation(turret.getRotation()); | ||
sprite.setColor(sf::Color::White); | ||
sprite.setOrigin(size / 2, size / 2); | ||
sprite.setScale(1.5, 1.5); | ||
|
||
//move to firepoint | ||
movement = getMoveVector(speed); | ||
sprite.move(25 * 1.5 * movement.x / speed, 25 * 1.5 * movement.y / speed); | ||
} | ||
|
||
sf::Vector2f Bullet::getMoveVector(float speed) { | ||
float angle = sprite.getRotation() * M_PI / 180; | ||
return sf::Vector2f{sin(angle) * speed, cos(angle) * -speed}; | ||
} | ||
|
||
void Bullet::move() { | ||
sprite.move(movement.x, movement.y); | ||
} | ||
|
||
sf::Sprite Bullet::getSprite() { | ||
return sprite; | ||
} | ||
|
||
Robot* Bullet::getAttacker() { | ||
return attacker; | ||
} | ||
|
||
float Bullet::getDamage() { | ||
return damage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
0
src/resources/body-grey.png → server/src/resources/body-grey.png
100755 → 100644
File renamed without changes
File renamed without changes
0
src/resources/explosion.png → server/src/resources/explosion.png
100755 → 100644
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.