Light Class Reference

#include <light.hpp>

Inherits GameObject.

Inherited by PulsingLight.

List of all members.

Public Member Functions

 Light (const Vector &center, const Color &color=Color(1.0, 1.0, 1.0, 1.0))
virtual ~Light ()
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.

Protected Attributes

Vector position
Color color
SpritePtr sprite


Detailed Description

Definition at line 27 of file light.hpp.


Constructor & Destructor Documentation

Light::Light ( const Vector center,
const Color color = Color(1.0, 1.0, 1.0, 1.0) 
)

Definition at line 21 of file light.cpp.

References SpriteManager::create(), sprite, and sprite_manager.

00021                                                      : 
00022   position(center), 
00023   color(color),
00024   sprite()
00025 {
00026   sprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite");
00027 }

Light::~Light (  )  [virtual]

Definition at line 29 of file light.cpp.

00030 {
00031 }


Member Function Documentation

void Light::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.

Reimplemented in PulsingLight.

Definition at line 34 of file light.cpp.

Referenced by PulsingLight::update().

00035 {
00036 }

void Light::draw ( DrawingContext context  )  [virtual]

The GameObject should draw itself onto the provided DrawingContext if this function is called.

Implements GameObject.

Reimplemented in PulsingLight.

Definition at line 39 of file light.cpp.

References color, GL_ONE, GL_SRC_ALPHA, DrawingContext::LIGHTMAP, DrawingContext::pop_target(), position, DrawingContext::push_target(), DrawingContext::set_target(), and sprite.

Referenced by PulsingLight::draw().

00040 {
00041   context.push_target();
00042   context.set_target(DrawingContext::LIGHTMAP);
00043 
00044   sprite->set_color(color);
00045   sprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
00046   sprite->set_angle(90); // FIXME: color won't get applied for angle=0
00047   sprite->draw(context, position, 0);
00048 
00049   context.pop_target();
00050 }


Member Data Documentation

Vector Light::position [protected]

Definition at line 37 of file light.hpp.

Referenced by draw().

Color Light::color [protected]

Definition at line 38 of file light.hpp.

Referenced by PulsingLight::draw(), and draw().

SpritePtr Light::sprite [protected]

Definition at line 39 of file light.hpp.

Referenced by draw(), and Light().


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