home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 April / Game.EXE_04_2002.iso / Alawar / PacmanInterface2D.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-02  |  1.4 KB  |  62 lines

  1. #include "PacmanInterface2D.h"
  2. #include "Color.h"
  3. #include "Hardware2D.h"
  4. #include "LogPtr.h"
  5. #include "String.h"
  6. #include "safe_new.h"
  7.  
  8. Interface2D * create_game(Hardware2D * hardware)
  9. {
  10.     return new PacmanInterface2D( hardware );
  11. }
  12.  
  13.  
  14. PacmanInterface2D::PacmanInterface2D(Hardware2D * hardware)
  15. :    Interface2D( hardware ),
  16.     scene( hardware ),
  17.     pic0( &scene, 0, "data\\help_pic" ),
  18.     pic1( &scene, 1, "data\\intro" ),
  19.     apple( &scene, 2, "data\\apple" ),
  20.     hello( &scene, 3, "data\\small_alphabet" ),
  21.     time_ms( 0 ),
  22.     fps( 2000 )
  23. {
  24.     hardware->set_mode( 240, 320 );
  25.  
  26.     apple.start( 0, true );
  27.     apple.move( 160, 120 );
  28.     pic0.start( 0, true );
  29.     pic0.move( 0, 0 );
  30.     pic1.start( 0, true );
  31.     pic1.move( 0, 0 );
  32.  
  33.     hello.move( 0, 0 );
  34.     hello.change_text( "123 Hello, World" );
  35. }
  36.  
  37. PacmanInterface2D::~PacmanInterface2D()
  38. {
  39.     hardware->stop_mode();
  40. }
  41.  
  42. bool PacmanInterface2D::render()
  43. {
  44.     bool ok = scene.render( 0, 0, Color(0,0,128) );
  45.     return ok;
  46. }
  47.  
  48. bool PacmanInterface2D::life_cycle(unsigned delta_time_ms)
  49. {
  50.     fps.record( time_ms );
  51.     LogPtr()->message( String("Fps ") + String::convert( fps.get_fps() ) + "\n" );
  52.     hello.change_text( String("Fps ") + String::convert( int(fps.get_fps()) ) );
  53.  
  54.     time_ms += delta_time_ms;
  55.     pic1.set_transparency( (time_ms%2550)/10 );
  56.  
  57.     apple.life_cycle( delta_time_ms );
  58.     pic0.life_cycle( delta_time_ms );
  59.     pic1.life_cycle( delta_time_ms );
  60.     return true;
  61. }
  62.