timnicolas / bomberman

3d remake of the classic game Bomberman in C++ with OpenGL.
https://tnicolas42.github.io/bomberman
MIT License
7 stars 0 forks source link

add cheat code #100

Closed timnicolas closed 4 years ago

timnicolas commented 4 years ago

cheatcode

comment ajouter une commande

Dans SceneCheatCode.cpp, dans le constructeur, ajouter les infos sur la fonction:

{"log", {  // nom de la fonction
    "<type> <message>",  // prototype
    "Log a message (/log list to get the list of logs types).\n"  // description
        CHEATCODE_TAB"/log info \"info message\"",  // description
    &SceneCheatCode::_execLog,  // fonction a executer
}},

Dans SceneCheatCode_exec.cpp, ajouter la fonction a executer pour la commande.

Cette fonction DOIT avoir le prototype suivant:

// le nom doit etre `_exec<nomCommande>`
int SceneCheatCode::_execHelp(std::vector<std::string> const & args);

args contient les arguments (comme en shell -> args[0] = nom commande, args[1-n] = arguments)

un argument est soit un mot soit une chaine entre guillemet

La return value d'une fonction exec defini ce qui se passe apres

namespace CheatcodeAction {
    // open or close cheatcode
    int const KEEP_OPEN =           0b00000000001;  // keep command line open
    int const CLOSE =               0b00000000010;  // close command line
    // setup txt in cheatcode
    int const TXT_RESET =           0b00000000100;  // reset commadn line text
    int const TXT_DEF =             0b00000001000;  // set command line text to default
    int const TXT_KEEP =            0b00000010000;  // keep the same command line text
    // if close, open text only mode
    int const CHEAT_NO_TXT_ONLY =   0b00000100000;  // don't open text only mode
    int const CHEAT_TXT_ONLY =      0b00001000000;  // open text only mode (only if CLOSE)
    // result of a command
    int const RESULT_SUCCESS =      0b00001000000;  // result of the command: success
    int const RESULT_ERROR =        0b00010000000;  // result of the command: error
};  // namespace CheatcodeAction

// pour quiter la commande line mais afficher les messages 3 sec
return CheatcodeAction::CLOSE | CheatcodeAction::SUCCESS | CheatcodeAction::CHEAT_TXT_ONLY;

// il faut toujours return au minimum:
//    KEEP_OPEN ou CLOSE et RESULT_SUCCESS ou RESULT_ERROR

code couleur

βœ… -> c'est fait ! πŸ”œ -> c'est a faire ❌ -> finalement je fait pas (pas utile)

liste des commandes

autres ajouts

bugs

ebaudet commented 4 years ago

Super cools les cheat code, je rajouterai bien le fait de pouvoir dΓ©sactiver les bonus aussi.