• Main Page
  • Classes
  • Files
  • File List
  • File Members

code/source/powerups/PowerupSpeedUp.cpp

Go to the documentation of this file.
00001 /*
00002  * TetriCycle
00003  * Copyright (C) 2010 Cale Scholl
00004  *
00005  * This file is part of TetriCycle.
00006  *
00007  * TetriCycle is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU Lesser General Public License as published
00009  * by the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * TetriCycle is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with TetriCycle.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 /** @file PowerupSpeedUp.cpp
00022  * @author Cale Scholl
00023  */
00024 
00025 #include "PowerupSpeedUp.h"
00026 
00027 #include "Player.h"        // for Player
00028 #include "libwiigui/gui.h" // for GuiImageData
00029 
00030 extern Player *g_players; ///< the player instances
00031 
00032 PowerupId PowerupSpeedUp::powerupId;
00033 Powerup *PowerupSpeedUp::instance = new PowerupSpeedUp();
00034 
00035 GuiImageData *PowerupSpeedUp::imageData = 
00036   new GuiImageData(powerup_speedup_png);
00037 
00038 string PowerupSpeedUp::helpText[2] = 
00039   {"Speed Up", "A powerup that temporarily increases the level (speed) of the target player."};
00040 
00041 // OPTIONAL:
00042 //GuiSound *PowerupSpeedUp::sound = 
00043 //  new GuiSound(powerup_speedup_pcm, powerup_speedup_pcm_size, SOUND_PCM);
00044 
00045 #define SPEED_INCREMENT 2
00046 
00047 void PowerupSpeedUp::StartEffect(u8 player)
00048 {
00049   g_players[player].gameData.level += SPEED_INCREMENT;
00050   g_players[player].gameData.speed = START_SPEED - 3 * g_players[player].gameData.level;
00051   if (g_players[player].gameData.speed <= 0)
00052     g_players[player].gameData.speed = 1;
00053 }
00054 
00055 void PowerupSpeedUp::StopEffect(u8 player)
00056 {
00057   g_players[player].gameData.level -= SPEED_INCREMENT;
00058   g_players[player].gameData.speed = START_SPEED - 3 * g_players[player].gameData.level;
00059   if (g_players[player].gameData.speed <= 0)
00060     g_players[player].gameData.speed = 1;
00061 }

Generated on Wed Oct 20 2010 17:06:58 for TetriCycle by  doxygen 1.7.1