#include <fireworks.hpp>
Inherits GameObject.
Public Member Functions | |
Fireworks () | |
~Fireworks () | |
virtual void | update (float elapsed_time) |
This function is called once per frame and allows the object to update it's state. | |
virtual void | draw (DrawingContext &context) |
The GameObject should draw itself onto the provided DrawingContext if this function is called. | |
Private Attributes | |
Timer | timer |
Definition at line 20 of file fireworks.hpp.
Fireworks::Fireworks | ( | ) |
Definition at line 26 of file fireworks.cpp.
References SoundManager::preload(), sound_manager, Timer::start(), and timer.
00026 : 00027 timer() 00028 { 00029 timer.start(.2f); 00030 sound_manager->preload("sounds/fireworks.wav"); 00031 }
Fireworks::~Fireworks | ( | ) |
void Fireworks::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 38 of file fireworks.cpp.
References Sector::camera, Timer::check(), Sector::current(), Camera::get_translation(), graphicsRandom, LAYER_FOREGROUND1, SoundManager::play(), RandomGenerator::randf(), SCREEN_HEIGHT, SCREEN_WIDTH, sound_manager, Timer::start(), and timer.
00039 { 00040 if(timer.check()) { 00041 Sector* sector = Sector::current(); 00042 Vector pos = sector->camera->get_translation(); 00043 pos += Vector(graphicsRandom.randf(SCREEN_WIDTH), 00044 graphicsRandom.randf(SCREEN_HEIGHT/2)); 00045 00046 float red = graphicsRandom.randf(1.0); 00047 float green = graphicsRandom.randf(1.0); 00048 //float red = 0.7; 00049 //float green = 0.9; 00050 (void) red; 00051 (void) green; 00052 sector->add_object(new Particles(pos, 0, 360, Vector(140, 140), 00053 Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f, 00054 LAYER_FOREGROUND1+1)); 00055 sound_manager->play("sounds/fireworks.wav"); 00056 timer.start(graphicsRandom.randf(1.0, 1.5)); 00057 } 00058 }
void Fireworks::draw | ( | DrawingContext & | context | ) | [virtual] |
The GameObject should draw itself onto the provided DrawingContext if this function is called.
Implements GameObject.
Definition at line 61 of file fireworks.cpp.
Timer Fireworks::timer [private] |