home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / EV_201 / HANOI / MAIN.CPP < prev    next >
C/C++ Source or Header  |  1993-07-03  |  5KB  |  131 lines

  1. /*
  2.    Project       : Hanoi's towers.
  3.                    Hanoi is the capital of reunified Viêt-Nam
  4.    Version       : 2.0
  5.    Revision Date : July 3rd, 1993
  6.    Author(s)     : Remy Gendron
  7.  
  8.    Description   : Solves the puzzle, using 1 to 10 disks.
  9. */
  10.  
  11.  
  12. // Headers ------------------------------------------------------------------
  13.  
  14. #include <conio.h>                                      // System's libraries
  15. #include <ctype.h>
  16. #include <dos.h>
  17. #include <math.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <time.h>
  21. #pragma hdrstop
  22.  
  23. #include "evmsgs.hpp"                                        // Other modules
  24. #include "hanoi.hcm"
  25. #include "module.hpp"
  26. #include "stdfcts.h"
  27. #include "tdesktop.hpp"
  28. #include "tdisk.hpp"
  29. #include "tinput.hpp"
  30. #include "tstatusline.hpp"
  31. #include "ttower.hpp"
  32. #include "twindow.hpp"
  33.  
  34.  
  35. // Macros -------------------------------------------------------------------
  36.  
  37. #include "stdmacro.h"
  38.  
  39.  
  40. // TypeDefs -----------------------------------------------------------------
  41.  
  42. #include "stdtype.h"
  43. #include "prjtype.h"
  44.  
  45.  
  46. // Global Variables ---------------------------------------------------------
  47.  
  48. int  move_count ;          // Counts number of moves made to solve the puzzle
  49. char nbmoves[18] ;                             // To show current move number
  50. char alphaspeed[18] ;                                // To show current speed
  51. int  globspeed ;                 // Animation's speed (0: slowest 9: fastest)
  52. bool end_anim ;                       // If true, user asked to end animation
  53.  
  54.  
  55. // --------------------------------------------------------------------------
  56.  
  57. int main
  58. (
  59.    int  argc,                             // Number of command line arguments
  60.    char *argv[]                    // Array of ptrs to command line arguments
  61. )
  62.  
  63. {
  64.    input_info  ii ;                                         // User's command
  65.    config_info config ;                              // Configuration's infos
  66.  
  67.  
  68.    language_french () ;                     // Sets default prompts to french
  69.  
  70.                                                              // Opens desktop
  71.    desktop.settitle ("EasyVision 2.0 : Les tours de Hanoi",CYAN,WHITE) ;
  72.    desktop.settextmode (C80,TRUE) ;
  73.    desktop.open () ;
  74.    delay (2000) ;
  75.                                                        // Defines the menubar
  76.    menubar.addmenu ("≡",'Z',"Menu système",HC_MENU_SYSTEME) ;
  77.    menubar.additem ("Rafraîchir   Alt-R",'R',II_A_R,
  78.                     "Redessine l'écran au complet",HC_MENU_SYSTEME_RAFRAICHIR) ;
  79.  
  80.    menubar.addmenu ("Programme",'P',
  81.                     "Fonctions principales du programme",HC_MENU_PROGRAMME) ;
  82.    menubar.additem ("Options animation   Alt-O",'O',II_A_O,
  83.                     "Choix du nombre de disques et de la vitesse",
  84.                     HC_MENU_PROGRAMME_OPTIONS) ;
  85.    menubar.additem ("Solutionner         Alt-S",'S',II_A_S,
  86.                     "Trouver la solution pour la configuration présente",
  87.                     HC_MENU_PROGRAMME_SOLUTIONNER) ;
  88.  
  89.    menubar.addmenu ("Terminer",'T',
  90.                     "Pour terminer le programme",HC_MENU_TERMINER) ;
  91.    menubar.additem ("A propos...  Alt-A",'A',II_A_A,
  92.                     "Affiche la version et notices de droits d'auteur",
  93.                     HC_MENU_TERMINER_APROPOS) ;
  94.    menubar.additem () ;
  95.    menubar.additem ("Sortir       Alt-X",'S',II_A_X,
  96.                     "Terminer le programme immédiatement",
  97.                     HC_MENU_TERMINER_SORTIR) ;
  98.  
  99.  
  100.    config.nb_disks = 5 ;                          // Configuration's defaults
  101.    config.source   = 1 ;
  102.    config.target   = 3 ;
  103.    config.speed    = 2 ;
  104.  
  105.    ii.key_code = II_NUL ;
  106.  
  107.    while (ii.key_code != II_A_X)          // Gets user's input until he exits
  108.    {
  109.       statusline.display ("Bienvenue aux ~Tours de Hanoi~") ;
  110.       input.get (&ii,0,HC_GENERAL,FALSE) ;
  111.       ii = menubar.through (ii) ;
  112.  
  113.       switch (ii.key_code)                                 // Processes input
  114.       {
  115.         case II_A_R : desktop.refresh () ; break ;
  116.         case II_A_O : config = configuration (config) ; break ;
  117.         case II_A_S : animation (config) ; break ;
  118.         case II_A_A : about () ; break ;
  119.         default     : ;
  120.       }
  121.    }
  122.  
  123.    desktop.close () ;                                       // Closes desktop
  124.  
  125.  
  126.    return 0 ;                                   // Program normal termination
  127. }                                                                 // End main
  128.  
  129.  
  130. // End Source File ----------------------------------------------------------
  131.