#include <spotlight.hpp>
Inherits GameObject.
Public Member Functions | |
Spotlight (const Reader &reader) | |
virtual | ~Spotlight () |
void | update (float elapsed_time) |
This function is called once per frame and allows the object to update it's state. | |
void | draw (DrawingContext &context) |
The GameObject should draw itself onto the provided DrawingContext if this function is called. | |
Private Attributes | |
Vector | position |
float | angle |
SpritePtr | center |
SpritePtr | base |
SpritePtr | lights |
SpritePtr | light |
SpritePtr | lightcone |
Color | color |
Definition at line 28 of file spotlight.hpp.
Spotlight::Spotlight | ( | const Reader & | reader | ) |
Definition at line 23 of file spotlight.cpp.
References angle, base, center, color, SpriteManager::create(), lisp::Lisp::get(), light, lightcone, lights, position, sprite_manager, Vector::x, and Vector::y.
00023 : 00024 position(), 00025 angle(0.0f), 00026 center(), 00027 base(), 00028 lights(), 00029 light(), 00030 lightcone(), 00031 color(1.0f, 1.0f, 1.0f) 00032 { 00033 lisp.get("x", position.x); 00034 lisp.get("y", position.y); 00035 00036 lisp.get("angle", angle); 00037 00038 std::vector<float> vColor; 00039 if( lisp.get( "color", vColor ) ){ 00040 color = Color( vColor ); 00041 } 00042 00043 center = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite"); 00044 base = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite"); 00045 lights = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite"); 00046 lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite"); 00047 light = sprite_manager->create("images/objects/spotlight/light.sprite"); 00048 00049 }
Spotlight::~Spotlight | ( | ) | [virtual] |
void Spotlight::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 56 of file spotlight.cpp.
References angle.
00057 { 00058 angle += delta * 50.0f; 00059 }
void Spotlight::draw | ( | DrawingContext & | context | ) | [virtual] |
The GameObject should draw itself onto the provided DrawingContext if this function is called.
Implements GameObject.
Definition at line 62 of file spotlight.cpp.
References angle, base, center, color, GL_ONE, GL_SRC_ALPHA, LAYER_FOREGROUND1, light, lightcone, DrawingContext::LIGHTMAP, lights, DrawingContext::NORMAL, DrawingContext::pop_target(), position, DrawingContext::push_target(), and DrawingContext::set_target().
00063 { 00064 context.push_target(); 00065 context.set_target(DrawingContext::LIGHTMAP); 00066 00067 light->set_color(color); 00068 light->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); 00069 light->set_angle(angle); 00070 light->draw(context, position, 0); 00071 00072 //lightcone->set_angle(angle); 00073 //lightcone->draw(context, position, 0); 00074 00075 context.set_target(DrawingContext::NORMAL); 00076 00077 lights->set_angle(angle); 00078 lights->draw(context, position, 0); 00079 00080 base->set_angle(angle); 00081 base->draw(context, position, 0); 00082 00083 center->draw(context, position, 0); 00084 00085 lightcone->set_angle(angle); 00086 lightcone->draw(context, position, LAYER_FOREGROUND1 + 10); 00087 00088 context.pop_target(); 00089 }
Vector Spotlight::position [private] |
float Spotlight::angle [private] |
SpritePtr Spotlight::center [private] |
SpritePtr Spotlight::base [private] |
SpritePtr Spotlight::lights [private] |
SpritePtr Spotlight::light [private] |
SpritePtr Spotlight::lightcone [private] |
Color Spotlight::color [private] |