Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rommmmaha committed Jun 6, 2024
1 parent 16b9925 commit 92fba81
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
19 changes: 10 additions & 9 deletions client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ game::game()

fps = 10;
scale = 20;
debug = false;
running = true;
needInitialization = true;
number_of_enemies = 2;

map = nullptr;
tmp_map = nullptr;

sb_intro.loadFromFile("resources/intro.wav");
sb_damaged.loadFromFile("resources/damaged.wav");
sb_captured.loadFromFile("resources/captured.wav");
Expand Down Expand Up @@ -272,10 +276,10 @@ void game::update()
}

if (left.size() < right.size())
for (auto i : left)
for (auto &i : left)
map[pos2index(i.x, i.y, map_size.x)] = 1;
else
for (auto i : right)
for (auto &i : right)
map[pos2index(i.x, i.y, map_size.x)] = 1;

leftNeighbours.clear();
Expand Down Expand Up @@ -431,17 +435,14 @@ void game::draw()
if (3 < seconds)
{
_RenderWindow->setFramerateLimit(fps);
alpha = int((5 - _GlobalClock.getElapsedTime().asSeconds()) / 2.0f) * 255;
alpha2 = int((5 - _GlobalClock.getElapsedTime().asSeconds()) / 2.0f) * 255;
alpha = int((5 - _GlobalClock.getElapsedTime().asSeconds()) / 2.0f * 255);
alpha2 = alpha;
}

sf::Text _Text;
_Text.setString("xonix-X");
_Text.setFont(font);
_Text.setCharacterSize(100);
sf::Text _Text("xonix-X", font, 120);
_Text.setPosition(sf::Vector2f(_RenderWindow->getSize().x / 2 - _Text.getGlobalBounds().width / 2,
_RenderWindow->getSize().y / 2 - _Text.getGlobalBounds().height / 2 -
_Text.getCharacterSize()));
_Text.getCharacterSize() / 2));
_Text.setFillColor(sf::Color(255, 255, 255, alpha));
sf::RectangleShape bg(V2_convert<float>(_RenderWindow->getSize()));
bg.setFillColor(sf::Color(0, 0, 0, alpha2));
Expand Down
2 changes: 1 addition & 1 deletion client/myfunc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ template <typename T> T max(T a, T b)
// Vector2 functions
template <typename T, typename U> sf::Vector2<T> V2_convert(sf::Vector2<U> a)
{
return sf::Vector2<T>(a.x, a.y);
return sf::Vector2<T>(T(a.x), T(a.y));
}

template <typename T> sf::Vector2<T> V2_invert(sf::Vector2<T> a)
Expand Down
9 changes: 6 additions & 3 deletions client/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
class object : public sf::Vector2i
{
public:
sf::Vector2i previous = sf::Vector2i(0, 0);
int direction;
int type; // 1 - player, 2 - enemy
int direction;
sf::RectangleShape shape;
sf::Vector2i previous = sf::Vector2i(0, 0);
object()
{
this->x = 0;
this->y = 0;
int direction = 0;
this->type = 0;
this->direction = 0;
this->previous = sf::Vector2i(0, 0);
}
object(int type, int x = 0, int y = 0)
{
this->type = type;
this->x = x;
this->y = y;
this->direction = 0;
this->previous = sf::Vector2i(0, 0);
if (this->type == 2)
this->direction = rand() % 4;
}
Expand Down

0 comments on commit 92fba81

Please sign in to comment.