#include "player.hpp"
#include "sector.hpp"
-Light::Light(const lisp::Lisp& )
+Light::Light(const Vector& center, const Color& color) : position(center), color(color)
{
sprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite");
}
context.push_target();
context.set_target(DrawingContext::LIGHTMAP);
- sprite->draw(context, Sector::current()->player->get_pos(), 0);
+ sprite->set_color(color);
+ sprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ sprite->draw(context, position, 0);
context.pop_target();
}
-IMPLEMENT_FACTORY(Light, "light");
#include "game_object.hpp"
#include "lisp/lisp.hpp"
+#include "math/vector.hpp"
+#include "video/color.hpp"
class Sprite;
class Light : public GameObject
{
public:
- Light(const lisp::Lisp& reader);
+ Light(const Vector& center, const Color& color = Color(1.0, 1.0, 1.0, 1.0));
virtual ~Light();
void update(float elapsed_time);
void draw(DrawingContext& context);
private:
+ Vector position;
+ Color color;
Sprite* sprite;
};
#include "object/coin.hpp"
#include "object/block.hpp"
#include "object/invisible_block.hpp"
+#include "object/light.hpp"
#include "object/bullet.hpp"
#include "object/text_object.hpp"
#include "object/portable.hpp"
}
}
}
+
+ // add lights for special tiles
+ for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); i++) {
+ TileMap* tm = dynamic_cast<TileMap*>(*i);
+ if (!tm) continue;
+ for(size_t x=0; x < tm->get_width(); ++x) {
+ for(size_t y=0; y < tm->get_height(); ++y) {
+ const Tile* tile = tm->get_tile(x, y);
+ Vector pos(tm->get_x_offset() + x*32, tm->get_y_offset() + y*32);
+ Vector center(pos.x + 16, pos.y + 16);
+
+ // torch
+ if (tile->getID() == 1517) {
+ add_object(new Light(center, Color(1.0, 0.6, 0.3, 1.0)));
+ }
+ // lava or lavaflow
+ if ((tile->getID() == 173) || (tile->getID() == 1700) || (tile->getID() == 1705) || (tile->getID() == 1706)) {
+ // space lights a bit
+ if (((tm->get_tile(x-1, y)->getID() != tm->get_tile(x,y)->getID())
+ && (tm->get_tile(x, y-1)->getID() != tm->get_tile(x,y)->getID()))
+ || ((x % 3 == 0) && (y % 3 == 0))) {
+ add_object(new Light(center, Color(1.0, 0.6, 0.6, 1.0)));
+ }
+ }
+
+ }
+ }
+ }
+
+
}
void