X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscene.cpp;h=429abd07d934c9fa12e8e43ba3549faa56b74ad5;hb=763454f90866bd4e7db95e5884c48a25d6b9bda1;hp=d85e9e8e0302b139461d155eb64c49ac294ca914;hpb=69ebb35511ad7ec0956b0f2b26c76fde47a53890;p=supertux.git diff --git a/src/scene.cpp b/src/scene.cpp index d85e9e8e0..429abd07d 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -1,160 +1,97 @@ +// $Id$ // -// C Implementation: scene +// SuperTux - A Jump'n Run +// Copyright (C) 2003 Tobias Glaesser // -// Description: +// 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. // -// Author: Tobias Glaesser , (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#include -#include "scene.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; -int global_frame_counter; -std::vector bouncy_distros; -std::vector broken_bricks; -std::vector bouncy_bricks; -std::vector bad_guys; -std::vector floating_scores; -std::vector upgrades; -std::vector bullets; -Player tux; -texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; -timer_type time_left; -double frame_ratio; - -/* Initialize all 'dynamic' arrays */ -void arrays_init(void) -{ -} - -/* Free memory of 'dynamic' arrays */ -void arrays_free(void) -{ -bad_guys.clear(); -bouncy_distros.clear(); -broken_bricks.clear(); -bouncy_bricks.clear(); -floating_scores.clear(); -upgrades.clear(); -bullets.clear(); -} - -void set_defaults(void) -{ - /* Set defaults: */ - - scroll_x = 0; - - score_multiplier = 1; - timer_init(&super_bkgd_timer, true); - - counting_distros = false; - distro_counter = 0; - - endpos = 0; - - /* set current song/music */ - set_current_music(LEVEL_MUSIC); -} - -/* Add score: */ +// 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. -void add_score(float x, float y, int s) -{ - /* Add the score: */ +#include - score += s; +#include - floating_score_type new_floating_score; - floating_score_init(&new_floating_score,x,y,s); - floating_scores.push_back(new_floating_score); -} +#include "scene.h" +#include "defines.h" +#include "resources.h" -/* Add a bouncy distro: */ +PlayerStatus player_status; -void add_bouncy_distro(float x, float y) +PlayerStatus::PlayerStatus() + : distros(0), + lives(START_LIVES), + bonus(NO_BONUS), + score_multiplier(1), + max_score_multiplier(1) { - - bouncy_distro_type new_bouncy_distro; - bouncy_distro_init(&new_bouncy_distro,x,y); - bouncy_distros.push_back(new_bouncy_distro); } - -/* Add broken brick pieces: */ - -void add_broken_brick(float x, float y) +void PlayerStatus::reset() { - add_broken_brick_piece(x, y, -1, -4); - add_broken_brick_piece(x, y + 16, -1.5, -3); - - add_broken_brick_piece(x + 16, y, 1, -4); - add_broken_brick_piece(x + 16, y + 16, 1.5, -3); + distros = 0; + lives = START_LIVES; + bonus = NO_BONUS; + score_multiplier = 1; + max_score_multiplier = 1; } - -/* Add a broken brick piece: */ - -void add_broken_brick_piece(float x, float y, float xm, float ym) +void +PlayerStatus::incLives() { - broken_brick_type new_broken_brick; - broken_brick_init(&new_broken_brick,x,y,xm,ym); - broken_bricks.push_back(new_broken_brick); + if(lives < MAX_LIVES) + ++lives; + SoundManager::get()->play_sound(IDToSound(SND_LIFEUP)); } - -/* Add a bouncy brick piece: */ - -void add_bouncy_brick(float x, float y) +void +PlayerStatus::incCoins() { - bouncy_brick_type new_bouncy_brick; - bouncy_brick_init(&new_bouncy_brick,x,y); - bouncy_bricks.push_back(new_bouncy_brick); + distros++; + if(distros >= 100) { + incLives(); + distros = 0; + } + SoundManager::get()->play_sound(IDToSound(SND_DISTRO)); } - -/* Add a bad guy: */ - -void add_bad_guy(float x, float y, BadGuyKind kind) +std::string bonus_to_string(PlayerStatus::BonusType b) { - BadGuy new_bad_guy; - new_bad_guy.init(x,y,kind); - bad_guys.push_back(new_bad_guy); + switch (b) + { + case PlayerStatus::NO_BONUS: + return "none"; + case PlayerStatus::GROWUP_BONUS: + return "growup"; + case PlayerStatus::FLOWER_BONUS: + return "iceflower"; + default: + return "none"; + } } -/* Add an upgrade: */ - -void add_upgrade(float x, float y, int dir, int kind) +PlayerStatus::BonusType string_to_bonus(const std::string& str) { - upgrade_type new_upgrade; - upgrade_init(&new_upgrade,x,y,dir,kind); - upgrades.push_back(new_upgrade); + 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; } -/* Add a bullet: */ +unsigned int global_frame_counter; -void add_bullet(float x, float y, float xm, int dir) -{ - bullet_type new_bullet; - bullet_init(&new_bullet,x,y,xm,dir); - bullets.push_back(new_bullet); - - play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER); -} +// EOF //