-/*
- gameloop.c
-
- Super Tux - Game Loop!
-
- by Bill Kendrick & Tobias Glaesser
- bill@newbreedsoftware.com
- http://www.newbreedsoftware.com/supertux/
-
- April 11, 2000 - March 15, 2004
-*/
+// $Id$
+//
+// SuperTux
+// Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
+// Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
#include <assert.h>
if (st_gl_mode != ST_GL_DEMO_GAME)
{
- if(st_gl_mode != ST_GL_TEST)
- load_hs();
-
if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
levelintro();
}
else if (!Menu::current())
{
Menu::set_current(game_menu);
- st_pause_ticks_stop();
}
}
if (Menu::current())
{
Menu::current()->event(event);
+ st_pause_ticks_start();
}
else
{
+ st_pause_ticks_stop();
+
switch(event.type)
{
case SDL_QUIT: /* Quit event - quit: */
break;
case SDL_JOYAXISMOTION:
- switch(event.jaxis.axis)
+ if (event.jaxis.axis == joystick_keymap.x_axis)
{
- case JOY_X:
- if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ if (event.jaxis.value < -joystick_keymap.dead_zone)
{
tux.input.left = DOWN;
tux.input.right = UP;
}
- else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ else if (event.jaxis.value > joystick_keymap.dead_zone)
{
tux.input.left = UP;
tux.input.right = DOWN;
tux.input.left = DOWN;
tux.input.right = DOWN;
}
- break;
- case JOY_Y:
- if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ }
+ else if (event.jaxis.axis == joystick_keymap.y_axis)
+ {
+ if (event.jaxis.value > joystick_keymap.dead_zone)
tux.input.down = DOWN;
- else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ else if (event.jaxis.value < -joystick_keymap.dead_zone)
tux.input.down = UP;
else
tux.input.down = UP;
-
- break;
- default:
- break;
}
break;
+
case SDL_JOYBUTTONDOWN:
- if (event.jbutton.button == JOY_A)
+ if (event.jbutton.button == joystick_keymap.a_button)
tux.input.up = DOWN;
- else if (event.jbutton.button == JOY_B)
+ else if (event.jbutton.button == joystick_keymap.b_button)
tux.input.fire = DOWN;
- else if (event.jbutton.button == JOY_START)
+ else if (event.jbutton.button == joystick_keymap.start_button)
on_escape_press();
break;
case SDL_JOYBUTTONUP:
- if (event.jbutton.button == JOY_A)
+ if (event.jbutton.button == joystick_keymap.a_button)
tux.input.up = UP;
- else if (event.jbutton.button == JOY_B)
+ else if (event.jbutton.button == joystick_keymap.b_button)
tux.input.fire = UP;
break;
if(Menu::current())
{
- Menu::current()->action();
Menu::current()->draw();
mouse_cursor->draw();
}
GameSession::ExitStatus
GameSession::run()
{
+ Menu::set_current(0);
Player* tux = world->get_tux();
current_ = this;
tux->input.old_fire = tux->input.fire;
process_events();
-
- if(Menu::current())
+
+ Menu* menu = Menu::current();
+ if(menu)
{
- if(Menu::current() == game_menu)
+ menu->action();
+
+ if(menu == game_menu)
{
switch (game_menu->check())
{
break;
}
}
- else if(Menu::current() == options_menu)
+ else if(menu == options_menu)
{
process_options_menu();
}
- else if(Menu::current() == load_game_menu )
+ else if(menu == load_game_menu )
{
process_load_game_menu();
}