Several enhancements to make dark levels more viable by adding a glow to several objects. Candles have additional functionality to allow for many custom ambient lighting effects. An ice vulnerability is also added to flame badguys; in addition, a fire vulnerable and invulnerable version of flame is added. Finally a spiky-like badguy, LiveFire, is added which offers a sleeping and dormant (does not wake) state as well. The effects can be observed in the added test level: "Glow Effects Test".
TODO: LiveFire graphics, regular level(s) intoducing the effects, and the addition of new sprites for candles would be nice.
(images "flame-0.png"
"flame-1.png"))
(action
+ (hitbox 0 0 31.8 31.8)
+ (name "fade")
+ (fps 5)
+ (images "flame-1.png"
+ "flame-fade-0.png"
+ "flame-fade-1.png"
+ "flame-fade-2.png"
+ "flame-fade-3.png"))
+ (action
(hitbox 96 96 127.8 31.8)
(name "editor")
(images "flame-editor.png"))
--- /dev/null
+(supertux-sprite
+ (action
+ (hitbox 0.2 0.2 31.6 31.6)
+ (name "normal")
+ (images "ghostflame-0.png"
+ "ghostflame-1.png"
+ "ghostflame-2.png"
+ "ghostflame-3.png"
+ "ghostflame-4.png"))
+ (action
+ (hitbox 96 96 127.8 31.8)
+ (name "editor")
+ (images "ghostflame-editor.png"))
+
+)
+
--- /dev/null
+(supertux-sprite
+ (action
+ (hitbox 0 0 31.8 31.8)
+ (name "normal")
+ (images "iceflame.png"))
+ (action
+ (hitbox 0 0 31.8 31.8)
+ (name "fade")
+ (fps 5)
+ (images "iceflame-fade-0.png"
+ "iceflame-fade-1.png"
+ "iceflame-fade-2.png"))
+ (action
+ (hitbox 96 96 127.8 31.8)
+ (name "editor")
+ (images "iceflame-editor.png"))
+)
+
--- /dev/null
+(supertux-sprite
+ (action
+ (name "left")
+ (hitbox 6 10 31.8 31.8)
+ (images "left-0.png"
+ "left-1.png"
+ "left-2.png"))
+ (action
+ (name "right")
+ (hitbox 6 10 31.8 31.8)
+ (mirror-action "left"))
+ (action
+ (name "sleeping-left")
+ (hitbox 6 10 31.8 31.8)
+ (images "sleeping-left.png"))
+ (action
+ (name "sleeping-right")
+ (hitbox 6 10 31.8 31.8)
+ (mirror-action "sleeping-left"))
+ (action
+ (name "waking-left")
+ (hitbox 6 10 31.8 31.8)
+ (fps 6.0)
+ (images "waking-left-0.png"
+ "waking-left-1.png"
+ "waking-left-2.png"))
+ (action
+ (name "waking-right")
+ (fps 6.0)
+ (hitbox 6 10 31.8 31.8)
+ (mirror-action "waking-left"))
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "candle-light-1.png")
+ (hitbox 256 256 0 0)
+ )
+ (action
+ (name "white")
+ (images "candle-light-white-1.png")
+ (hitbox 256 256 0 0)
+ )
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "candle-light-2.png")
+ (hitbox 256 256 0 0)
+ )
+ (action
+ (name "white")
+ (images "candle-light-white-2.png")
+ (hitbox 256 256 0 0)
+ )
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "on")
+ (images
+ "torch1.png"
+ "torch2.png"
+ "torch3.png"
+ )
+ )
+ (action
+ (name "off")
+ (hitbox 0 -32 32 32)
+ (images
+ "torch-off.png"
+ )
+ )
+ )
+
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "lightmap_light-large.png")
+ (hitbox 512 512 0 0)
+ )
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "lightmap_light-medium.png")
+ (hitbox 192 192 0 0)
+ )
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "lightmap_light-small.png")
+ (hitbox 64 64 0 0)
+ )
+)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "default")
+ (images "lightmap_light-tiny.png")
+ (hitbox 32 32 0 0)
+ )
+)
--- /dev/null
+(supertux-level
+ (version 2)
+ (name (_ "Glow Effects Test"))
+ (author "LMH")
+ (license "GPL 2 / CC-by-sa 3.0" )
+ (sector (name "main" )
+ (ambient-light 0.02 0.02 0.02 )
+ (camera (mode "normal" ))
+ (music "music/voc-dark.ogg" )
+
+ (spawnpoint (name "main" )
+ (x 64 )(y 448 ))
+ (spawnpoint (name "top" )
+ (x 656 )(y 288 ))
+
+
+ (mrbomb (x 832 )(y 736 ))
+ (short_fuse (x 1056 )(y 736 ))
+ (short_fuse (x 1152 )(y 736 ))
+ (short_fuse (x 1248 )(y 736 ))
+ (haywire (x 928 )(y 736 ))
+ (flame (x 576 )(y 480 )(speed 0.2))
+ (iceflame (x 736 )(y 480 )(speed 0.2))
+ (ghostflame (x 656 )(y 96 ))
+ (livefire (x 224 )(y 192 ))
+ (livefire_asleep (x 64 )(y 192 )(direction "right"))
+ (livefire_dormant (x 128)(y 192))
+
+ (tilemap (name "Interactive" )
+ (z-pos 0 )(solid #t )
+ (width 42 )(height 30 )
+ (tiles ; 160 192 224 256 288 320 352 384 416 448 480 512 544 576 608 640 672 704 736 768 800 832 864 896 928 960 992 1024 1056 1088 1120 1152 1184 1216 1248 1280 1312
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 32
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 64
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 96
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 128
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 160
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 192
+48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 224
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 256
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 130 133 ; 288
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 129 133 ; 320
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2817 0 1408 1388 0 2817 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1408 1412 1412 ; 352
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 384
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 416
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 448
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1408 1412 1412 1412 1412 1412 1412 1412 1412 1388 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480
+48 48 48 48 48 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 48 48 48 48 48 48 48 ; 512
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 544
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 576
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 608
+0 0 0 0 0 0 0 0 48 48 48 48 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 640
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 672
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 704
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 48 ; 736
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 768
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 800
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 832
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 864
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 0 0 0 0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 896
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 2136 2137 2138 2139 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 ; 928
+ ))
+
+ (candle (x 128 )(y 480 ))
+ (candle (x 96 )(y 736 )(color 1 0 0 )(name "red" ))
+ (candle (x 320 )(y 736 )(color 1 0.5 0 )(name "orange" ))
+ (candle (x 544 )(y 736 )(color 1 1 0 )(name "yellow" ))
+ (candle (x 768 )(y 736 )(color 0 1 0 )(name "green" ))
+ (candle (x 992 )(y 736 )(color 0 0 1 )(name "blue" ))
+ (candle (x 1216 )(y 736 )(color 0.5 0 0.5 )(name "purple" ))
+ (candle (x 1184 )(y 480 )(color 1 1 1 ))
+
+ (candle (x 608 )(y 960 )(color 0.4 0.1 0 )(flicker #f ))
+ (candle (x 640 )(y 960 )(color 0.4 0.1 0 )(flicker #f ))
+ (candle (x 672 )(y 960 )(color 0.4 0.1 0 )(flicker #f ))
+ (candle (x 704 )(y 960 )(color 0.4 0.1 0 )(flicker #f ))
+
+ (candle (x 576 )(y 320 )(color 1 0.2 0.05 )(name "torch1" )(sprite "images/objects/candle/torch/torch.sprite" )(burning #f ))
+ (candle (x 736 )(y 320 )(color 1 0.2 0.05 )(name "torch2" )(sprite "images/objects/candle/torch/torch.sprite" )(burning #f ))
+
+ (switch (script " red.set_burning(!red.get_burning());
+ wait( 0.1 );
+ orange.set_burning(!orange.get_burning());
+ wait( 0.1 );
+ yellow.set_burning(!yellow.get_burning());
+ wait( 0.1 );
+ green.set_burning(!green.get_burning());
+ wait( 0.1 );
+ blue.set_burning(!blue.get_burning());
+ wait( 0.1 );
+ purple.set_burning(!purple.get_burning()); ")(sprite "images/objects/switch/switch.sprite" )
+ (x 96 )(y 448 ))
+
+ (switch (script " torch1.set_burning(!torch1.get_burning());
+ torch2.set_burning(!torch2.get_burning()); ")(sprite "images/objects/switch/switch.sprite" )
+ (x 1216 )(y 448 ))
+ (switch (script " settings.set_ambient_light((settings.get_ambient_red() + 0.14 > 1) ? 0.02 : settings.get_ambient_red() + 0.14 , (settings.get_ambient_green() + 0.14 > 1) ? 0.02 : settings.get_ambient_green() + 0.14 , (settings.get_ambient_blue() + 0.14 > 1) ? 0.02 : settings.get_ambient_blue() + 0.14 ); ")(sprite "images/objects/switch/switch.sprite" )
+ (x 320 )(y 576 ))
+
+ (bonusblock (x 544 )(y 352 )(contents "icegrow" )(count 0 ))
+ (bonusblock (x 608 )(y 352 )(contents "star" )(count 0 ))
+ (bonusblock (x 704 )(y 352 )(contents "1up" )(count 0 ))
+ (bonusblock (x 768 )(y 352 )(contents "firegrow" )(count 0 ))
+
+ (willowisp (x 48 )(y 544)(spawnpoint "top" ))
+ (willowisp (x 1232 )(y 544)(spawnpoint "top" ))
+
+ (powerup (x 0 )(y 320 )(sprite "images/powerups/iceflower/iceflower.sprite" ))
+ (powerup (x 0 )(y 480 )(sprite "images/powerups/fireflower/fireflower.sprite" ))
+
+ (weak_block (x 0 )(y 352 )(linked #f ))
+ (weak_block (x 32 )(y 352 ))
+ (weak_block (x 64 )(y 352 ))
+ (weak_block (x 96 )(y 352 ))
+ (weak_block (x 128 )(y 352 ))
+ (weak_block (x 160 )(y 352 ))
+
+ (magicblock (x 416 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 448 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 480 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 512 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 544 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 576 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 608 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 640 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 672 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 704 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 736 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 768 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 800 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 832 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 864 )(y 224 )(color 1 1 1 ))
+ (magicblock (x 896 )(y 224 )(color 1 1 1 ))
+))
#include <math.h>
#include "audio/sound_manager.hpp"
+#include "math/random_generator.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "object/sprite_particle.hpp"
#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
#include "util/reader.hpp"
static const std::string FLAME_SOUND = "sounds/flame.wav";
angle(0),
radius(100),
speed(2),
+ fading(false),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
sound_source()
{
reader.get("radius", radius);
sound_manager->preload(FLAME_SOUND);
set_colgroup_active(COLGROUP_TOUCHABLE);
+
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.21f, 0.13f, 0.08f));
}
void
movement = newpos - get_pos();
sound_source->set_position(get_pos());
+
+ if(fading)
+ if (sprite->animation_done()) remove_me();
+}
+
+void
+Flame::draw(DrawingContext& context)
+{
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light if dark
+ if(true){
+ 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
sound_source.reset();
}
+
void
Flame::kill_fall()
{
}
+void
+Flame::freeze()
+{
+ //TODO: get unique death sound
+ sound_manager->play("sounds/fizz.wav", get_pos());
+ sprite->set_action("fade", 1);
+ Vector ppos = bbox.get_middle();
+ Vector pspeed = Vector(0, -150);
+ Vector paccel = Vector(0,0);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+ fading = true;
+
+ // start dead-script
+ run_dead_script();
+}
+
+bool
+Flame::is_freezable() const
+{
+ return true;
+}
+
/* EOF */
void deactivate();
void active_update(float elapsed_time);
+ void draw(DrawingContext& context);
void kill_fall();
+ void freeze();
+ bool is_freezable() const;
+
private:
float angle;
float radius;
float speed;
+ bool fading;
+ Color light;
+ SpritePtr lightsprite;
std::auto_ptr<SoundSource> sound_source;
};
--- /dev/null
+// SuperTux badguy - Ghostflame a flame-like enemy that cannot be killed
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "badguy/ghostflame.hpp"
+
+#include <math.h>
+
+#include "audio/sound_manager.hpp"
+#include "math/random_generator.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "object/sprite_particle.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
+#include "util/reader.hpp"
+
+Ghostflame::Ghostflame(const Reader& reader) :
+ BadGuy(reader, "images/creatures/flame/ghostflame.sprite", LAYER_FLOATINGOBJECTS),
+ angle(0),
+ radius(100),
+ speed(2),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+{
+ reader.get("radius", radius);
+ reader.get("speed", speed);
+ bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
+ start_position.y + sin(angle) * radius));
+ countMe = false;
+ //TODO: get unique death sound
+ sound_manager->preload("sounds/fizz.wav");
+
+ set_colgroup_active(COLGROUP_TOUCHABLE);
+
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.21f, 0.00f, 0.21f));
+
+}
+
+void
+Ghostflame::active_update(float elapsed_time)
+{
+ angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
+ Vector newpos(start_position.x + cos(angle) * radius,
+ start_position.y + sin(angle) * radius);
+ movement = newpos - get_pos();
+
+}
+
+void
+Ghostflame::draw(DrawingContext& context)
+{
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light if dark
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.blue + light.red < 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
+Ghostflame::kill_fall()
+{
+}
+
+/* EOF */
--- /dev/null
+// SuperTux badguy - Ghostflame a flame-like enemy that cannot be killed
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_BADGUY_GHOSTFLAME_HPP
+#define HEADER_SUPERTUX_BADGUY_GHOSTFLAME_HPP
+
+#include "badguy/badguy.hpp"
+
+class Ghostflame : public BadGuy
+{
+public:
+ Ghostflame(const Reader& reader);
+ Ghostflame(const Ghostflame& ghostflame);
+
+ void active_update(float elapsed_time);
+ void draw(DrawingContext& context);
+ void kill_fall();
+
+private:
+ float angle;
+ float radius;
+ float speed;
+ Color light;
+ SpritePtr lightsprite;
+
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux badguy - Iceflame a flame-like enemy that can be killed with fireballs
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "badguy/iceflame.hpp"
+
+#include <math.h>
+
+#include "audio/sound_manager.hpp"
+#include "math/random_generator.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "object/sprite_particle.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
+#include "util/reader.hpp"
+
+Iceflame::Iceflame(const Reader& reader) :
+ BadGuy(reader, "images/creatures/flame/iceflame.sprite", LAYER_FLOATINGOBJECTS),
+ angle(0),
+ radius(100),
+ speed(2),
+ fading(false),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+{
+ reader.get("radius", radius);
+ reader.get("speed", speed);
+ bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
+ start_position.y + sin(angle) * radius));
+ countMe = false;
+ //TODO: get unique death sound
+ sound_manager->preload("sounds/fizz.wav");
+
+ set_colgroup_active(COLGROUP_TOUCHABLE);
+
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.00f, 0.13f, 0.18f));
+
+}
+
+void
+Iceflame::active_update(float elapsed_time)
+{
+ angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
+ Vector newpos(start_position.x + cos(angle) * radius,
+ start_position.y + sin(angle) * radius);
+ movement = newpos - get_pos();
+
+ if(fading)
+ if (sprite->animation_done()) remove_me();
+}
+
+void
+Iceflame::draw(DrawingContext& context)
+{
+ context.push_target();
+ //Rotate the Sprite (3 rotations per revolution)
+ sprite->set_angle(angle * 360.0f / (2*M_PI) * 3);
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light if dark
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.blue + light.green < 2.0){
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ }
+ context.pop_target();
+}
+
+
+void
+Iceflame::kill_fall()
+{
+}
+
+void
+Iceflame::ignite()
+{
+ sound_manager->play("sounds/fizz.wav", get_pos());
+ sprite->set_action("fade", 1);
+ Vector ppos = bbox.get_middle();
+ Vector pspeed = Vector(0, -150);
+ Vector paccel = Vector(0,0);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+ fading = true;
+
+ // start dead-script
+ run_dead_script();
+}
+
+bool
+Iceflame::is_flammable() const
+{
+ return true;
+}
+
+/* EOF */
--- /dev/null
+// SuperTux badguy - Iceflame a flame-like enemy that can be killed with fireballs
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_BADGUY_ICEFLAME_HPP
+#define HEADER_SUPERTUX_BADGUY_ICEFLAME_HPP
+
+#include "badguy/badguy.hpp"
+
+class Iceflame : public BadGuy
+{
+public:
+ Iceflame(const Reader& reader);
+ Iceflame(const Iceflame& iceflame);
+
+ void active_update(float elapsed_time);
+ void draw(DrawingContext& context);
+ void kill_fall();
+
+ void ignite();
+ bool is_flammable() const;
+
+private:
+ float angle;
+ float radius;
+ float speed;
+ bool fading;
+ Color light;
+ SpritePtr lightsprite;
+
+};
+
+#endif
+
+/* EOF */
#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"
movement_timer(),
lifetime(),
direction(),
- state()
+ state(),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->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
}
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()
{
}
void active_update(float);
void kill_fall();
void explode();
+
+ virtual void draw(DrawingContext& context);
private:
void try_activate();
Timer lifetime;
int direction;
State state;
+ Color light;
+ SpritePtr lightsprite;
};
#endif
--- /dev/null
+// SuperTux badguy - walking flame that glows
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "badguy/livefire.hpp"
+
+#include "audio/sound_manager.hpp"
+#include "object/player.hpp"
+#include "object/sprite_particle.hpp"
+#include "sprite/sprite.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
+
+static const float WALKSPEED = 80;
+static const float MAXDROPHEIGHT = 20;
+
+LiveFire::LiveFire(const Reader& reader) :
+ WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
+ state(STATE_WALKING)
+{
+ walk_speed = WALKSPEED;
+ max_drop_height = MAXDROPHEIGHT;
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(1.0f, 0.9f, 0.8f));
+}
+
+void
+LiveFire::collision_solid(const CollisionHit& hit)
+{
+ if(state != STATE_WALKING) {
+ BadGuy::collision_solid(hit);
+ return;
+ }
+ WalkingBadguy::collision_solid(hit);
+}
+
+HitResponse
+LiveFire::collision_badguy(BadGuy& badguy, const CollisionHit& hit)
+{
+ if(state != STATE_WALKING) {
+ return BadGuy::collision_badguy(badguy, hit);
+ }
+ return WalkingBadguy::collision_badguy(badguy, hit);
+}
+
+void
+LiveFire::active_update(float elapsed_time) {
+
+ if(state == STATE_WALKING) {
+ WalkingBadguy::active_update(elapsed_time);
+ return;
+ }
+
+ if(state == STATE_SLEEPING) {
+
+ Player* player = this->get_nearest_player();
+ if (player) {
+ Rectf mb = this->get_bbox();
+ Rectf pb = player->get_bbox();
+
+ bool inReach_left = (pb.p2.x >= mb.p2.x-((dir == LEFT) ? 256 : 0));
+ bool inReach_right = (pb.p1.x <= mb.p1.x+((dir == RIGHT) ? 256 : 0));
+ bool inReach_top = (pb.p2.y >= mb.p1.y);
+ bool inReach_bottom = (pb.p1.y <= mb.p2.y);
+
+ if (inReach_left && inReach_right && inReach_top && inReach_bottom) {
+ // wake up
+ sprite->set_action(dir == LEFT ? "waking-left" : "waking-right", 1);
+ state = STATE_WAKING;
+ }
+ }
+
+ BadGuy::active_update(elapsed_time);
+ }
+
+ if(state == STATE_WAKING) {
+ if(sprite->animation_done()) {
+ // start walking
+ state = STATE_WALKING;
+ WalkingBadguy::initialize();
+ }
+
+ BadGuy::active_update(elapsed_time);
+ }
+}
+
+void
+LiveFire::draw(DrawingContext& context)
+{
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+}
+
+void
+LiveFire::freeze()
+{
+ // attempting to freeze a flame causes it to go out
+ kill_fall();
+}
+
+bool
+LiveFire::is_freezable() const
+{
+ return true;
+}
+
+bool
+LiveFire::is_flammable() const
+{
+ return false;
+}
+
+void
+LiveFire::kill_fall()
+{
+ //TODO: get unique sound for ice-fire encounters
+ sound_manager->play("sounds/fall.wav", get_pos());
+ // throw a puff of smoke
+ Vector ppos = bbox.get_middle();
+ Vector pspeed = Vector(0, -150);
+ Vector paccel = Vector(0,0);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+ // extinguish the flame
+ sprite->set_action(dir == LEFT ? "extinguish-left" : "extinguish-right");
+ physic.set_velocity_y(0);
+ physic.set_acceleration_y(0);
+ physic.enable_gravity(false);
+ set_state(STATE_SQUISHED); // used to nullify any threat and remove
+
+ // start dead-script
+ run_dead_script();
+}
+
+/* The following defines a sleeping version */
+
+LiveFireAsleep::LiveFireAsleep(const Reader& reader) :
+ LiveFire(reader)
+{
+ state = STATE_SLEEPING;
+}
+
+void
+LiveFireAsleep::initialize()
+{
+ physic.set_velocity_x(0);
+ sprite->set_action(dir == LEFT ? "sleeping-left" : "sleeping-right");
+}
+
+/* The following defines a dormant version that never wakes */
+LiveFireDormant::LiveFireDormant(const Reader& reader) :
+ LiveFire(reader)
+{
+ walk_speed = 0;
+ state = STATE_DORMANT;
+}
+
+void
+LiveFireDormant::initialize()
+{
+ physic.set_velocity_x(0);
+ sprite->set_action(dir == LEFT ? "sleeping-left" : "sleeping-right");
+}
+
+/* EOF */
--- /dev/null
+// SuperTux badguy - walking flame that glows
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_BADGUY_LiveFire_HPP
+#define HEADER_SUPERTUX_BADGUY_LiveFire_HPP
+
+#include "badguy/walking_badguy.hpp"
+
+class LiveFire : public WalkingBadguy
+{
+public:
+ LiveFire(const Reader& reader);
+
+ void collision_solid(const CollisionHit& hit);
+ HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
+ void active_update(float elapsed_time);
+ void draw(DrawingContext& context);
+
+ void freeze();
+ bool is_freezable() const;
+ bool is_flammable() const;
+
+ virtual void kill_fall();
+
+private:
+ SpritePtr lightsprite;
+
+protected:
+ enum SState {
+ STATE_SLEEPING,
+ STATE_WAKING,
+ STATE_WALKING,
+ STATE_DORMANT
+ };
+ SState state;
+};
+
+class LiveFireAsleep : public LiveFire
+{
+public:
+ LiveFireAsleep(const Reader& reader);
+
+ void initialize();
+};
+
+class LiveFireDormant : public LiveFire
+{
+public:
+ LiveFireDormant(const Reader& reader);
+
+ void initialize();
+};
+
+#endif
+
+/* EOF */
#include "object/player.hpp"
#include "scripting/squirrel_util.hpp"
#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
#include "supertux/game_session.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
walker(),
flyspeed(),
track_range(),
- vanish_range()
+ vanish_range(),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
bool running = false;
flyspeed = FLYSPEED;
sound_manager->preload(SOUNDFILE);
sound_manager->preload("sounds/warp.wav");
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.0f, 0.2f, 0.0f));
+
sprite->set_action("idle");
}
context.set_target(DrawingContext::LIGHTMAP);
sprite->draw(context, get_pos(), layer);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
context.pop_target();
}
float flyspeed;
float track_range;
float vanish_range;
+ SpritePtr lightsprite;
};
#endif
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "math/random_generator.hpp"
#include "object/bullet.hpp"
#include "object/camera.hpp"
+#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
#include "supertux/globals.hpp"
#include "supertux/sector.hpp"
physic(),
life_count(3),
sprite(),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
type(type)
{
float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
if(type == FIRE_BONUS) {
sprite = sprite_manager->create("images/objects/bullets/firebullet.sprite");
- } else if(type == ICE_BONUS) {
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.3f, 0.1f, 0.0f));
+ } else if(type == ICE_BONUS) {
life_count = 10;
sprite = sprite_manager->create("images/objects/bullets/icebullet.sprite");
} else {
void
Bullet::update(float elapsed_time)
{
+ // cause fireball color to flicker randomly
+ if (gameRandom.rand(5) != 0) {
+ lightsprite->set_color(Color(0.3f + gameRandom.rand(10)/100.0f, 0.1f + gameRandom.rand(20)/100.0f, gameRandom.rand(10)/100.0f));
+ } else
+ lightsprite->set_color(Color(0.3f, 0.1f, 0.0f));
// remove bullet when it's offscreen
float scroll_x =
Sector::current()->camera->get_translation().x;
void
Bullet::draw(DrawingContext& context)
{
+ //Draw the Sprite.
sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light if fire and dark
+ if(type == FIRE_BONUS){
+ 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_OBJECTS);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+ }
}
void
Physic physic;
int life_count;
SpritePtr sprite;
+ Color light;
+ SpritePtr lightsprite;
BonusType type;
};
#include "util/reader.hpp"
Candle::Candle(const Reader& lisp)
- : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED), burning(true),
- candle_light_1(Surface::create("images/objects/candle/candle-light-1.png")),
- candle_light_2(Surface::create("images/objects/candle/candle-light-2.png"))
+ : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED),
+ burning(true),
+ flicker(true),
+ lightcolor(1.0f, 1.0f, 1.0f),
+ candle_light_1(sprite_manager->create("images/objects/candle/candle-light-1.sprite")),
+ candle_light_2(sprite_manager->create("images/objects/candle/candle-light-2.sprite"))
{
lisp.get("name", name);
lisp.get("burning", burning);
-
+ lisp.get("flicker", flicker);
+ //get color from lisp
+ std::vector<float> vColor;
+ lisp.get("color", vColor);
+ //change the light color if defined
+ if (vColor.size() >= 3) {
+ lightcolor = Color(vColor);
+ candle_light_1->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ candle_light_2->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ candle_light_1->set_color(lightcolor);
+ candle_light_2->set_color(lightcolor);
+ //the following allows the original candle appearance to be preserved
+ candle_light_1->set_action("white");
+ candle_light_2->set_action("white");
+ }
+
if (burning) {
sprite->set_action("on");
} else {
// draw on lightmap
if (burning) {
- Vector pos = get_pos() + (bbox.get_size() - candle_light_1->get_size()) / 2;
+ //Vector pos = get_pos() + (bbox.get_size() - candle_light_1->get_size()) / 2;
context.push_target();
context.set_target(DrawingContext::LIGHTMAP);
// draw approx. 1 in 10 frames darker. Makes the candle flicker
- if (gameRandom.rand(10) != 0) {
- context.draw_surface(candle_light_1, pos, layer);
+ if (gameRandom.rand(10) != 0 || !flicker) {
+ //context.draw_surface(candle_light_1, pos, layer);
+ candle_light_1->draw(context, get_bbox().get_middle(), 0);
} else {
- context.draw_surface(candle_light_2, pos, layer);
+ //context.draw_surface(candle_light_2, pos, layer);
+ candle_light_2->draw(context, get_bbox().get_middle(), 0);
}
context.pop_target();
}
this->burning = burning;
if (burning) {
sprite->set_action("on");
- puff_smoke();
} else {
sprite->set_action("off");
- puff_smoke();
}
+ //puff smoke for flickering light sources only
+ if (flicker) puff_smoke();
}
/* EOF */
private:
bool burning; /**< true if candle is currently lighted */
- SurfacePtr candle_light_1; /**< drawn to lightmap */
- SurfacePtr candle_light_2; /**< drawn to lightmap (alternative image) */
+ bool flicker; /**< true if candle light is to flicker */
+ Color lightcolor; /**< determines color or light given off */
+ SpritePtr candle_light_1; /**< drawn to lightmap */
+ SpritePtr candle_light_2; /**< drawn to lightmap (alternative image) */
};
#include "math/random_generator.hpp"
#include "object/player.hpp"
#include "object/sprite_particle.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING),
hurt(true),
push(false),
- state(STATE_WAITING)
+ state(STATE_WAITING),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
{
sound_manager->preload("sounds/explosion.wav");
set_pos(get_pos() - (get_bbox().get_middle() - get_pos()));
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.6f, 0.6f, 0.6f));
}
Explosion::Explosion(const Reader& reader) :
MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING),
hurt(true),
push(false),
- state(STATE_WAITING)
+ state(STATE_WAITING),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
{
sound_manager->preload("sounds/explosion.wav");
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.6f, 0.6f, 0.6f));
}
void
}
}
+void
+Explosion::draw(DrawingContext& context)
+{
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS+40);
+ //Explosions produce light (if ambient light is not maxed)
+ context.get_light( get_bbox().get_middle(), &light);
+ if (light.red + light.green + light.blue < 3.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+}
+
HitResponse
Explosion::collision(GameObject& other, const CollisionHit& )
{
Explosion(const Reader& reader);
void update(float elapsed_time);
+ void draw(DrawingContext& context);
HitResponse collision(GameObject& other, const CollisionHit& hit);
bool hurts (void) const
bool hurt;
bool push;
State state;
+ Color light;
+ SpritePtr lightsprite;
};
#include "audio/sound_manager.hpp"
#include "object/flower.hpp"
#include "object/player.hpp"
+#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
Flower::Flower(BonusType _type) :
type(_type),
sprite(),
- drawing_effect(NO_EFFECT)
+ drawing_effect(NO_EFFECT),
+ light(1.0f,1.0f,1.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
bbox.set_size(32, 32);
-
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+
if(type == FIRE_BONUS) {
sprite = sprite_manager->create("images/powerups/fireflower/fireflower.sprite");
sound_manager->preload("sounds/fire-flower.wav");
+ lightsprite->set_color(Color(0.3f, 0.0f, 0.0f));
}
else if(type == ICE_BONUS) {
sprite = sprite_manager->create("images/powerups/iceflower/iceflower.sprite");
sound_manager->preload("sounds/fire-flower.wav");
+ lightsprite->set_color(Color(0.0f, 0.1f, 0.2f));
} else {
assert(false);
}
void
Flower::draw(DrawingContext& context)
{
+ //Draw the Sprite.
sprite->draw(context, get_pos(), LAYER_OBJECTS, drawing_effect);
+ //Draw the light when dark
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green + light.blue < 3.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
}
HitResponse
private:
Flower(const Flower&);
Flower& operator=(const Flower&);
-
+ Color light;
+ SpritePtr lightsprite;
+
friend class FlipLevelTransformer;
};
#include "audio/sound_manager.hpp"
#include "object/growup.hpp"
#include "object/player.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
GrowUp::GrowUp(Direction direction) :
MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING),
- physic()
+ physic(),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
physic.enable_gravity(true);
physic.set_velocity_x((direction == LEFT)?-100:100);
sound_manager->preload("sounds/grow.ogg");
+ //set light for glow effect
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
}
void
}
void
+GrowUp::draw(DrawingContext& context){
+ //Draw the Sprite.
+ MovingSprite::draw(context);
+ //Draw the light when dark
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green < 2.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+}
+
+void
GrowUp::collision_solid(const CollisionHit& hit)
{
if(hit.top)
GrowUp(Direction direction = RIGHT);
virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
virtual void collision_solid(const CollisionHit& hit);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
void do_jump();
private:
Physic physic;
+ Color light;
+ SpritePtr lightsprite;
};
#endif
#include "object/powerup.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
#include "util/reader.hpp"
#include <sstream>
MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING),
physic(),
script(),
- no_physics()
+ no_physics(),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
lisp.get("script", script);
no_physics = false;
physic.enable_gravity(true);
sound_manager->preload("sounds/grow.ogg");
sound_manager->preload("sounds/fire-flower.wav");
+ //set default light for glow effect for standard sprites
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.0f, 0.0f, 0.0f));
+ if (sprite_name == "images/powerups/egg/egg.sprite") {
+ lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
+ } else if (sprite_name == "images/powerups/fireflower/fireflower.sprite") {
+ lightsprite->set_color(Color(0.3f, 0.0f, 0.0f));
+ } else if (sprite_name == "images/powerups/iceflower/iceflower.sprite") {
+ lightsprite->set_color(Color(0.0f, 0.1f, 0.2f));
+ } else if (sprite_name == "images/powerups/star/star.sprite") {
+ lightsprite->set_color(Color(0.4f, 0.4f, 0.4f));
+ }
+
}
void
if(!player->add_bonus(FIRE_BONUS, true))
return FORCE_MOVE;
sound_manager->play("sounds/fire-flower.wav");
+ } else if (sprite_name == "images/powerups/iceflower/iceflower.sprite") {
+ if(!player->add_bonus(ICE_BONUS, true))
+ return FORCE_MOVE;
+ sound_manager->play("sounds/fire-flower.wav");
} else if (sprite_name == "images/powerups/star/star.sprite") {
player->make_invincible();
} else if (sprite_name == "images/powerups/1up/1up.sprite") {
movement = physic.get_movement(elapsed_time);
}
+void
+PowerUp::draw(DrawingContext& context){
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), layer);
+ //Draw light when dark for defaults
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green + light.blue < 3.0){
+ //Stars are brighter
+ if (sprite_name == "images/powerups/star/star.sprite") {
+ sprite->draw(context, get_pos(), layer);
+ }
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+}
/* EOF */
PowerUp(const Reader& lisp);
virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
virtual void collision_solid(const CollisionHit& hit);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
Physic physic;
std::string script;
bool no_physics;
+ Color light;
+ SpritePtr lightsprite;
};
#endif
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "object/camera.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
#include "object/sprite_particle.hpp"
#include "supertux/globals.hpp"
#include "supertux/sector.hpp"
position(position),
velocity(velocity),
acceleration(acceleration),
- drawing_layer(drawing_layer)
+ drawing_layer(drawing_layer),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")),
+ glow(false)
{
sprite = sprite_manager->create(sprite_name);
if (!sprite.get()) throw std::runtime_error("Could not load sprite "+sprite_name);
sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action
this->position -= get_anchor_pos(sprite->get_current_hitbox(), anchor);
+
+ if(sprite_name=="images/objects/particles/sparkle.sprite")
+ glow = true;
}
SpriteParticle::~SpriteParticle()
SpriteParticle::draw(DrawingContext& context)
{
sprite->draw(context, position, drawing_layer);
+
+ //Sparkles glow in the dark
+ if(glow){
+ context.get_light(position, &light );
+ if (light.red + light.green + light.blue < 3.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ sprite->draw(context, position, drawing_layer);
+ lightsprite->draw(context, position + Vector(12,12), 0);
+ context.pop_target();
+ }
+ }
+
}
/* EOF */
Vector velocity;
Vector acceleration;
int drawing_layer;
+ Color light;
+ SpritePtr lightsprite;
+ bool glow;
private:
SpriteParticle(const SpriteParticle&);
#include "object/player.hpp"
#include "object/star.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
static const float INITIALJUMP = -400;
static const float STAR_SPEED = 150;
Star::Star(const Vector& pos, Direction direction) :
MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING),
- physic()
+ physic(),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
physic.set_velocity((direction == LEFT) ? -STAR_SPEED : STAR_SPEED, INITIALJUMP);
+ //set light for glow effect
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.4f, 0.4f, 0.4f));
}
void
}
void
+Star::draw(DrawingContext& context){
+ //Draw the Sprite.
+ MovingSprite::draw(context);
+ //Draw the light when dark
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green + light.blue < 3.0){
+ MovingSprite::draw(context);
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+}
+
+void
Star::collision_solid(const CollisionHit& hit)
{
if(hit.bottom) {
Star(const Vector& pos, Direction direction = RIGHT);
virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
virtual void collision_solid(const CollisionHit& hit);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
private:
Physic physic;
+ Color light;
+ SpritePtr lightsprite;
};
#endif
#include "object/weak_block.hpp"
+#include "math/random_generator.hpp"
#include "object/bullet.hpp"
#include "object/explosion.hpp"
#include "supertux/object_factory.hpp"
WeakBlock::WeakBlock(const Reader& lisp)
: MovingSprite(lisp, "images/objects/weak_block/strawbox.sprite", LAYER_TILES, COLGROUP_STATIC), state(STATE_NORMAL),
-linked(true)
+ linked(true),
+ light(0.0f,0.0f,0.0f),
+ lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
sprite->set_action("normal");
//Check if this weakblock destroys adjacent weakblocks
sprite->set_action("normal");
}
}
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
}
HitResponse
break;
case STATE_BURNING:
+ // cause burn light to flicker randomly
+ if (linked) {
+ if(gameRandom.rand(10) >= 7) {
+ lightsprite->set_color(Color(0.2f + gameRandom.rand(20)/100.0f, 0.1f + gameRandom.rand(20)/100.0f, 0.1f));
+ } else
+ lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
+ }
+
if (sprite->animation_done()) {
state = STATE_DISINTEGRATING;
sprite->set_action("disintegrating", 1);
spreadHit();
set_group(COLGROUP_DISABLED);
+ lightsprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite");
+ lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+ lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
}
break;
}
void
+WeakBlock::draw(DrawingContext& context)
+{
+ //Draw the Sprite.
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ //Draw the light if burning and dark
+ if(linked && (state != STATE_NORMAL)){
+ context.get_light( get_bbox().get_middle(), &light );
+ if (light.red + light.green + light.blue < 3.0){
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ lightsprite->draw(context, get_bbox().get_middle(), 0);
+ context.pop_target();
+ }
+ }
+}
+
+void
WeakBlock::startBurning()
{
if (state != STATE_NORMAL) return;
HitResponse collision(GameObject& other, const CollisionHit& hit);
void update(float elapsed_time);
+ void draw(DrawingContext& context);
protected:
/**
bool linked;
virtual HitResponse collision_bullet(Bullet& bullet, const CollisionHit& hit);
+ Color light;
+ SpritePtr lightsprite;
+
};
#endif
#include "badguy/fish.hpp"
#include "badguy/flame.hpp"
#include "badguy/flyingsnowball.hpp"
+#include "badguy/ghostflame.hpp"
#include "badguy/ghosttree.hpp"
#include "badguy/goldbomb.hpp"
#include "badguy/haywire.hpp"
+#include "badguy/iceflame.hpp"
#include "badguy/igel.hpp"
#include "badguy/jumpy.hpp"
#include "badguy/kamikazesnowball.hpp"
#include "badguy/kugelblitz.hpp"
+#include "badguy/livefire.hpp"
#include "badguy/mole.hpp"
#include "badguy/mole_rock.hpp"
#include "badguy/mrbomb.hpp"
add_factory<Fish>("fish");
add_factory<Flame>("flame");
add_factory<FlyingSnowBall>("flyingsnowball");
+ add_factory<Ghostflame>("ghostflame");
add_factory<GhostTree>("ghosttree");
add_factory<GoldBomb>("goldbomb");
add_factory<Haywire>("haywire");
+ add_factory<Iceflame>("iceflame");
add_factory<Igel>("igel");
add_factory<Jumpy>("jumpy");
add_factory<KamikazeSnowball>("kamikazesnowball");
add_factory<Kugelblitz>("kugelblitz");
+ add_factory<LiveFire>("livefire");
+ add_factory<LiveFireAsleep>("livefire_asleep");
+ add_factory<LiveFireDormant>("livefire_dormant");
add_factory<Mole>("mole");
add_factory<MoleRock>("mole_rock");
add_factory<MrBomb>("mrbomb");