Commit bed9d01b by Thomas Brandého
parents d462158b a4e9a6ee
......@@ -204,7 +204,13 @@ void Client::update(sf::RenderWindow& window)
hasMoved = false;
break;
case sf::Keyboard::Escape:
window.close();
m_server.disconnect();
m_connected = false;
m_authenticated = false;
m_menu->setConnecting(false);
m_menu->setStartPressed(false);
m_graphics->initMenu(m_menu);
m_graphics->setMessage("");
break;
default:
hasMoved = false;
......
......@@ -17,7 +17,7 @@ CrateEntity::~CrateEntity()
sf::Vector2f CrateEntity::getRenderPosition(float time)
{
int moveFrame = int(time * 64) % 32;
int moveFrame = int(time * 32 / REFRESH_TIME) % 32;
return sf::Vector2f(m_position*32 + m_moveDir*(moveFrame-32));
}
......
......@@ -93,7 +93,7 @@ void Graphics::renderMap(sf::RenderWindow &window, MapKoban& map)
float currentTick = m_clock->getElapsedTime().asSeconds();
if(currentTick - m_current_turn_tick > 0.5)
if(currentTick - m_current_turn_tick > REFRESH_TIME)
{
// if(m_main_player != nullptr) // temp debug code
// {
......@@ -104,7 +104,7 @@ void Graphics::renderMap(sf::RenderWindow &window, MapKoban& map)
// increment turn
m_current_turn++;
m_current_turn_tick += 0.5;
m_current_turn_tick += REFRESH_TIME;
// reset animations
for(CrateEntity* c : m_crates)
......@@ -185,6 +185,7 @@ void Graphics::initMenu(Menu* menu)
for(auto pe : m_players)
delete pe.second;
m_players.clear();
m_diffs.clear();
}
void Graphics::renderMenu(sf::RenderWindow &window, Menu* menu)
......
......@@ -30,7 +30,7 @@ PlayerEntity::~PlayerEntity()
sf::Vector2f PlayerEntity::getRenderPosition(float time)
{
int moveFrame = int(time * 64) % 32;
int moveFrame = int(time * 32 / REFRESH_TIME) % 32;
return sf::Vector2f(m_position*32 + m_moveDir*(moveFrame-32));
}
......
......@@ -2,7 +2,7 @@
#define DEFINES_H
const unsigned short TCP_PORT = 42024;
const float REFRESH_TIME = 0.1;
const float REFRESH_TIME = 0.25;
enum TileType {
FLOOR,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment