#include "object/camera.hpp"
#include "object/player.hpp"
#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
#include "util/reader.hpp"
#define RAND_SPEED 150
Kugelblitz::Kugelblitz(const Reader& reader) :
- BadGuy(reader, "images/creatures/kugelblitz/kugelblitz.sprite"),
+ BadGuy(reader, "images/creatures/kugelblitz/kugelblitz.sprite"),
pos_groundhit(),
groundhit_pos_set(false),
dying(),
movement_timer(),
lifetime(),
direction(),
- state()
+ light(0.0f,0.0f,0.0f),
+ lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite"))
{
reader.get("x", start_position.x);
sprite->set_action("falling");
physic.enable_gravity(false);
countMe = false;
+
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.2f, 0.1f, 0.0f));
}
void
}
HitResponse
-Kugelblitz::hit(const CollisionHit& hit)
+Kugelblitz::hit(const CollisionHit& hit_)
{
// hit floor?
- if(hit.bottom) {
+ if(hit_.bottom) {
if (!groundhit_pos_set)
{
pos_groundhit = get_pos();
movement_timer.start(MOVETIME);
lifetime.start(LIFETIME);
- } else if(hit.top) { // bumped on roof
+ } else if(hit_.top) { // bumped on roof
physic.set_velocity_y(0);
}
}
void
+Kugelblitz::draw(DrawingContext& context)
+{
+ sprite->draw(context, get_pos(), layer);
+
+ //Only draw light in dark areas
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green < 2.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ sprite->draw(context, get_pos(), layer);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+}
+
+void
Kugelblitz::kill_fall()
{
}
float X_OFFSCREEN_DISTANCE = 400;
float Y_OFFSCREEN_DISTANCE = 600;
- Player* player = get_nearest_player();
- if (!player) return;
- Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle();
+ Player* player_ = get_nearest_player();
+ if (!player_) return;
+ Vector dist = player_->get_bbox().get_middle() - get_bbox().get_middle();
if ((fabsf(dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(dist.y) <= Y_OFFSCREEN_DISTANCE)) {
set_state(STATE_ACTIVE);
if (!is_initialized) {
// if starting direction was set to AUTO, this is our chance to re-orient the badguy
if (start_dir == AUTO) {
- Player* player = get_nearest_player();
- if (player && (player->get_bbox().p1.x > get_bbox().p2.x)) {
+ Player* player__ = get_nearest_player();
+ if (player__ && (player__->get_bbox().p1.x > get_bbox().p2.x)) {
dir = RIGHT;
} else {
dir = LEFT;