X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscene.cpp;h=429abd07d934c9fa12e8e43ba3549faa56b74ad5;hb=8385faa306eca6d96ab11ed7dae293d85e9c4e4f;hp=b2a242111d570328c6757677de9bbc2fd1ac4d96;hpb=6923b0b0fb10c3bcb17f03d7bbe159d034f07db2;p=supertux.git diff --git a/src/scene.cpp b/src/scene.cpp index b2a242111..429abd07d 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -1,58 +1,97 @@ +// $Id$ // -// C Implementation: scene +// SuperTux - A Jump'n Run +// Copyright (C) 2003 Tobias Glaesser // -// Description: -// -// -// Author: Tobias Glaesser , (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution +// 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 + +#include -#include #include "scene.h" +#include "defines.h" +#include "resources.h" -int score; -int distros; -int level; -int next_level; -int game_pause; -bool quit; -int score_multiplier; -int endpos; -bool counting_distros; -int distro_counter; -timer_type super_bkgd_timer; -float scroll_x; -unsigned int global_frame_counter; +PlayerStatus player_status; -Player tux; -texture_type img_box_full; -texture_type img_box_empty; -texture_type img_mints; -texture_type img_coffee; -texture_type img_super_bkgd; -texture_type img_red_glow; -timer_type time_left; -double frame_ratio; - -void set_defaults(void) +PlayerStatus::PlayerStatus() + : distros(0), + lives(START_LIVES), + bonus(NO_BONUS), + score_multiplier(1), + max_score_multiplier(1) { - // Set defaults: - scroll_x = 0; +} +void PlayerStatus::reset() +{ + distros = 0; + lives = START_LIVES; + bonus = NO_BONUS; score_multiplier = 1; - timer_init(&super_bkgd_timer, true); + max_score_multiplier = 1; +} - counting_distros = false; - distro_counter = 0; +void +PlayerStatus::incLives() +{ + if(lives < MAX_LIVES) + ++lives; + SoundManager::get()->play_sound(IDToSound(SND_LIFEUP)); +} - endpos = 0; +void +PlayerStatus::incCoins() +{ + distros++; + if(distros >= 100) { + incLives(); + distros = 0; + } + SoundManager::get()->play_sound(IDToSound(SND_DISTRO)); +} - /* set current song/music */ - set_current_music(LEVEL_MUSIC); +std::string bonus_to_string(PlayerStatus::BonusType b) +{ + switch (b) + { + case PlayerStatus::NO_BONUS: + return "none"; + case PlayerStatus::GROWUP_BONUS: + return "growup"; + case PlayerStatus::FLOWER_BONUS: + return "iceflower"; + default: + return "none"; + } } +PlayerStatus::BonusType string_to_bonus(const std::string& str) +{ + if (str == "none") + return PlayerStatus::NO_BONUS; + else if (str == "growup") + return PlayerStatus::GROWUP_BONUS; + else if (str == "iceflower") + return PlayerStatus::FLOWER_BONUS; + else + return PlayerStatus::NO_BONUS; +} + +unsigned int global_frame_counter; + // EOF //