Commit 7c745a0e authored by pa's avatar pa

fixxxx

parent f0f74f20
......@@ -5,7 +5,7 @@
#include <iostream>
#include <sstream>
#define PORT 53000
#define PORT 53001
class Input{
......@@ -24,6 +24,7 @@ class KeyInput : public Input {
class TCPInput : public Input{
public :
TCPInput();
~TCPInput();
virtual bool isKeyPressed(sf::Keyboard::Key k);
virtual void update();
......
......@@ -12,6 +12,10 @@ bool TCPInput::isKeyPressed(sf::Keyboard::Key k){
return pressed.find(k) != pressed.end();
}
TCPInput::~TCPInput(){
thread.terminate();
}
void Input::update(){
}
......@@ -27,7 +31,7 @@ void TCPInput::connect(){
void TCPInput::update(){
sf::TcpListener listener;
if (listener.listen(53000) != sf::Socket::Done){
if (listener.listen(PORT) != sf::Socket::Done){
std::cout << "err\n";
}
sf::TcpSocket client;
......
......@@ -68,21 +68,32 @@ void World::checkCollision(){
pair.second->onCollideWith(*pair.first);
}
for(auto &pair : stack){
if(pair.first->identify() == Category::Player && pair.second->identify() == Category::Door){
if(static_cast<Door&>(*pair.second).lockLevel()
if(pair.first->identify() == Category::Player
&& pair.second->identify() == Category::Door
&& static_cast<Door&>(*pair.second).lockLevel()
<= static_cast<Player&>(*pair.first).getKeys()){
mPlayer[0] = static_cast<Player*>(mRoom->detachPlayer(*mPlayer[0]));
std::cout << "t1\n";
mPlayer[1] = static_cast<Player*>(mRoom->detachPlayer(*mPlayer[1]));
std::cout << "t2\n";
Room* room = static_cast<Room*>(mSceneGraph.detachChild(*mRoom));
std::cout << "t3\n";
mCarte.checkOut(room);
std::cout << "t4\n";
mCarte.move(static_cast<Door&>(*pair.second).getDir());
std::cout << "t5\n";
mRoom->reset();
std::cout << "t6\n";
mRoom = mCarte.checkIn();
std::cout << "t7\n";
mRoom->spawnAt(static_cast<Door&>(*pair.second).getDir());
std::cout << "t8\n";
mRoom->attachPlayer(mPlayer[0]);
std::cout << "t9\n";
mRoom->attachPlayer(mPlayer[1]);
std::cout << "ta\n";
mSceneGraph.attachChild(mRoom);
}
std::cout << "tb\n";
}
}
}
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