- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/jegan/Desktop/projectX/PlayMusicCommand.cpp

Go to the documentation of this file.

    00001 #include "Command.h"
    00002 #include "Level.h"
    00003 #include "List.h"
    00004
    00005 using namespace std;
    00006
    00007 const std::string PlayMusicCommand::_id = "playMusic";
    00008
    00009 PlayMusicCommand::PlayMusicCommand( std::string filename )
    00010 : _filename( filename )
    00011 {
    00012         Level::instance()->setMusic( Mix_LoadMUS( _filename.c_str() ) );
    00013 }
    00014
    00015 PlayMusicCommand::PlayMusicCommand(List *command)
    00016 {
    00017         command = command->rest();
    00018         _filename = command->firstString();
    00019
    00020         Level::instance()->setMusic( Mix_LoadMUS( _filename.c_str() ) );
    00021 }
    00022 void PlayMusicCommand::execute()
    00023 {
    00024         Mix_FadeOutMusic(1000);
    00025         Mix_FadeInMusic(Level::instance()->getMusic(), -1, 1000);
    00026 }
    00027
    00028 std::string PlayMusicCommand::getString()
    00029 {
    00030         List *command = new List();
    00031         command->snoc(new Atom(_id));
    00032         command->snoc( new Atom( _filename ) );
    00033         string commandString = command->getString();
    00034         delete command;
    00035
    00036         return commandString;
    00037 }