CometParticleSystem Class Reference

#include <comet_particle_system.hpp>

Inherits ParticleSystem_Interactive.

List of all members.

Public Member Functions

 CometParticleSystem ()
virtual ~CometParticleSystem ()
void parse (const Reader &lisp)
void write (Writer &writer)
virtual void update (float elapsed_time)
 This function is called once per frame and allows the object to update it's state.
std::string type () const

Private Member Functions

 CometParticleSystem (const CometParticleSystem &)
CometParticleSystemoperator= (const CometParticleSystem &)

Private Attributes

SurfacePtr cometimages [2]

Classes

class  CometParticle


Detailed Description

Definition at line 26 of file comet_particle_system.hpp.


Constructor & Destructor Documentation

CometParticleSystem::CometParticleSystem (  ) 

Definition at line 24 of file comet_particle_system.cpp.

References cometimages, Surface::create(), graphicsRandom, ParticleSystem_Interactive::particles, RandomGenerator::rand(), RandomGenerator::randf(), SCREEN_WIDTH, ParticleSystem_Interactive::virtual_height, and ParticleSystem_Interactive::virtual_width.

00025 {
00026   cometimages[0] = Surface::create("images/creatures/mr_bomb/exploding-left-0.png");
00027   cometimages[1] = Surface::create("images/creatures/mr_bomb/exploding-left-0.png");
00028 
00029   virtual_width = SCREEN_WIDTH * 2;
00030 
00031   // create some random comets
00032   size_t cometcount = 2;
00033   for(size_t i=0; i<cometcount; ++i) {
00034     CometParticle* particle = new CometParticle;
00035     particle->pos.x = graphicsRandom.rand(int(virtual_width));
00036     particle->pos.y = graphicsRandom.rand(int(virtual_height));
00037     int cometsize = graphicsRandom.rand(2);
00038     particle->texture = cometimages[cometsize];
00039     do {
00040       particle->speed = (cometsize+1)*30 + graphicsRandom.randf(3.6);
00041     } while(particle->speed < 1);
00042     particle->speed *= 10; // gravity
00043 
00044     particles.push_back(particle);
00045   }
00046 }

CometParticleSystem::~CometParticleSystem (  )  [virtual]

Definition at line 54 of file comet_particle_system.cpp.

00055 {
00056 }

CometParticleSystem::CometParticleSystem ( const CometParticleSystem  )  [private]


Member Function Documentation

void CometParticleSystem::parse ( const Reader lisp  ) 

Definition at line 49 of file comet_particle_system.cpp.

References LAYER_BACKGROUND1, reader_get_layer(), and ParticleSystem_Interactive::z_pos.

Referenced by Sector::parse_object().

00050 {
00051   z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1);
00052 }

void CometParticleSystem::write ( Writer writer  ) 

void CometParticleSystem::update ( float  elapsed_time  )  [virtual]

This function is called once per frame and allows the object to update it's state.

The elapsed_time is the time since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode)

Implements GameObject.

Definition at line 58 of file comet_particle_system.cpp.

References Sector::add_object(), Sector::camera, ParticleSystem_Interactive::collision(), Sector::current(), Camera::get_translation(), graphicsRandom, LEFT, ParticleSystem_Interactive::particles, RandomGenerator::rand(), SCREEN_HEIGHT, ParticleSystem_Interactive::virtual_width, Vector::x, and Vector::y.

00059 {
00060   (void) elapsed_time;
00061 #if 0
00062   std::vector<Particle*>::iterator i;
00063   for(
00064     i = particles.begin(); i != particles.end(); ++i) {
00065     CometParticle* particle = (CometParticle*) *i;
00066     float movement = particle->speed * elapsed_time;
00067     float abs_x = Sector::current()->camera->get_translation().x;
00068     float abs_y = Sector::current()->camera->get_translation().y;
00069     particle->pos.y += movement;
00070     particle->pos.x -= movement;
00071     int col = collision(particle, Vector(-movement, movement));
00072     if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (col >= 0)) {
00073       if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
00074         Sector::current()->add_object(new Bomb(particle->pos, LEFT));
00075       }
00076       int new_x = graphicsRandom.rand(int(virtual_width)) + int(abs_x);
00077       int new_y = 0;
00078       //FIXME: Don't move particles over solid tiles
00079       particle->pos.x = new_x;
00080       particle->pos.y = new_y;
00081     }
00082   }
00083 #endif
00084 }

std::string CometParticleSystem::type (  )  const [inline]

Definition at line 37 of file comet_particle_system.hpp.

00038   { return "CometParticleSystem"; }

CometParticleSystem& CometParticleSystem::operator= ( const CometParticleSystem  )  [private]


Member Data Documentation

SurfacePtr CometParticleSystem::cometimages[2] [private]

Definition at line 51 of file comet_particle_system.hpp.

Referenced by CometParticleSystem().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:29 2014 for SuperTux by  doxygen 1.5.1