[Super-tux-commit] supertux/src gameloop.cpp,1.104,1.105 worldmap.cpp,1.51,1.52 worldmap.h,1.23,1.24
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-26 12:19:34
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30023 Modified Files: gameloop.cpp worldmap.cpp worldmap.h Log Message: - added way to interupt exit sequence - added primitive autowalk to worldmap Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- worldmap.cpp 26 Apr 2004 10:46:45 -0000 1.51 +++ worldmap.cpp 26 Apr 2004 12:19:23 -0000 1.52 @@ -596,13 +596,43 @@ switch (session.run()) { case GameSession::LEVEL_FINISHED: - level->solved = true; - if (session.get_world()->get_tux()->got_coffee) - player_status.bonus = PlayerStatus::FLOWER_BONUS; - else if (session.get_world()->get_tux()->size == BIG) - player_status.bonus = PlayerStatus::GROWUP_BONUS; - else - player_status.bonus = PlayerStatus::NO_BONUS; + { + bool old_level_state = level->solved; + level->solved = true; + + if (session.get_world()->get_tux()->got_coffee) + player_status.bonus = PlayerStatus::FLOWER_BONUS; + else if (session.get_world()->get_tux()->size == BIG) + player_status.bonus = PlayerStatus::GROWUP_BONUS; + else + player_status.bonus = PlayerStatus::NO_BONUS; + + if (old_level_state != level->solved) + { // Try to detect the next direction to which we should walk + // FIXME: Mostly a hack + Direction dir = NONE; + + Tile* tile = at(tux->get_tile_pos()); + + if (tile->north && tux->back_direction != NORTH) + dir = NORTH; + else if (tile->south && tux->back_direction != SOUTH) + dir = SOUTH; + else if (tile->east && tux->back_direction != EAST) + dir = EAST; + else if (tile->west && tux->back_direction != WEST) + dir = WEST; + + if (dir != NONE) + { + tux->set_direction(dir); + tux->update(0.33f); + } + + std::cout << "Walk to dir: " << dir << std::endl; + } + } + break; case GameSession::LEVEL_ABORT: // Reseting the player_status might be a worthy Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.104 retrieving revision 1.105 diff -u -d -r1.104 -r1.105 --- gameloop.cpp 26 Apr 2004 10:03:33 -0000 1.104 +++ gameloop.cpp 26 Apr 2004 12:19:22 -0000 1.105 @@ -209,6 +209,43 @@ tux.input.up = UP; last_x_pos = tux.base.x; + + SDL_Event event; + while (SDL_PollEvent(&event)) + { + /* Check for menu-events, if the menu is shown */ + if (Menu::current()) + { + Menu::current()->event(event); + st_pause_ticks_start(); + } + + switch(event.type) + { + case SDL_QUIT: /* Quit event - quit: */ + st_abort("Received window close", ""); + break; + + case SDL_KEYDOWN: /* A keypress! */ + { + SDLKey key = event.key.keysym.sym; + + switch(key) + { + case SDLK_ESCAPE: /* Escape: Open/Close the menu: */ + on_escape_press(); + break; + default: + break; + } + } + + case SDL_JOYBUTTONDOWN: + if (event.jbutton.button == joystick_keymap.start_button) + on_escape_press(); + break; + } + } } else { Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- worldmap.h 25 Apr 2004 21:55:39 -0000 1.23 +++ worldmap.h 26 Apr 2004 12:19:23 -0000 1.24 @@ -62,6 +62,9 @@ /** Stop on this tile or walk over it? */ bool stop; + + /** direction in which to automatically turn when walked on such a tile */ + Direction auto_walk; }; class TileManager |