GhostParticleSystem Class Reference

#include <ghost_particle_system.hpp>

Inherits ParticleSystem.

List of all members.

Public Member Functions

 GhostParticleSystem ()
virtual ~GhostParticleSystem ()
void parse (const Reader &lisp)
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

 GhostParticleSystem (const GhostParticleSystem &)
GhostParticleSystemoperator= (const GhostParticleSystem &)

Private Attributes

SurfacePtr ghosts [2]

Classes

class  GhostParticle


Detailed Description

Definition at line 25 of file ghost_particle_system.hpp.


Constructor & Destructor Documentation

GhostParticleSystem::GhostParticleSystem (  ) 

Definition at line 27 of file ghost_particle_system.cpp.

References Surface::create(), ghosts, graphicsRandom, ParticleSystem::particles, RandomGenerator::rand(), RandomGenerator::randf(), SCREEN_HEIGHT, SCREEN_WIDTH, and ParticleSystem::virtual_width.

00028 {
00029   ghosts[0] = Surface::create("images/objects/particles/ghost0.png");
00030   ghosts[1] = Surface::create("images/objects/particles/ghost1.png");
00031 
00032   virtual_width = SCREEN_WIDTH * 2;
00033 
00034   // create two ghosts
00035   size_t ghostcount = 2;
00036   for(size_t i=0; i<ghostcount; ++i) {
00037     GhostParticle* particle = new GhostParticle;
00038     particle->pos.x = graphicsRandom.randf(virtual_width);
00039     particle->pos.y = graphicsRandom.randf(SCREEN_HEIGHT);
00040     int size = graphicsRandom.rand(2);
00041     particle->texture = ghosts[size];
00042     particle->speed = graphicsRandom.randf(std::max(50, (size * 10)), 180 + (size * 10));
00043     particles.push_back(particle);
00044   }
00045 }

GhostParticleSystem::~GhostParticleSystem (  )  [virtual]

Definition at line 53 of file ghost_particle_system.cpp.

00054 {
00055 }

GhostParticleSystem::GhostParticleSystem ( const GhostParticleSystem  )  [private]


Member Function Documentation

void GhostParticleSystem::parse ( const Reader lisp  ) 

Definition at line 48 of file ghost_particle_system.cpp.

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

Referenced by Sector::parse_object().

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

void GhostParticleSystem::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 57 of file ghost_particle_system.cpp.

References graphicsRandom, ParticleSystem::particles, RandomGenerator::rand(), SCREEN_HEIGHT, ParticleSystem::virtual_height, and ParticleSystem::virtual_width.

00058 {
00059   std::vector<Particle*>::iterator i;
00060   for(i = particles.begin(); i != particles.end(); ++i) {
00061     GhostParticle* particle = (GhostParticle*) *i;
00062     particle->pos.y -= particle->speed * elapsed_time;
00063     particle->pos.x -= particle->speed * elapsed_time;
00064     if(particle->pos.y > SCREEN_HEIGHT) {
00065       particle->pos.y = fmodf(particle->pos.y , virtual_height);
00066       particle->pos.x = graphicsRandom.rand(static_cast<int>(virtual_width));
00067     }
00068   }
00069 }

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

Definition at line 35 of file ghost_particle_system.hpp.

00036   { return "GhostParticleSystem"; }

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


Member Data Documentation

SurfacePtr GhostParticleSystem::ghosts[2] [private]

Definition at line 49 of file ghost_particle_system.hpp.

Referenced by GhostParticleSystem().


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