X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=inline;f=src%2Fmap%2FMapState.cpp;h=b18d75da38f685c877618de0796d0dcc3a15ea62;hb=HEAD;hp=9bae990ce6d72c053ce1b252a48a121cf49d0f67;hpb=0911d263c10cca314305799d5b839ee9653cac0b;p=l2e.git diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index 9bae990..b18d75d 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -32,7 +32,7 @@ MapState::MapState(GameConfig *g, Map *map) , pushed(0) , lastLock(-1, -1) , camera(100, 100, 0) -, walkingSpeed(64) +, walkingSpeed(1) , nextDirection(-1) , afterLock(false) , skipLock(false) @@ -43,7 +43,8 @@ MapState::MapState(GameConfig *g, Map *map) void MapState::OnEnterState(SDL_Surface *screen) { - camera.Resize(screen->w, screen->h); + OnResize(screen->w, screen->h); + tileAnimation = GraphicsTimers().StartInterval(512); LoadMap(map); } @@ -52,7 +53,7 @@ void MapState::OnExitState(SDL_Surface *screen) { } void MapState::OnResumeState(SDL_Surface *screen) { - camera.Resize(screen->w, screen->h); + OnResize(screen->w, screen->h); } void MapState::OnPauseState(SDL_Surface *screen) { @@ -64,6 +65,12 @@ void MapState::OnResize(int width, int height) { } +void MapState::SetWalkingSpeed(int s) { + walkingSpeed = math::Fixed<8>(1, s); + Timestep(s); +} + + void MapState::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_X)) { Ctrl().PushState(new PartyMenu(game)); @@ -101,6 +108,7 @@ void MapState::UpdateWorld(Uint32 deltaT) { } void MapState::OnTileLock() { + // moveTimer is running when the pc is walking against a wall if (moveTimer.Running() && !moveTimer.JustHit()) return; Vector nowLock(ToInt(controlled->Position())); @@ -463,7 +471,7 @@ void MapState::Render(SDL_Surface *screen) { SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); Vector offset(camera.CalculateOffset()); - map->Render(screen, offset); + map->Render(screen, offset, tileAnimation.Iteration()); if (debug) { map->RenderDebug(screen, offset);