home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 May / Game.EXE_05_2002.iso / Alawar / src / Dot.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-08  |  942 b   |  50 lines

  1. #include "Dot.h"
  2. #include "Level.h"
  3.  
  4. Dot::Dot( Level * level, Scene2D * scene, int x, int y )
  5. :    Creature( level ),
  6.     anim( scene, 1, "data/dot" ),
  7.     alive( true )
  8. {
  9.     anim.start( 0, true );
  10.     const int cell_size = level->get_cell_size();
  11.     const int anim_shift = int(cell_size - anim.get_width(0,0))/2;
  12.     const Coord coord ( cell_size*x, cell_size*y );
  13.     pos = Position( coord, coord, cell_size );
  14.     anim.move( cell_size*x+anim_shift, cell_size*y+anim_shift );
  15. }
  16.  
  17. void Dot::life_cycle(float delta_time)
  18. {
  19.     anim.life_cycle( delta_time );
  20. }
  21.  
  22. String Dot::get_name()const
  23. {
  24.     return "Dot";
  25. }
  26.  
  27. float Dot::get_size()const
  28. {
  29.     return anim.get_width( 0, 0 );
  30. }
  31.  
  32. void Dot::process_collision(const Creature * cre)
  33. {
  34.     if ( cre->get_name() == "Pacman" )
  35.         alive = false;
  36. }
  37.  
  38. bool Dot::is_solid()const
  39. {
  40.     return alive;
  41. }
  42.  
  43. void Dot::process_death(const Creature * cre)
  44. {}
  45.  
  46. bool Dot::is_alive()const
  47. {
  48.     return alive;
  49. }
  50.