PlayerCharacter is moving around smoothly
This commit is contained in:
+31
-3
@@ -34,6 +34,7 @@ InWorld::InWorld() {
|
||||
cout << "entering InWorld" << endl;
|
||||
#endif
|
||||
cout << "Client Index: " << infoMgr->GetClientIndex() << endl;
|
||||
pc.GetSprite()->SetSurface(surfaceMgr->Get("elliot"), 32, 48);
|
||||
}
|
||||
|
||||
InWorld::~InWorld() {
|
||||
@@ -52,6 +53,7 @@ void InWorld::FrameStart() {
|
||||
|
||||
void InWorld::Update(double delta) {
|
||||
while(HandlePacket(popNetworkPacket()));
|
||||
pc.Update(delta);
|
||||
}
|
||||
|
||||
void InWorld::FrameEnd() {
|
||||
@@ -59,7 +61,7 @@ void InWorld::FrameEnd() {
|
||||
}
|
||||
|
||||
void InWorld::Render(SDL_Surface* const screen) {
|
||||
//
|
||||
pc.DrawTo(screen);
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
@@ -89,11 +91,37 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
case SDLK_ESCAPE:
|
||||
ExitGame();
|
||||
break;
|
||||
case SDLK_w:
|
||||
pc.MoveDirection(CardinalDirection::NORTH);
|
||||
break;
|
||||
case SDLK_s:
|
||||
pc.MoveDirection(CardinalDirection::SOUTH);
|
||||
break;
|
||||
case SDLK_a:
|
||||
pc.MoveDirection(CardinalDirection::EAST);
|
||||
break;
|
||||
case SDLK_d:
|
||||
pc.MoveDirection(CardinalDirection::WEST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InWorld::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
//
|
||||
//reversed
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_w:
|
||||
pc.MoveDirection(CardinalDirection::SOUTH);
|
||||
break;
|
||||
case SDLK_s:
|
||||
pc.MoveDirection(CardinalDirection::NORTH);
|
||||
break;
|
||||
case SDLK_a:
|
||||
pc.MoveDirection(CardinalDirection::WEST);
|
||||
break;
|
||||
case SDLK_d:
|
||||
pc.MoveDirection(CardinalDirection::EAST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
@@ -170,4 +198,4 @@ void InWorld::HandleDisconnection(::Disconnect& disconnect) {
|
||||
Disconnect();
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
cout << "You have been disconnected" << endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user