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

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