made secret area trigger work
[supertux.git] / src / scene.cpp
1 //  $Id$
2 //
3 //  SuperTux -  A Jump'n Run
4 //  Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #include <config.h>
21
22 #include <cstdlib>
23
24 #include "scene.h"
25 #include "defines.h"
26 #include "resources.h"
27
28 PlayerStatus player_status;
29
30 PlayerStatus::PlayerStatus()
31   : distros(0),
32     lives(START_LIVES),
33     bonus(NO_BONUS),
34     score_multiplier(1),
35     max_score_multiplier(1)
36 {
37 }
38
39 void PlayerStatus::reset()
40 {
41   distros = 0;
42   lives = START_LIVES;
43   bonus = NO_BONUS;
44   score_multiplier = 1;
45   max_score_multiplier = 1;
46 }
47
48 void
49 PlayerStatus::incLives()
50 {
51   if(lives < MAX_LIVES)
52     ++lives;
53   SoundManager::get()->play_sound(IDToSound(SND_LIFEUP));
54 }
55
56 void
57 PlayerStatus::incCoins()
58 {
59   distros++;
60   if(distros >= 100) {
61     incLives();
62     distros = 0;
63   }
64   SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
65 }
66
67 std::string bonus_to_string(PlayerStatus::BonusType b)
68 {
69   switch (b)
70     {
71     case PlayerStatus::NO_BONUS:
72       return "none";
73     case PlayerStatus::GROWUP_BONUS:
74       return "growup";
75     case PlayerStatus::FLOWER_BONUS:
76       return "iceflower";
77     default:
78       return "none";
79     }
80 }
81
82 PlayerStatus::BonusType string_to_bonus(const std::string& str)
83 {
84   if (str == "none")
85     return PlayerStatus::NO_BONUS;
86   else if (str == "growup")
87     return PlayerStatus::GROWUP_BONUS;
88   else if (str == "iceflower")
89     return PlayerStatus::FLOWER_BONUS;
90   else
91     return PlayerStatus::NO_BONUS;
92 }
93
94 unsigned int global_frame_counter;
95
96 // EOF //
97