PlayerCharacter is moving around smoothly

This commit is contained in:
Kayne Ruse
2013-06-23 13:53:55 +10:00
parent 3232925ccd
commit d833b76856
7 changed files with 212 additions and 61 deletions
+31 -3
View File
@@ -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;
}
}