home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / !BONUS / GAMES / ENGINES / BM214A.ZIP / BM214A / ORIGINAL.SRC / MAINBC.CPP < prev    next >
C/C++ Source or Header  |  1994-12-23  |  2KB  |  103 lines

  1. /********************************************************************
  2.  FILENAME: MAINBC.CPP
  3.  AUTHOR  : JAKE HILL
  4.  DATE    : 12/1/94
  5.  
  6.  Copyright (c) 1994 by Jake Hill:
  7.  If you use any part of this code in your own project, please credit
  8.  me in your documentation and source code.  Thanks.
  9. ********************************************************************/
  10.  
  11. #include "TRIG.HPP"
  12. #include "VIEW.HPP"
  13. #include "KEYBOARD.HPP"
  14.  
  15. #include <dos.h>                // time functions
  16. #include <stdio.h>              // printf
  17. #include <stdlib.h>
  18.  
  19. void main(int argc, char *argv[])
  20. {
  21.    short Px, Py, Ph;
  22.    long FrameCount = 0L;
  23.    unsigned short Pangle;
  24.    char *WadFile = "DOOM.WAD";
  25.    short Level = 0, Step = 8, Turn = 1024;
  26.  
  27.    View Map;
  28.  
  29.    if (argc == 2)
  30.       Level = atoi(argv[1]);
  31.    else if (argc == 3)
  32.    {
  33.       WadFile = argv[1];
  34.       Level   = atoi(argv[2]);
  35.    }
  36.    Map.OpenWad(WadFile, Level);
  37.  
  38.    SetKeyboardInt();
  39.  
  40.    Map.GetView(&Px, &Py, &Ph, &Pangle);
  41.    Map.SetView(Px,Py,Ph,Pangle);
  42.    Map.DrawView();
  43.  
  44.    float T1,T2,dT;
  45.    struct time t1,t2;
  46.    gettime(&t1);
  47.  
  48.    while ( key != 1 )
  49.    {
  50.       FrameCount++;
  51.  
  52.       if ( key_flags & FLAG_UP )
  53.       {
  54.          Px += xCosA( Step, Pangle );
  55.          Py += xSinA( Step, Pangle );
  56.       }
  57.       if ( key_flags & FLAG_DOWN )
  58.       {
  59.          Px -= xCosA( Step, Pangle );
  60.          Py -= xSinA( Step, Pangle );
  61.       }
  62.  
  63.       if ( (key_flags & FLAG_SRIGHT) == FLAG_SRIGHT )
  64.       {
  65.          Px += xCosA( Step, Pangle-0x4000 );
  66.          Py += xSinA( Step, Pangle-0x4000 );
  67.       }
  68.       else
  69.       if ( key_flags & FLAG_RIGHT )
  70.          Pangle -= Turn;
  71.  
  72.       if ( (key_flags & FLAG_SLEFT) == FLAG_SLEFT )
  73.       {
  74.          Px += xCosA( Step, Pangle+0x4000 );
  75.          Py += xSinA( Step, Pangle+0x4000 );
  76.       }
  77.       else
  78.       if ( key_flags & FLAG_LEFT )
  79.          Pangle += Turn;
  80.  
  81.       if ( key == KEY_PLUS )
  82.          Ph += 10;
  83.       if ( key == KEY_MINUS )
  84.          Ph -= 10;
  85.  
  86.       Map.SetView(Px,Py,Ph,Pangle);
  87.       Map.DrawView();
  88.    }
  89.  
  90.    gettime(&t2);
  91.    Map.Close();
  92.  
  93.    T1 = t1.ti_hund+(t1.ti_sec*100)+(t1.ti_min*6000);
  94.    T2 = t2.ti_hund+(t2.ti_sec*100)+(t2.ti_min*6000);
  95.    dT = T2 - T1;
  96.    float fps = (float) FrameCount / ( (float) dT / 100 );
  97.  
  98.    ResetKeyboardInt();
  99.  
  100.    printf("\n");
  101.    printf("FPS = %f\n",fps);
  102.    printf("Elapsed Time = %4.2f\n",dT/100);
  103. };